Compare commits

..

1 Commits

Author SHA1 Message Date
nobohan
c67dfbeb56 init drone: download pbf with plugin
Some checks failed
continuous-integration/drone/tag Build is failing
2023-07-03 15:12:50 +02:00
8 changed files with 70 additions and 61 deletions

23
.drone.yml Normal file
View File

@@ -0,0 +1,23 @@
---
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/pbf

View File

@@ -20,7 +20,17 @@ 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
``` ```
#### OAM data dependencies #### 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 ##### Contour lines
@@ -43,7 +53,7 @@ Then, you can import the OSM data by doing this command:
docker-compose run --rm map import docker-compose run --rm map import
``` ```
This will take a while, about 15 min for Luxembourg for example, but up to 7 hours for Belgium with OAM! This will take a while, about 15 min for Luxembourg for example.
You should end with : You should end with :
@@ -79,14 +89,6 @@ Move this `tiles.list` file in the `/tiles/` directory and then run:
docker-compose run --rm map generate_tiles docker-compose run --rm map generate_tiles
``` ```
For Belgium up to zoom 18, it might take >48 hours!
#### Transfer the tiles to tiles.champs-libres.be
```bash
rsync --compress --recursive ./tiles/cyclosm debian@juniperus.champs-libres.be:/var/lib/mod_tile/
```
## Original README ## Original README

View File

@@ -9,8 +9,6 @@
DocumentRoot /var/www/html DocumentRoot /var/www/html
ServerName 192.168.192.2
ErrorLog ${APACHE_LOG_DIR}/error.log ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined CustomLog ${APACHE_LOG_DIR}/access.log combined

View File

@@ -12,7 +12,7 @@ font_dir=/usr/share/fonts
font_dir_recurse=true font_dir_recurse=true
; ADD YOUR LAYERS: ; ADD YOUR LAYERS:
[oam] [cyclosm]
URI=/tile/ URI=/tile/
TILEDIR=/var/cache/renderd/tiles TILEDIR=/var/cache/renderd/tiles
XML=/data/style/mapnik.xml XML=/data/style/mapnik.xml

View File

@@ -7,15 +7,14 @@ services:
#- osm-data:/data/database/ #- osm-data:/data/database/
- ./database:/data/database/ - ./database:/data/database/
- ./tiles:/data/tiles/ - ./tiles:/data/tiles/
- ./oam/renderd.conf:/etc/renderd.conf - ./cyclosm/renderd.conf:/etc/renderd.conf
- ./oam/alter_view_owner.sql:/data/alter_view_owner.sql
- ./run.sh:/run.sh # for dev - ./run.sh:/run.sh # for dev
- ./pbf/belgium-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 -> not used - ./pbf/luxembourg.poly:/data/region.poly # and your poly
- ./pbf/shp/:/data/shp/ - ./pbf/shp/:/data/shp/
- ./pbf/hillshade.tif:/data/hillshade.tif - ./pbf/hillshade.tif:/data/hillshade.tif
ports: ports:
- "9000:80" - "8080:80"
command: "run" command: "run"
# volumes: # volumes:

View File

@@ -1,20 +0,0 @@
ALTER TABLE landuse OWNER TO renderer;
ALTER TABLE train_elements OWNER TO renderer;
ALTER TABLE places OWNER TO renderer;
ALTER TABLE linear_features OWNER TO renderer;
ALTER TABLE buildings OWNER TO renderer;
ALTER TABLE cemeteries OWNER TO renderer;
ALTER TABLE bridge_symbols OWNER TO renderer;
ALTER TABLE landuse_overlays OWNER TO renderer;
ALTER TABLE waters OWNER TO renderer;
ALTER TABLE waterways OWNER TO renderer;
ALTER TABLE boundaries OWNER TO renderer;
ALTER TABLE tunnels OWNER TO renderer;
ALTER TABLE bridges OWNER TO renderer;
ALTER TABLE roads OWNER TO renderer;
ALTER TABLE rotated_buildings OWNER TO renderer;
ALTER TABLE trails OWNER TO renderer;
ALTER TABLE point_features OWNER TO renderer;
ALTER TABLE pitch OWNER TO renderer;
ALTER TABLE landuse_label OWNER TO renderer;
ALTER TABLE waterway_label OWNER TO renderer;

43
run.sh
View File

@@ -14,20 +14,32 @@ function setPostgresPassword() {
function compileStyle() { function compileStyle() {
cd /data/style/ cd /data/style/
git clone --single-branch --branch osm-tile-server https://github.com/nobohan/OpenArdenneMap.git --depth 1 git clone --single-branch --branch v0.6 https://github.com/cyclosm/cyclosm-cartocss-style.git --depth 1
# mv symbols folder # mv symbols folder
mkdir /data/img/ mkdir /data/style/symbols/
mv /data/style/OpenArdenneMap/img/* /data/img/ mv /data/style/cyclosm-cartocss-style/symbols/* /data/style/symbols/
# copy fonts # change shp paths
cp /data/style/OpenArdenneMap/fonts/* /usr/share/fonts/ 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 # change dbname
sed -i 's/"dbname": "osmpg_db",/"dbname": "gis",/g' ./OpenArdenneMap/osm2pgsql/project.mml 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 # change hillshade
sed -i 's,/mnt/tera/ChampsLibres/Projets/OSM/CyclOSM/hillshade/data/dem_be_10x10_hillshade_semi_transparent_3857.tif,/data/hillshade.tif,g' ./OpenArdenneMap/osm2pgsql/project.mml 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 # change contours
sed -i 's,../contour/beautiful_contour_belgium.shp,/data/shp/contours_3857.shp,g' ./OpenArdenneMap/osm2pgsql/project.mml 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 build
carto OpenArdenneMap/osm2pgsql/project.mml > mapnik.xml carto cyclosm-cartocss-style/project.mml > mapnik.xml
} }
@@ -71,7 +83,6 @@ if [ "$1" == "import" ]; then
sudo -u postgres createdb -E UTF8 -O renderer gis sudo -u postgres createdb -E UTF8 -O renderer gis
sudo -u postgres psql -d gis -c "CREATE EXTENSION postgis;" sudo -u postgres psql -d gis -c "CREATE EXTENSION postgis;"
sudo -u postgres psql -d gis -c "CREATE EXTENSION hstore;" sudo -u postgres psql -d gis -c "CREATE EXTENSION hstore;"
sudo -u postgres psql -d gis -c "CREATE EXTENSION postgis_sfcgal;"
sudo -u postgres psql -d gis -c "ALTER TABLE geometry_columns OWNER TO renderer;" sudo -u postgres psql -d gis -c "ALTER TABLE geometry_columns OWNER TO renderer;"
sudo -u postgres psql -d gis -c "ALTER TABLE spatial_ref_sys OWNER TO renderer;" sudo -u postgres psql -d gis -c "ALTER TABLE spatial_ref_sys OWNER TO renderer;"
setPostgresPassword setPostgresPassword
@@ -112,7 +123,7 @@ if [ "$1" == "import" ]; then
fi fi
# Import data # Import data
sudo -u renderer osm2pgsql -d gis --create --slim -G -S /data/style/OpenArdenneMap/osm2pgsql/OpenArdenneMap.style --extra-attributes \ sudo -u renderer osm2pgsql -d gis --create --slim -G --hstore \
/data/region.osm.pbf \ /data/region.osm.pbf \
${OSM2PGSQL_EXTRA_ARGS:-} \ ${OSM2PGSQL_EXTRA_ARGS:-} \
; ;
@@ -128,8 +139,12 @@ 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
sudo -u postgres psql -d gis -f /data/style/OpenArdenneMap/create_views.sql # Create cyclosm special views
sudo -u postgres psql -d gis -f /data/alter_view_owner.sql 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 # 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
@@ -216,7 +231,7 @@ if [ "$1" == "generate_tiles" ]; then
sudo -u renderer renderd -c /etc/renderd.conf sudo -u renderer renderd -c /etc/renderd.conf
cat /data/tiles/oam/tiles.list | render_list --map oam cat /data/tiles/cyclosm/tiles.list | render_list --map cyclosm
bash bash
fi fi

View File

@@ -16,16 +16,8 @@ max_y = 50.184
min_x = 5.735 min_x = 5.735
min_y = 49.452 min_y = 49.452
# BE ardenne coordinates
max_x = 6.40
max_y = 50.77
min_x = 4.13
min_y = 49.49
min_z = 9 min_z = 9
max_z = 18 max_z = 17
for z in range(min_z, max_z+1): for z in range(min_z, max_z+1):
x1_tile, y1_tile = deg2num(max_y, max_x, z) x1_tile, y1_tile = deg2num(max_y, max_x, z)