Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
7d636bc777 | ||
|
0a9fb88da2 | ||
|
c67dfbeb56 | ||
|
a62a10552b | ||
|
b994c64d6b | ||
|
f5c2022e7f | ||
|
830155628f | ||
|
40a760e941 | ||
|
6488beaf79 | ||
|
0fca85665f | ||
|
ebe7d6b336 | ||
|
0bbebc0f4a | ||
|
c2b79805a0 | ||
|
6276d18671 |
40
.drone.yml
Normal file
40
.drone.yml
Normal file
@ -0,0 +1,40 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: default
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
steps:
|
||||
- name: clone
|
||||
image: plugins/git
|
||||
settings:
|
||||
recursive: true
|
||||
|
||||
- name: download_pbf
|
||||
image: plugins/download
|
||||
settings:
|
||||
source: https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf
|
||||
#destination: /drone/src/
|
||||
|
||||
- name: import_pbf
|
||||
image: plugins/docker
|
||||
settings:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
pull_image: true
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
registry: h3m6q87t.gra7.container-registry.ovh.net
|
||||
repo: h3m6q87t.gra7.container-registry.ovh.net/osm_tile_server/map
|
||||
tag:
|
||||
- ${DRONE_TAG:=latest}
|
||||
commands:
|
||||
- sh run.sh import
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,7 @@
|
||||
pbf/*.pbf
|
||||
pbf/*.poly
|
||||
pbf/shp/*
|
||||
pbf/*.tif
|
||||
tiles/*
|
||||
!tiles/.gitkeep
|
||||
database/*
|
||||
|
@ -169,6 +169,6 @@ COPY --from=compiler-stylesheet /root/openstreetmap-carto /home/renderer/src/ope
|
||||
|
||||
# Start running
|
||||
COPY run.sh /
|
||||
ENTRYPOINT ["/run.sh"]
|
||||
#ENTRYPOINT ["/run.sh"]
|
||||
CMD []
|
||||
EXPOSE 80 5432
|
||||
|
23
README.md
23
README.md
@ -20,6 +20,29 @@ For entering into the container, use the "terminal" argument of the run.sh scrip
|
||||
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
|
||||
|
||||
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>
|
||||
ServerAdmin webmaster@localhost
|
||||
|
||||
AddTileConfig /tile/ default
|
||||
AddTileConfig /tile/ cyclosm
|
||||
LoadTileConfigFile /etc/renderd.conf
|
||||
ModTileRenderdSocketName /run/renderd/renderd.sock
|
||||
ModTileRequestTimeout 0
|
||||
|
21
cyclosm/renderd.conf
Normal file
21
cyclosm/renderd.conf
Normal file
@ -0,0 +1,21 @@
|
||||
; 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,9 +7,12 @@ services:
|
||||
#- osm-data:/data/database/
|
||||
- ./database:/data/database/
|
||||
- ./tiles:/data/tiles/
|
||||
- ./cyclosm/renderd.conf:/etc/renderd.conf
|
||||
- ./run.sh:/run.sh # for dev
|
||||
- ./pbf/luxembourg-latest.osm.pbf:/data/region.osm.pbf # change here your pbf
|
||||
- ./pbf/luxembourg.poly:/data/region.poly # and your poly
|
||||
- ./pbf/shp/:/data/shp/
|
||||
- ./pbf/hillshade.tif:/data/hillshade.tif
|
||||
ports:
|
||||
- "8080:80"
|
||||
command: "run"
|
||||
|
69
run.sh
69
run.sh
@ -12,6 +12,37 @@ function setPostgresPassword() {
|
||||
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
|
||||
echo "usage: <import|run>"
|
||||
echo "commands:"
|
||||
@ -29,22 +60,14 @@ fi
|
||||
|
||||
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
|
||||
bash
|
||||
fi
|
||||
|
||||
if [ "$1" == "import" ]; then
|
||||
|
||||
compileStyle
|
||||
|
||||
# Ensure that database directory is in right state
|
||||
mkdir -p /data/database/postgres/
|
||||
chown renderer: /data/database/
|
||||
@ -101,9 +124,6 @@ if [ "$1" == "import" ]; then
|
||||
|
||||
# Import data
|
||||
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 \
|
||||
${OSM2PGSQL_EXTRA_ARGS:-} \
|
||||
;
|
||||
@ -119,11 +139,12 @@ if [ "$1" == "import" ]; then
|
||||
sudo -u postgres psql -d gis -f /data/style/${NAME_SQL:-indexes.sql}
|
||||
fi
|
||||
|
||||
#Import external data
|
||||
chown -R renderer: /home/renderer/src/ /data/style/
|
||||
if [ -f /data/style/scripts/get-external-data.py ] && [ -f /data/style/external-data.yml ]; then
|
||||
sudo -E -u renderer python3 /data/style/scripts/get-external-data.py -c /data/style/external-data.yml -D /data/style/data
|
||||
fi
|
||||
# Create cyclosm special views
|
||||
sudo -u renderer psql -d gis -f "/data/style/cyclosm-cartocss-style/views.sql"
|
||||
|
||||
# Import contour files
|
||||
shp2pgsql -s 31370:3857 -c -g geometry -I /data/shp/contours.shp public.contours | sudo -u renderer psql -d gis
|
||||
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
|
||||
sudo -u renderer touch /data/database/planet-import-complete
|
||||
@ -137,6 +158,8 @@ if [ "$1" == "run" ]; then
|
||||
# Clean /tmp
|
||||
rm -rf /tmp/*
|
||||
|
||||
compileStyle
|
||||
|
||||
# migrate old files
|
||||
if [ -f /data/database/PG_VERSION ] && ! [ -d /data/database/postgres/ ]; then
|
||||
mkdir /data/database/postgres/
|
||||
@ -172,7 +195,7 @@ if [ "$1" == "run" ]; then
|
||||
setPostgresPassword
|
||||
|
||||
# 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
|
||||
if [ "${UPDATES:-}" == "enabled" ] || [ "${UPDATES:-}" == "1" ]; then
|
||||
@ -201,12 +224,16 @@ fi
|
||||
|
||||
if [ "$1" == "generate_tiles" ]; then
|
||||
|
||||
compileStyle
|
||||
|
||||
service postgresql start
|
||||
service apache2 restart
|
||||
|
||||
sudo -u renderer renderd -c /etc/renderd.conf
|
||||
|
||||
cat /data/tiles/default/tiles.list | render_list --map default
|
||||
cat /data/tiles/cyclosm/tiles.list | render_list --map cyclosm
|
||||
|
||||
bash
|
||||
fi
|
||||
|
||||
echo "invalid command"
|
||||
|
Loading…
Reference in New Issue
Block a user