docker-renderd-osm/renderd/run

46 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
exec 2>&1
source /etc/envvars
sed -i -e "s/{{OSM_CARTO_XML_DIR}}/\/usr\/share\/mapnik\/openstreetmap-carto-$OSM_CARTO_VERSION\/style.xml/" \
-e "s/{{PLUGINS_DIR}}/\/usr\/lib\/mapnik\/3.0\/input\//" \
-e "s/{{HOST}}/localhost/" \
/usr/local/etc/renderd.conf
sed -i -e "s/{{OSM_BRIGHT_XML_DIR}}/\/usr\/share\/mapnik\/osm-bright-$OSM_BRIGHT_VERSION\/OSMBright\/style.xml/" \
/usr/local/etc/renderd.conf
# osm-carto setup
cd /usr/share/mapnik/openstreetmap-carto-$OSM_CARTO_VERSION/
cp project.mml.orig project.mml
sed -i "s/ dbname: \"gis\"/ host: \"$PG_ENV_OSM_HOST\"\n\
port: \"$PG_ENV_OSM_PORT\"\n\
user: \"$PG_ENV_OSM_USER\"\n\
password: \"$PG_ENV_OSM_PASSWORD\"\n\
dbname: \"$PG_ENV_OSM_DB\"/" project.mml
carto project.mml > style.xml
# osm-bright setup
cd /usr/share/mapnik/osm-bright-$OSM_BRIGHT_VERSION/
cp configure.py.sample configure.py
# prepare configure.py
sed -i -e "s|^config\[\"path\"\].*|config\[\"path\"\] = \"$(pwd)\"|" \
-e "s/^config\[\"postgis\"\]\[\"host\"\].*/config\[\"postgis\"\]\[\"host\"\] = \"$PG_ENV_OSM_HOST\"/" \
-e "s/^config\[\"postgis\"\]\[\"port\"\].*/config\[\"postgis\"\]\[\"port\"\] = \"$PG_ENV_OSM_PORT\"/" \
-e "s/^config\[\"postgis\"\]\[\"dbname\"\].*/config\[\"postgis\"\]\[\"dbname\"\] = \"$PG_ENV_OSM_DB\"/" \
-e "s/^config\[\"postgis\"\]\[\"password\"\].*/config\[\"postgis\"\]\[\"password\"\] = \"$PG_ENV_OSM_PASSWORD\"/" \
-e "s/^config\[\"postgis\"\]\[\"user\"\].*/config\[\"postgis\"\]\[\"user\"\] = \"$PG_ENV_OSM_USER\"/" configure.py
./make.py
cd OSMBright
cat >fix-mml.pl <<EOF
#!/usr/bin/perl -p
s/"srs": null,//;
s/name, z_order \\\n FROM planet_osm_point \\\n WHERE railway = 'station'\\\n ORDER BY z_order NULLS LAST/name FROM planet_osm_point WHERE railway = 'station'/;
s/z_order, population\\\n FROM planet_osm_point/(tags->'population') population FROM planet_osm_point/;
EOF
perl -p fix-mml.pl < project.mml > project.local.mml
carto project.local.mml > style.xml
exec sudo -u www-data LD_LIBRARY_PATH=/usr/local/lib/ /usr/local/bin/renderd -f --config /usr/local/etc/renderd.conf