From 56068b9244c31fb896d160939cfd4e7c7c1bcc9b Mon Sep 17 00:00:00 2001 From: Lev Zaplatin Date: Wed, 29 Dec 2021 22:49:12 +0300 Subject: [PATCH] Add postgis extention (#5) * feat: add postgis with proj * feat: add test postgis extension * fix: remove proj * fix: add protobuf-c-compiler dependencies --- src/postgresql/tests/test_postgresql.py | 12 ++++++++++++ src/tools/install_pg.sh | 21 ++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) 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;"') diff --git a/src/tools/install_pg.sh b/src/tools/install_pg.sh index 32f287b..ff321db 100755 --- a/src/tools/install_pg.sh +++ b/src/tools/install_pg.sh @@ -5,17 +5,32 @@ then else VERSION=13.4 fi +JOBS_NUMBER=4 +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 \ + libproj-dev protobuf-c-compiler +# 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 .. +# 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 +make -j ${JOBS_NUMBER} +make install +cd ..