Cyclosm: factorise compile-style function and change dbname in project.mml

This commit is contained in:
nobohan 2023-06-26 09:02:43 +02:00
parent ebe7d6b336
commit 0fca85665f

37
run.sh
View File

@ -12,6 +12,22 @@ function setPostgresPassword() {
sudo -u postgres psql -c "ALTER USER renderer PASSWORD '${PGPASSWORD:-renderer}'" sudo -u postgres psql -c "ALTER USER renderer PASSWORD '${PGPASSWORD:-renderer}'"
} }
function compileStyle() {
cd /data/style/
git clone --single-branch --branch v0.6 https://github.com/cyclosm/cyclosm-cartocss-style.git --depth 1
# mv symbols folder
mkdir /data/style/symbols/
mv /data/style/cyclosm-cartocss-style/symbols/* /data/style/symbols/
# change shp paths
sed -i "s,file: http://osmdata.openstreetmap.de/download,file: /data/shp,g" ./cyclosm-cartocss-style/project.mml
sed -i "s/.zip/.shp/g" ./cyclosm-cartocss-style/project.mml
# change dbname
sed -i 's/dbname: "osm"/dbname: "gis"/g' ./cyclosm-cartocss-style/project.mml
# carto build
carto cyclosm-cartocss-style/project.mml > mapnik.xml
}
if [ "$#" -ne 1 ]; then if [ "$#" -ne 1 ]; then
echo "usage: <import|run>" echo "usage: <import|run>"
echo "commands:" echo "commands:"
@ -35,15 +51,7 @@ fi
if [ "$1" == "import" ]; then if [ "$1" == "import" ]; then
cd /data/style/ compileStyle
git clone --single-branch --branch v0.6 https://github.com/cyclosm/cyclosm-cartocss-style.git --depth 1
mkdir /data/style/symbols/
mv /data/style/cyclosm-cartocss-style/symbols/* /data/style/symbols/
# change shp paths
sed -i "s,file: http://osmdata.openstreetmap.de/download,file: /data/shp,g" ./cyclosm-cartocss-style/project.mml
sed -i "s/.zip/.shp/g" ./cyclosm-cartocss-style/project.mml
# carto build
carto cyclosm-cartocss-style/project.mml > mapnik.xml
# Ensure that database directory is in right state # Ensure that database directory is in right state
mkdir -p /data/database/postgres/ mkdir -p /data/database/postgres/
@ -134,16 +142,7 @@ if [ "$1" == "run" ]; then
# Clean /tmp # Clean /tmp
rm -rf /tmp/* rm -rf /tmp/*
cd /data/style/ compileStyle
git clone --single-branch --branch v0.6 https://github.com/cyclosm/cyclosm-cartocss-style.git --depth 1
mkdir /data/style/symbols/
mv /data/style/cyclosm-cartocss-style/symbols/* /data/style/symbols/
# change shp paths
sed -i "s,file: http://osmdata.openstreetmap.de/download,file: /data/shp,g" ./cyclosm-cartocss-style/project.mml
sed -i "s/.zip/.shp/g" ./cyclosm-cartocss-style/project.mml
# carto build
carto cyclosm-cartocss-style/project.mml > mapnik.xml
# migrate old files # migrate old files
if [ -f /data/database/PG_VERSION ] && ! [ -d /data/database/postgres/ ]; then if [ -f /data/database/PG_VERSION ] && ! [ -d /data/database/postgres/ ]; then