Skip to content

Commit

Permalink
Add postgis extention (#5)
Browse files Browse the repository at this point in the history
* feat: add postgis with proj

* feat: add test postgis extension

* fix: remove proj

* fix: add protobuf-c-compiler dependencies
  • Loading branch information
LevZaplatin authored Dec 29, 2021
1 parent 46f4b9d commit 56068b9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/postgresql/tests/test_postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;"')
21 changes: 18 additions & 3 deletions src/tools/install_pg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..

0 comments on commit 56068b9

Please sign in to comment.