Compare commits
No commits in common. "cyclosm" and "master" have entirely different histories.
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,7 +1,5 @@
|
|||||||
pbf/*.pbf
|
pbf/*.pbf
|
||||||
pbf/*.poly
|
pbf/*.poly
|
||||||
pbf/shp/*
|
|
||||||
pbf/*.tif
|
|
||||||
tiles/*
|
tiles/*
|
||||||
!tiles/.gitkeep
|
!tiles/.gitkeep
|
||||||
database/*
|
database/*
|
||||||
|
23
README.md
23
README.md
@ -20,29 +20,6 @@ For entering into the container, use the "terminal" argument of the run.sh scrip
|
|||||||
docker-compose run --rm map terminal
|
docker-compose run --rm map terminal
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Cyclosm data dependencies
|
|
||||||
|
|
||||||
##### Shp
|
|
||||||
|
|
||||||
Download the 2 following zip files, unzip them, and place them in the `pbf/shp` folder. They are mounted as volume in the docker-compose.yml.
|
|
||||||
|
|
||||||
- http://osmdata.openstreetmap.de/download/simplified-land-polygons-complete-3857.zip
|
|
||||||
- http://osmdata.openstreetmap.de/download/land-polygons-split-3857.zip
|
|
||||||
|
|
||||||
Also, rename them as in the zip file, so simplified-land-polygons-complete-3857.shp and land-polygons-split-3857.shp.
|
|
||||||
|
|
||||||
|
|
||||||
##### Contour lines
|
|
||||||
|
|
||||||
Download the geopackage from http://opendata.champs-libres.be/beautiful-contour-belgium.zip, convert it to shp and place it into the pbf/shp folder under the name "contours.shp". It will be mounted as written in the `docker-compose.yml` file.
|
|
||||||
|
|
||||||
The shp is imported using `shp2pgsql` in the import step, assuming EPSG:31370 as the input shp CRS.
|
|
||||||
|
|
||||||
#### Hillshade
|
|
||||||
|
|
||||||
Download the hillshade at http://opendata.champs-libres.be/hillshade_belgium_EPSG3857.zip and place the tif file in the pdf folder, as mounted in the `docker-compose.yml` file.
|
|
||||||
|
|
||||||
|
|
||||||
#### Do an import
|
#### Do an import
|
||||||
|
|
||||||
Download a pbf and a poly file of your choice on https://download.geofabrik.de and put it in the `pbf` folder. Change the lines of the pbf and poly paths in the volumes in the `docker-compose.yml` file
|
Download a pbf and a poly file of your choice on https://download.geofabrik.de and put it in the `pbf` folder. Change the lines of the pbf and poly paths in the volumes in the `docker-compose.yml` file
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<VirtualHost *:80>
|
<VirtualHost *:80>
|
||||||
ServerAdmin webmaster@localhost
|
ServerAdmin webmaster@localhost
|
||||||
|
|
||||||
AddTileConfig /tile/ cyclosm
|
AddTileConfig /tile/ default
|
||||||
LoadTileConfigFile /etc/renderd.conf
|
LoadTileConfigFile /etc/renderd.conf
|
||||||
ModTileRenderdSocketName /run/renderd/renderd.sock
|
ModTileRenderdSocketName /run/renderd/renderd.sock
|
||||||
ModTileRequestTimeout 0
|
ModTileRequestTimeout 0
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
; BASIC AND SIMPLE CONFIGURATION:
|
|
||||||
|
|
||||||
[renderd]
|
|
||||||
stats_file=/run/renderd/renderd.stats
|
|
||||||
socketname=/run/renderd/renderd.sock
|
|
||||||
num_threads=4
|
|
||||||
tile_dir=/var/cache/renderd/tiles
|
|
||||||
|
|
||||||
[mapnik]
|
|
||||||
plugins_dir=/usr/lib/mapnik/3.1/input
|
|
||||||
font_dir=/usr/share/fonts
|
|
||||||
font_dir_recurse=true
|
|
||||||
|
|
||||||
; ADD YOUR LAYERS:
|
|
||||||
[cyclosm]
|
|
||||||
URI=/tile/
|
|
||||||
TILEDIR=/var/cache/renderd/tiles
|
|
||||||
XML=/data/style/mapnik.xml
|
|
||||||
HOST=localhost
|
|
||||||
TILESIZE=256
|
|
||||||
MAXZOOM=20
|
|
@ -7,12 +7,9 @@ services:
|
|||||||
#- osm-data:/data/database/
|
#- osm-data:/data/database/
|
||||||
- ./database:/data/database/
|
- ./database:/data/database/
|
||||||
- ./tiles:/data/tiles/
|
- ./tiles:/data/tiles/
|
||||||
- ./cyclosm/renderd.conf:/etc/renderd.conf
|
|
||||||
- ./run.sh:/run.sh # for dev
|
- ./run.sh:/run.sh # for dev
|
||||||
- ./pbf/luxembourg-latest.osm.pbf:/data/region.osm.pbf # change here your pbf
|
- ./pbf/luxembourg-latest.osm.pbf:/data/region.osm.pbf # change here your pbf
|
||||||
- ./pbf/luxembourg.poly:/data/region.poly # and your poly
|
- ./pbf/luxembourg.poly:/data/region.poly # and your poly
|
||||||
- ./pbf/shp/:/data/shp/
|
|
||||||
- ./pbf/hillshade.tif:/data/hillshade.tif
|
|
||||||
ports:
|
ports:
|
||||||
- "8080:80"
|
- "8080:80"
|
||||||
command: "run"
|
command: "run"
|
||||||
|
69
run.sh
69
run.sh
@ -12,37 +12,6 @@ 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
|
|
||||||
# remove some deprecated fonts
|
|
||||||
sed -i 's/, "unifont Medium", "Unifont Upper Medium"//g' ./cyclosm-cartocss-style/fonts.mss
|
|
||||||
sed -i 's/"Noto Sans Tibetan Regular",//g' ./cyclosm-cartocss-style/fonts.mss
|
|
||||||
sed -i 's/"Noto Sans Tibetan Bold",//g' ./cyclosm-cartocss-style/fonts.mss
|
|
||||||
sed -i 's/Noto Sans Syriac Eastern Regular/Noto Sans Syriac Regular/g' ./cyclosm-cartocss-style/fonts.mss
|
|
||||||
# change hillshade
|
|
||||||
sed -i 's/*extents84/*extents/g' ./cyclosm-cartocss-style/project.mml
|
|
||||||
sed -i 's,dem/shade.vrt,/data/hillshade.tif,g' ./cyclosm-cartocss-style/project.mml
|
|
||||||
sed -z 's/status: off\n- id: contours100/status: on\n- id: contours100/' -i ./cyclosm-cartocss-style/project.mml
|
|
||||||
# change contours
|
|
||||||
sed -z 's/status: off\n- id: contours50/status: on\n- id: contours50/' -i ./cyclosm-cartocss-style/project.mml
|
|
||||||
sed -z 's/status: off\n- id: contours20/status: on\n- id: contours20/' -i ./cyclosm-cartocss-style/project.mml
|
|
||||||
sed -z 's/status: off\n- id: contours10/status: on\n- id: contours10/' -i ./cyclosm-cartocss-style/project.mml
|
|
||||||
sed -z 's/status: off\n- id: waterway_low/status: on\n- id: waterway_low/' -i ./cyclosm-cartocss-style/project.mml
|
|
||||||
sed -i 's/dbname: "contours"/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:"
|
||||||
@ -60,14 +29,22 @@ fi
|
|||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
|
# if there is no custom style mounted, then use osm-carto
|
||||||
|
if [ ! "$(ls -A /data/style/)" ]; then
|
||||||
|
mv /home/renderer/src/openstreetmap-carto-backup/* /data/style/
|
||||||
|
fi
|
||||||
|
|
||||||
|
# carto build
|
||||||
|
if [ ! -f /data/style/mapnik.xml ]; then
|
||||||
|
cd /data/style/
|
||||||
|
carto ${NAME_MML:-project.mml} > mapnik.xml
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$1" == "terminal" ]; then
|
if [ "$1" == "terminal" ]; then
|
||||||
bash
|
bash
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" == "import" ]; then
|
if [ "$1" == "import" ]; then
|
||||||
|
|
||||||
compileStyle
|
|
||||||
|
|
||||||
# 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/
|
||||||
chown renderer: /data/database/
|
chown renderer: /data/database/
|
||||||
@ -124,6 +101,9 @@ if [ "$1" == "import" ]; then
|
|||||||
|
|
||||||
# Import data
|
# Import data
|
||||||
sudo -u renderer osm2pgsql -d gis --create --slim -G --hstore \
|
sudo -u renderer osm2pgsql -d gis --create --slim -G --hstore \
|
||||||
|
--tag-transform-script /data/style/${NAME_LUA:-openstreetmap-carto.lua} \
|
||||||
|
--number-processes ${THREADS:-4} \
|
||||||
|
-S /data/style/${NAME_STYLE:-openstreetmap-carto.style} \
|
||||||
/data/region.osm.pbf \
|
/data/region.osm.pbf \
|
||||||
${OSM2PGSQL_EXTRA_ARGS:-} \
|
${OSM2PGSQL_EXTRA_ARGS:-} \
|
||||||
;
|
;
|
||||||
@ -139,12 +119,11 @@ if [ "$1" == "import" ]; then
|
|||||||
sudo -u postgres psql -d gis -f /data/style/${NAME_SQL:-indexes.sql}
|
sudo -u postgres psql -d gis -f /data/style/${NAME_SQL:-indexes.sql}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create cyclosm special views
|
#Import external data
|
||||||
sudo -u renderer psql -d gis -f "/data/style/cyclosm-cartocss-style/views.sql"
|
chown -R renderer: /home/renderer/src/ /data/style/
|
||||||
|
if [ -f /data/style/scripts/get-external-data.py ] && [ -f /data/style/external-data.yml ]; then
|
||||||
# Import contour files
|
sudo -E -u renderer python3 /data/style/scripts/get-external-data.py -c /data/style/external-data.yml -D /data/style/data
|
||||||
shp2pgsql -s 31370:3857 -c -g geometry -I /data/shp/contours.shp public.contours | sudo -u renderer psql -d gis
|
fi
|
||||||
sudo -u renderer psql -d gis -c "ALTER TABLE public.contours RENAME COLUMN elev TO height;"
|
|
||||||
|
|
||||||
# Register that data has changed for mod_tile caching purposes
|
# Register that data has changed for mod_tile caching purposes
|
||||||
sudo -u renderer touch /data/database/planet-import-complete
|
sudo -u renderer touch /data/database/planet-import-complete
|
||||||
@ -158,8 +137,6 @@ if [ "$1" == "run" ]; then
|
|||||||
# Clean /tmp
|
# Clean /tmp
|
||||||
rm -rf /tmp/*
|
rm -rf /tmp/*
|
||||||
|
|
||||||
compileStyle
|
|
||||||
|
|
||||||
# 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
|
||||||
mkdir /data/database/postgres/
|
mkdir /data/database/postgres/
|
||||||
@ -195,7 +172,7 @@ if [ "$1" == "run" ]; then
|
|||||||
setPostgresPassword
|
setPostgresPassword
|
||||||
|
|
||||||
# Configure renderd threads
|
# Configure renderd threads
|
||||||
#sed -i -E "s/num_threads=[0-9]+/num_threads=${THREADS:-4}/g" /etc/renderd.conf
|
sed -i -E "s/num_threads=[0-9]+/num_threads=${THREADS:-4}/g" /etc/renderd.conf
|
||||||
|
|
||||||
# start cron job to trigger consecutive updates
|
# start cron job to trigger consecutive updates
|
||||||
if [ "${UPDATES:-}" == "enabled" ] || [ "${UPDATES:-}" == "1" ]; then
|
if [ "${UPDATES:-}" == "enabled" ] || [ "${UPDATES:-}" == "1" ]; then
|
||||||
@ -224,16 +201,12 @@ fi
|
|||||||
|
|
||||||
if [ "$1" == "generate_tiles" ]; then
|
if [ "$1" == "generate_tiles" ]; then
|
||||||
|
|
||||||
compileStyle
|
|
||||||
|
|
||||||
service postgresql start
|
service postgresql start
|
||||||
service apache2 restart
|
service apache2 restart
|
||||||
|
|
||||||
sudo -u renderer renderd -c /etc/renderd.conf
|
sudo -u renderer renderd -c /etc/renderd.conf
|
||||||
|
|
||||||
cat /data/tiles/cyclosm/tiles.list | render_list --map cyclosm
|
cat /data/tiles/default/tiles.list | render_list --map default
|
||||||
|
|
||||||
bash
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "invalid command"
|
echo "invalid command"
|
||||||
|
Loading…
Reference in New Issue
Block a user