This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"workbench.colorCustomizations": { | ||
"activityBar.background": "#372937", | ||
"titleBar.activeBackground": "#4D394D", | ||
"titleBar.activeForeground": "#FBFAFB" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM postgis/postgis:14-3.2 AS builder | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends postgis | ||
|
||
FROM postgis/postgis:14-3.2 | ||
LABEL Author "Miguel Martinez <[email protected]>" | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
wget unzip \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& mkdir -p /docker-entrypoint-initdb.d | ||
|
||
ENV POSTGIS_MAJOR=3.2 | ||
|
||
COPY --from=builder /usr/bin/shp2pgsql /usr/bin/shp2pgsql | ||
COPY ./postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
## Container locations | ||
- `/var/lib/postgresql/gisdata/`: temp folder and staging for this container | ||
|
||
## Post container creation set-up | ||
run `post-install` script. It installs DC data only. | ||
|
||
## Test use-cases | ||
- template | ||
``` | ||
docker exec some-postgis-geocoder psql -U postgres -d geocoder -c "<YOUR SQL GOES HERE (paste it in 1 line)>" | ||
``` | ||
- query #1 geocoder usage | ||
``` | ||
SELECT g.rating, ST_X(g.geomout) As lon, ST_Y(g.geomout) As lat, (addy).address As stno, (addy).streetname As street, (addy).streettypeabbrev As styp, (addy).location As city, (addy).stateabbrev As st,(addy).zip FROM geocode('1600 Pennsylvania Ave NW, Washington, DC 20500') As g; | ||
``` | ||
pprinted | ||
``` | ||
SELECT | ||
g.rating, | ||
ST_X(g.geomout) As lon, | ||
ST_Y(g.geomout) As lat, | ||
(addy).address As stno, | ||
(addy).streetname As street, | ||
(addy).streettypeabbrev As styp, | ||
(addy).location As city, | ||
(addy).stateabbrev As st, | ||
(addy).zip | ||
FROM geocode('1600 Pennsylvania Ave NW, Washington, DC 20500') As g; | ||
``` | ||
- query #2 reverse geocoder usage | ||
``` | ||
SELECT pprint_addy(r.addy[1]) As st1, pprint_addy(r.addy[2]) As st2, pprint_addy(r.addy[3]) As st3, array_to_string(r.street, ',') As cross_streets FROM reverse_geocode(ST_GeomFromText('POINT(-77.00046877117504 38.8875068167358)',4269),true) As r; | ||
``` | ||
pprinted | ||
``` | ||
SELECT | ||
pprint_addy(r.addy[1]) As st1, | ||
pprint_addy(r.addy[2]) As st2, | ||
pprint_addy(r.addy[3]) As st3, | ||
array_to_string(r.street, ',') As cross_streets | ||
FROM reverse_geocode(ST_GeomFromText('POINT(-77.00046877117504 38.8875068167358)',4269),true) As r; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: "3.8" | ||
|
||
services: | ||
geocoder: | ||
container_name: some-postgis-geocoder | ||
build: | ||
context: . | ||
ports: | ||
- "5432:5432" | ||
environment: | ||
- POSTGRES_PASSWORD=postgres | ||
- POSTGRES_DB=geocoder | ||
- POSTGRES_USER=postgres | ||
- staging_fold=gisdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
docker exec some-postgis-geocoder bash /var/lib/postgresql/gisdata/nation.sh | ||
docker exec some-postgis-geocoder psql -U postgres -d geocoder -o /var/lib/postgresql/gisdata/DC.sh -A -t -c "SELECT loader_generate_script(ARRAY['DC'], 'geocoder') AS result;" | ||
docker exec some-postgis-geocoder chmod +x /var/lib/postgresql/gisdata/DC.sh | ||
docker exec some-postgis-geocoder bash /var/lib/postgresql/gisdata/DC.sh | ||
docker exec some-postgis-geocoder psql -U postgres -d geocoder -c "SELECT install_missing_indexes();" | ||
docker exec some-postgis-geocoder psql -U postgres -d geocoder -c "SELECT g.rating, ST_X(g.geomout) As lon, ST_Y(g.geomout) As lat, (addy).address As stno, (addy).streetname As street, (addy).streettypeabbrev As styp, (addy).location As city, (addy).stateabbrev As st,(addy).zip FROM geocode('1600 Pennsylvania Ave NW, Washington, DC 20500') As g;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
docker exec some-postgis-geocoder bash /var/lib/postgresql/gisdata/nation.sh | ||
docker exec some-postgis-geocoder psql -U postgres -d geocoder -o /var/lib/postgresql/gisdata/DC.sh -A -t -c "SELECT loader_generate_script(ARRAY['DC'], 'geocoder') AS result;" | ||
docker exec some-postgis-geocoder chmod +x /var/lib/postgresql/gisdata/DC.sh | ||
docker exec some-postgis-geocoder bash /var/lib/postgresql/gisdata/DC.sh | ||
docker exec some-postgis-geocoder psql -U postgres -d geocoder -c "SELECT install_missing_indexes();" | ||
docker exec some-postgis-geocoder psql -U postgres -d geocoder -c "SELECT g.rating, ST_X(g.geomout) As lon, ST_Y(g.geomout) As lat, (addy).address As stno, (addy).streetname As street, (addy).streettypeabbrev As styp, (addy).location As city, (addy).stateabbrev As st,(addy).zip FROM geocode('1600 Pennsylvania Ave NW, Washington, DC 20500') As g;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
# Perform all actions as $POSTGRES_USER | ||
export PGUSER="$POSTGRES_USER" | ||
|
||
# Create the 'template_postgis' template db | ||
psql <<EOSQL | ||
CREATE DATABASE template_postgis IS_TEMPLATE true; | ||
EOSQL | ||
|
||
# Load PostGIS into both template_database and $POSTGRES_DB | ||
for DB in template_postgis "$POSTGRES_DB"; do | ||
echo "Loading PostGIS extensions into $DB" | ||
psql --dbname="$DB" <<EOSQL | ||
CREATE EXTENSION IF NOT EXISTS postgis; | ||
CREATE EXTENSION IF NOT EXISTS postgis_topology; | ||
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; | ||
CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; | ||
INSERT INTO tiger.loader_platform(os, declare_sect, pgbin, wget, unzip_command, psql, path_sep, loader, environ_set_command, county_process_command) | ||
SELECT 'geocoder', | ||
'TMPDIR="/var/lib/postgresql/gisdata/temp/" | ||
UNZIPTOOL="/usr/bin/unzip" | ||
WGETTOOL="/usr/bin/wget" | ||
export PGBIN=/usr/lib/postgresql/${PG_MAJOR}/bin | ||
export PGPORT=5432 | ||
export PGHOST=localhost | ||
export PGUSER=postgres | ||
export PGPASSWORD=postgres | ||
export PGDATABASE=geocoder | ||
PSQL=psql | ||
SHP2PGSQL=/usr/bin/shp2pgsql | ||
cd /var/lib/postgresql/gisdata', | ||
pgbin, | ||
'wget --no-check-certificate', | ||
unzip_command, | ||
psql, | ||
path_sep, | ||
loader, | ||
environ_set_command, | ||
county_process_command | ||
FROM tiger.loader_platform WHERE os = 'sh'; | ||
UPDATE tiger.loader_variables | ||
SET staging_fold='/var/lib/postgresql/gisdata' | ||
WHERE staging_fold='/gisdata'; | ||
EOSQL | ||
done | ||
|
||
mkdir -p /var/lib/postgresql/gisdata/temp | ||
chmod 777 /var/lib/postgresql/gisdata | ||
|
||
psql -d $POSTGRES_DB -o /var/lib/postgresql/gisdata/nation.sh -A -t -c "SELECT loader_generate_nation_script('geocoder');" | ||
chmod +x /var/lib/postgresql/gisdata/nation.sh |