Skip to content

Commit 56068b9

Browse files
authored
Add postgis extention (#5)
* feat: add postgis with proj * feat: add test postgis extension * fix: remove proj * fix: add protobuf-c-compiler dependencies
1 parent 46f4b9d commit 56068b9

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

src/postgresql/tests/test_postgresql.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,15 @@ def test_uuid_ossp_extension(tmp_postgres):
2525
def test_xml2_extension(tmp_postgres):
2626
pgdata, con_str = tmp_postgres
2727
postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION xml2;"')
28+
29+
30+
def test_postgis_extension(tmp_postgres):
31+
pgdata, con_str = tmp_postgres
32+
postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION postgis;"')
33+
postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION postgis_raster;"')
34+
postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION postgis_topology;"')
35+
postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION postgis_sfcgal;"')
36+
postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION fuzzystrmatch;"')
37+
postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION address_standardizer;"')
38+
postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION address_standardizer_data_us;"')
39+
postgresql.psql(f'-d "{con_str}" -c "CREATE EXTENSION postgis_tiger_geocoder;"')

src/tools/install_pg.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,32 @@ then
55
else
66
VERSION=13.4
77
fi
8+
JOBS_NUMBER=4
9+
POSTGIS_VERSION=3.2.0
810

911
export DEBIAN_FRONTEND=noninteractive
1012

1113
sudo apt update
12-
sudo apt install -y zlib1g-dev libreadline-dev libossp-uuid-dev libxml2-dev libxslt1-dev curl make gcc
13-
curl -L -O https://ftp.postgresql.org/pub/source/v${VERSION}/postgresql-${VERSION}.tar.gz
14+
sudo apt install -y zlib1g-dev libreadline-dev libossp-uuid-dev libxml2-dev \
15+
libxslt1-dev curl make gcc pkg-config libgeos-dev libxml2-utils \
16+
libjson-c-dev proj-bin g++ libsqlite3-dev libtiff-dev \
17+
libcurl4-gnutls-dev libprotobuf-c-dev libgdal-dev libsfcgal-dev \
18+
libproj-dev protobuf-c-compiler
1419

20+
# Build Postgresql
21+
curl -L -O https://ftp.postgresql.org/pub/source/v${VERSION}/postgresql-${VERSION}.tar.gz
1522
tar -xzf postgresql-${VERSION}.tar.gz
1623
cd postgresql-${VERSION}
1724
./configure --prefix=`pwd`/../src/postgresql --with-ossp-uuid --with-libxml --with-libxslt
18-
make -j 4 world-bin
25+
make -j ${JOBS_NUMBER} world-bin
1926
make install-world-bin
2027
cd ..
2128

29+
# Build PostGIS
30+
curl -L -O https://download.osgeo.org/postgis/source/postgis-${POSTGIS_VERSION}.tar.gz
31+
tar -xzvf postgis-${POSTGIS_VERSION}.tar.gz
32+
cd postgis-${POSTGIS_VERSION}
33+
./configure --with-pgconfig=`pwd`/../src/postgresql/bin/pg_config
34+
make -j ${JOBS_NUMBER}
35+
make install
36+
cd ..

0 commit comments

Comments
 (0)