From 59f7f0be875ec926de6d27f5311bf7b39667ae8f Mon Sep 17 00:00:00 2001 From: Lev Zaplatin Date: Wed, 29 Dec 2021 21:49:27 +0300 Subject: [PATCH 1/4] feat: add postgis with proj --- src/tools/install_pg.sh | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/tools/install_pg.sh b/src/tools/install_pg.sh index 32f287b..834ae9a 100755 --- a/src/tools/install_pg.sh +++ b/src/tools/install_pg.sh @@ -5,17 +5,41 @@ then else VERSION=13.4 fi +JOBS_NUMBER=4 +PROJ_VERSION=8.2.0 +POSTGIS_VERSION=3.2.0 export DEBIAN_FRONTEND=noninteractive sudo apt update -sudo apt install -y zlib1g-dev libreadline-dev libossp-uuid-dev libxml2-dev libxslt1-dev curl make gcc -curl -L -O https://ftp.postgresql.org/pub/source/v${VERSION}/postgresql-${VERSION}.tar.gz +sudo apt install -y zlib1g-dev libreadline-dev libossp-uuid-dev libxml2-dev \ + libxslt1-dev curl make gcc pkg-config libgeos-dev libxml2-utils \ + libjson-c-dev proj-bin g++ libsqlite3-dev libtiff-dev \ + libcurl4-gnutls-dev libprotobuf-c-dev libgdal-dev libsfcgal-dev +# Build Postgresql +curl -L -O https://ftp.postgresql.org/pub/source/v${VERSION}/postgresql-${VERSION}.tar.gz tar -xzf postgresql-${VERSION}.tar.gz cd postgresql-${VERSION} ./configure --prefix=`pwd`/../src/postgresql --with-ossp-uuid --with-libxml --with-libxslt -make -j 4 world-bin +make -j ${JOBS_NUMBER} world-bin make install-world-bin cd .. +# Proj, need for PostGIS +curl -L -O https://download.osgeo.org/proj/proj-${PROJ_VERSION}.tar.gz +tar -xzvf proj-${PROJ_VERSION}.tar.gz +cd proj-${PROJ_VERSION} +./configure --prefix=`pwd`/../src/proj +make -j ${JOBS_NUMBER} +make install +cd .. + +# PostGIS +curl -L -O https://download.osgeo.org/postgis/source/postgis-${POSTGIS_VERSION}.tar.gz +tar -xzvf postgis-${POSTGIS_VERSION}.tar.gz +cd postgis-${POSTGIS_VERSION} +./configure --with-pgconfig=`pwd`/../src/postgresql/bin/pg_config --with-projdir=`pwd`/../src/proj +make -j ${JOBS_NUMBER} +make install +cd .. From 3ab86463db6ec7d0c3b0604e223a6415b7153d13 Mon Sep 17 00:00:00 2001 From: Lev Zaplatin Date: Wed, 29 Dec 2021 21:53:27 +0300 Subject: [PATCH 2/4] feat: add test postgis extension --- src/postgresql/tests/test_postgresql.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/postgresql/tests/test_postgresql.py b/src/postgresql/tests/test_postgresql.py index 24f9f5f..31923ff 100644 --- a/src/postgresql/tests/test_postgresql.py +++ b/src/postgresql/tests/test_postgresql.py @@ -25,3 +25,15 @@ def test_uuid_ossp_extension(tmp_postgres): def test_xml2_extension(tmp_postgres): pgdata, con_str = tmp_postgres postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION xml2;"') + + +def test_postgis_extension(tmp_postgres): + pgdata, con_str = tmp_postgres + postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION postgis;"') + postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION postgis_raster;"') + postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION postgis_topology;"') + postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION postgis_sfcgal;"') + postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION fuzzystrmatch;"') + postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION address_standardizer;"') + postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION address_standardizer_data_us;"') + postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION postgis_tiger_geocoder;"') From e01ec39ddaa33c03dfa7c60ea6b13e7426a30a46 Mon Sep 17 00:00:00 2001 From: Lev Zaplatin Date: Wed, 29 Dec 2021 22:03:14 +0300 Subject: [PATCH 3/4] fix: remove proj --- src/tools/install_pg.sh | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/tools/install_pg.sh b/src/tools/install_pg.sh index 834ae9a..243681e 100755 --- a/src/tools/install_pg.sh +++ b/src/tools/install_pg.sh @@ -6,7 +6,6 @@ else VERSION=13.4 fi JOBS_NUMBER=4 -PROJ_VERSION=8.2.0 POSTGIS_VERSION=3.2.0 export DEBIAN_FRONTEND=noninteractive @@ -15,7 +14,8 @@ sudo apt update sudo apt install -y zlib1g-dev libreadline-dev libossp-uuid-dev libxml2-dev \ libxslt1-dev curl make gcc pkg-config libgeos-dev libxml2-utils \ libjson-c-dev proj-bin g++ libsqlite3-dev libtiff-dev \ - libcurl4-gnutls-dev libprotobuf-c-dev libgdal-dev libsfcgal-dev + libcurl4-gnutls-dev libprotobuf-c-dev libgdal-dev libsfcgal-dev \ + libproj-dev # Build Postgresql curl -L -O https://ftp.postgresql.org/pub/source/v${VERSION}/postgresql-${VERSION}.tar.gz @@ -26,20 +26,11 @@ make -j ${JOBS_NUMBER} world-bin make install-world-bin cd .. -# Proj, need for PostGIS -curl -L -O https://download.osgeo.org/proj/proj-${PROJ_VERSION}.tar.gz -tar -xzvf proj-${PROJ_VERSION}.tar.gz -cd proj-${PROJ_VERSION} -./configure --prefix=`pwd`/../src/proj -make -j ${JOBS_NUMBER} -make install -cd .. - -# PostGIS +# Build PostGIS curl -L -O https://download.osgeo.org/postgis/source/postgis-${POSTGIS_VERSION}.tar.gz tar -xzvf postgis-${POSTGIS_VERSION}.tar.gz cd postgis-${POSTGIS_VERSION} -./configure --with-pgconfig=`pwd`/../src/postgresql/bin/pg_config --with-projdir=`pwd`/../src/proj +./configure --with-pgconfig=`pwd`/../src/postgresql/bin/pg_config make -j ${JOBS_NUMBER} make install cd .. From 1eaaf00f3486a55f8247de2d7f521b2f948597e0 Mon Sep 17 00:00:00 2001 From: Lev Zaplatin Date: Wed, 29 Dec 2021 22:12:51 +0300 Subject: [PATCH 4/4] fix: add protobuf-c-compiler dependencies --- src/tools/install_pg.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/install_pg.sh b/src/tools/install_pg.sh index 243681e..ff321db 100755 --- a/src/tools/install_pg.sh +++ b/src/tools/install_pg.sh @@ -15,7 +15,7 @@ sudo apt install -y zlib1g-dev libreadline-dev libossp-uuid-dev libxml2-dev \ libxslt1-dev curl make gcc pkg-config libgeos-dev libxml2-utils \ libjson-c-dev proj-bin g++ libsqlite3-dev libtiff-dev \ libcurl4-gnutls-dev libprotobuf-c-dev libgdal-dev libsfcgal-dev \ - libproj-dev + libproj-dev protobuf-c-compiler # Build Postgresql curl -L -O https://ftp.postgresql.org/pub/source/v${VERSION}/postgresql-${VERSION}.tar.gz