.osm.pbf and .poly files env done
This commit is contained in:
parent
dc47871a5d
commit
61b803c42e
23
run.sh
23
run.sh
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
PBF_FILE=${PBF_FILE:="/data/region.osm.pbf"}
|
||||||
|
POLY_FILE=${POLY_FILE:="/data/region.poly"}
|
||||||
|
|
||||||
function createPostgresConfig() {
|
function createPostgresConfig() {
|
||||||
cp /etc/postgresql/14/main/postgresql.custom.conf.tmpl /etc/postgresql/14/main/conf.d/postgresql.custom.conf
|
cp /etc/postgresql/14/main/postgresql.custom.conf.tmpl /etc/postgresql/14/main/conf.d/postgresql.custom.conf
|
||||||
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/14/main/conf.d/postgresql.custom.conf
|
sudo -u postgres echo "autovacuum = $AUTOVACUUM" >> /etc/postgresql/14/main/conf.d/postgresql.custom.conf
|
||||||
@ -15,11 +18,13 @@ function setPostgresPassword() {
|
|||||||
if [ "$#" -ne 1 ]; then
|
if [ "$#" -ne 1 ]; then
|
||||||
echo "usage: <import|run>"
|
echo "usage: <import|run>"
|
||||||
echo "commands:"
|
echo "commands:"
|
||||||
echo " import: Set up the database and import /data/region.osm.pbf"
|
echo " import: Set up the database and import $PBF_FILE"
|
||||||
echo " run: Runs Apache and renderd to serve tiles at /tile/{z}/{x}/{y}.png"
|
echo " run: Runs Apache and renderd to serve tiles at /tile/{z}/{x}/{y}.png"
|
||||||
echo "environment variables:"
|
echo "environment variables:"
|
||||||
echo " THREADS: defines number of threads used for importing / tile rendering"
|
echo " THREADS: defines number of threads used for importing / tile rendering"
|
||||||
echo " UPDATES: consecutive updates (enabled/disabled)"
|
echo " UPDATES: consecutive updates (enabled/disabled)"
|
||||||
|
echo " PBF_FILE: path to .osm.pbf file to import (/data/region.osm.pbf if not provided)"
|
||||||
|
echo " POLY_FILE: path to .poly file (/data/region.poly if not provided) (optional)"
|
||||||
echo " NAME_LUA: name of .lua script to run as part of the style"
|
echo " NAME_LUA: name of .lua script to run as part of the style"
|
||||||
echo " NAME_STYLE: name of the .style to use"
|
echo " NAME_STYLE: name of the .style to use"
|
||||||
echo " NAME_MML: name of the .mml file to render to mapnik.xml"
|
echo " NAME_MML: name of the .mml file to render to mapnik.xml"
|
||||||
@ -61,32 +66,32 @@ if [ "$1" == "import" ]; then
|
|||||||
setPostgresPassword
|
setPostgresPassword
|
||||||
|
|
||||||
# Download Luxembourg as sample if no data is provided
|
# Download Luxembourg as sample if no data is provided
|
||||||
if [ ! -f /data/region.osm.pbf ] && [ -z "${DOWNLOAD_PBF:-}" ]; then
|
if [ ! -f $PBF_FILE ] && [ -z "${DOWNLOAD_PBF:-}" ]; then
|
||||||
echo "WARNING: No import file at /data/region.osm.pbf, so importing Luxembourg as example..."
|
echo "WARNING: No import file at $PBF_FILE, so importing Luxembourg as example..."
|
||||||
DOWNLOAD_PBF="https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf"
|
DOWNLOAD_PBF="https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf"
|
||||||
DOWNLOAD_POLY="https://download.geofabrik.de/europe/luxembourg.poly"
|
DOWNLOAD_POLY="https://download.geofabrik.de/europe/luxembourg.poly"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${DOWNLOAD_PBF:-}" ]; then
|
if [ -n "${DOWNLOAD_PBF:-}" ]; then
|
||||||
echo "INFO: Download PBF file: $DOWNLOAD_PBF"
|
echo "INFO: Download PBF file: $DOWNLOAD_PBF"
|
||||||
wget ${WGET_ARGS:-} "$DOWNLOAD_PBF" -O /data/region.osm.pbf
|
wget ${WGET_ARGS:-} "$DOWNLOAD_PBF" -O $PBF_FILE
|
||||||
if [ -n "$DOWNLOAD_POLY" ]; then
|
if [ -n "$DOWNLOAD_POLY" ]; then
|
||||||
echo "INFO: Download PBF-POLY file: $DOWNLOAD_POLY"
|
echo "INFO: Download PBF-POLY file: $DOWNLOAD_POLY"
|
||||||
wget ${WGET_ARGS:-} "$DOWNLOAD_POLY" -O /data/region.poly
|
wget ${WGET_ARGS:-} "$DOWNLOAD_POLY" -O $POLY_FILE
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${UPDATES:-}" == "enabled" ] || [ "${UPDATES:-}" == "1" ]; then
|
if [ "${UPDATES:-}" == "enabled" ] || [ "${UPDATES:-}" == "1" ]; then
|
||||||
# determine and set osmosis_replication_timestamp (for consecutive updates)
|
# determine and set osmosis_replication_timestamp (for consecutive updates)
|
||||||
REPLICATION_TIMESTAMP=`osmium fileinfo /data/region.osm.pbf | grep 'osmosis_replication_timestamp=' | cut -b35-44`
|
REPLICATION_TIMESTAMP=`osmium fileinfo $PBF_FILE | grep 'osmosis_replication_timestamp=' | cut -b35-44`
|
||||||
|
|
||||||
# initial setup of osmosis workspace (for consecutive updates)
|
# initial setup of osmosis workspace (for consecutive updates)
|
||||||
sudo -u renderer openstreetmap-tiles-update-expire.sh $REPLICATION_TIMESTAMP
|
sudo -u renderer openstreetmap-tiles-update-expire.sh $REPLICATION_TIMESTAMP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# copy polygon file if available
|
# copy polygon file if available
|
||||||
if [ -f /data/region.poly ]; then
|
if [ -f $POLY_FILE ]; then
|
||||||
cp /data/region.poly /data/database/region.poly
|
cp $POLY_FILE /data/database/region.poly
|
||||||
chown renderer: /data/database/region.poly
|
chown renderer: /data/database/region.poly
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -100,7 +105,7 @@ if [ "$1" == "import" ]; then
|
|||||||
--tag-transform-script /data/style/${NAME_LUA:-openstreetmap-carto.lua} \
|
--tag-transform-script /data/style/${NAME_LUA:-openstreetmap-carto.lua} \
|
||||||
--number-processes ${THREADS:-4} \
|
--number-processes ${THREADS:-4} \
|
||||||
-S /data/style/${NAME_STYLE:-openstreetmap-carto.style} \
|
-S /data/style/${NAME_STYLE:-openstreetmap-carto.style} \
|
||||||
/data/region.osm.pbf \
|
$PBF_FILE \
|
||||||
${OSM2PGSQL_EXTRA_ARGS:-} \
|
${OSM2PGSQL_EXTRA_ARGS:-} \
|
||||||
;
|
;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user