From ac78d62347d91f3a8951e5a5aff92f58bb378413 Mon Sep 17 00:00:00 2001 From: Ben Varick Date: Wed, 29 Jan 2025 10:15:15 -0600 Subject: [PATCH 01/11] added import .pbf to xml --- Makefile | 6 ++++++ docker/osm_edit/.gitignore | 9 +++++++++ docker/osm_edit/osm-data/.gitignore | 4 ++++ 3 files changed, 19 insertions(+) create mode 100644 docker/osm_edit/.gitignore create mode 100644 docker/osm_edit/osm-data/.gitignore diff --git a/Makefile b/Makefile index eb42337..7c3e269 100644 --- a/Makefile +++ b/Makefile @@ -43,3 +43,9 @@ brouter-data: cd ./docker/brouter/brouter-web; cp keys.template.js keys.js; cd ./docker/brouter/brouter-web; cp config.template.js config.js cd ./docker/brouter; docker compose build + +osm_edit_import_pbf: + cd ./docker/osm_edit/; wget https://download.geofabrik.de/north-america/us/wisconsin-latest.osm.pbf -O ./osm-data/wisconsin-latest.osm.pbf + cd ./docker/osm_edit/; rm -rf ./docker-osmosis; git clone https://github.com/bvarick/docker-osmosis.git + cd ./docker/osm_edit/; docker build -t osmosis ./docker-osmosis + cd ./docker/osm_edit/; docker run -v ./osm-data:/osm-data osmosis osmosis --read-pbf "/osm-data/wisconsin-latest.osm.pbf" --write-xml file="/osm-data/wisconsin-latest.osm" diff --git a/docker/osm_edit/.gitignore b/docker/osm_edit/.gitignore new file mode 100644 index 0000000..e95cb01 --- /dev/null +++ b/docker/osm_edit/.gitignore @@ -0,0 +1,9 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore + +# Except Dockerfile +!Dockerfile + +!osm-data/ diff --git a/docker/osm_edit/osm-data/.gitignore b/docker/osm_edit/osm-data/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/docker/osm_edit/osm-data/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore From 7ff54d52eac4da936fc44e657bd16944ab066cb4 Mon Sep 17 00:00:00 2001 From: Ben Varick Date: Wed, 29 Jan 2025 15:11:30 -0600 Subject: [PATCH 02/11] changed to osmium-tool --- Makefile | 8 +++++--- README.md | 9 +++++++++ docker/osm_edit/.gitignore | 9 --------- docker/osm_edit/osm-data/.gitignore | 4 ---- 4 files changed, 14 insertions(+), 16 deletions(-) delete mode 100644 docker/osm_edit/.gitignore delete mode 100644 docker/osm_edit/osm-data/.gitignore diff --git a/Makefile b/Makefile index 7c3e269..cc821ab 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,8 @@ brouter-data: osm_edit_import_pbf: cd ./docker/osm_edit/; wget https://download.geofabrik.de/north-america/us/wisconsin-latest.osm.pbf -O ./osm-data/wisconsin-latest.osm.pbf - cd ./docker/osm_edit/; rm -rf ./docker-osmosis; git clone https://github.com/bvarick/docker-osmosis.git - cd ./docker/osm_edit/; docker build -t osmosis ./docker-osmosis - cd ./docker/osm_edit/; docker run -v ./osm-data:/osm-data osmosis osmosis --read-pbf "/osm-data/wisconsin-latest.osm.pbf" --write-xml file="/osm-data/wisconsin-latest.osm" + cd ./docker/osm_edit/; rm ./osm-data/wisconsin-latest.osm; docker run -v ./osm-data:/osm-data ghcr.io/bvarick/osmosis:0.49.2 osmosis --read-pbf "/osm-data/wisconsin-latest.osm.pbf" --write-xml file="/osm-data/wisconsin-latest.osm" + +osm_edit_create_pbfs: + docker run -v ./data/osm/osm_edit:/osm_edit ghcr.io/bvarick/osmium-tool:2.21.0 osmium cat /osm_edit/map.osm -o /osm_edit/map.osm.pbf + docker run -v ./data/osm/osm_edit:/osm_edit ghcr.io/bvarick/osmium-tool:2.21.0 osmium cat /osm_edit/map_edited.osm -o /osm_edit/map_edited.osm.pbf \ No newline at end of file diff --git a/README.md b/README.md index ae43ea3..dd7e7bc 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,15 @@ calculates the walking routes using OSRM. - `make cycle-osrm` will run *cycling_route_analysis.Rmd* which calculates the biking routes using OSRM. - `make cycle-brouter` will run *cycling_route_analysis_brouter.Rmd* which calculates the biking routes using brouter. +## What-if analysis +This allows you to make changes to the street network (add a bike path, reduce a lane on an arterial st) and see how it affects the routes that brouter chooses. +This is a multi-step process: +1. Download a chunk of OpenStreetMap data: https://www.openstreetmap.org/export +2. Make edits to that file in [JOSM](https://josm.openstreetmap.de/) +3. Save the edited file as `map_edited.osm`, save both `map.osm` and `map_edited.osm` in `data/osm/osm_edit/` +4. `make osm_edit_create_pbfs` will generate two files `map.osm.pbf` and `map_edited.osm.pbf` in `docker/osm_edit/osm-data` +5. + ## Misc. - [Bike Level of Traffic Stress (LTS)](https://www.dvrpc.org/webmaps/bike-lts/analysis/) diff --git a/docker/osm_edit/.gitignore b/docker/osm_edit/.gitignore deleted file mode 100644 index e95cb01..0000000 --- a/docker/osm_edit/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -# Ignore everything in this directory -* -# Except this file -!.gitignore - -# Except Dockerfile -!Dockerfile - -!osm-data/ diff --git a/docker/osm_edit/osm-data/.gitignore b/docker/osm_edit/osm-data/.gitignore deleted file mode 100644 index 5e7d273..0000000 --- a/docker/osm_edit/osm-data/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything in this directory -* -# Except this file -!.gitignore From 910dcd1d1a5d26dc700e5211c11f551ffd55c1be Mon Sep 17 00:00:00 2001 From: Ben Varick Date: Thu, 30 Jan 2025 17:19:23 -0600 Subject: [PATCH 03/11] added make commands for editing osm --- Makefile | 11 ++++++++--- README.md | 8 +++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index cc821ab..47117e1 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,11 @@ osm_edit_import_pbf: cd ./docker/osm_edit/; wget https://download.geofabrik.de/north-america/us/wisconsin-latest.osm.pbf -O ./osm-data/wisconsin-latest.osm.pbf cd ./docker/osm_edit/; rm ./osm-data/wisconsin-latest.osm; docker run -v ./osm-data:/osm-data ghcr.io/bvarick/osmosis:0.49.2 osmosis --read-pbf "/osm-data/wisconsin-latest.osm.pbf" --write-xml file="/osm-data/wisconsin-latest.osm" -osm_edit_create_pbfs: - docker run -v ./data/osm/osm_edit:/osm_edit ghcr.io/bvarick/osmium-tool:2.21.0 osmium cat /osm_edit/map.osm -o /osm_edit/map.osm.pbf - docker run -v ./data/osm/osm_edit:/osm_edit ghcr.io/bvarick/osmium-tool:2.21.0 osmium cat /osm_edit/map_edited.osm -o /osm_edit/map_edited.osm.pbf \ No newline at end of file +osm_edit_refresh_base: + cd ./data/osm; wget https://download.geofabrik.de/north-america/us/wisconsin-latest.osm.pbf -O ./wisconsin-latest.osm.pbf + cd ./data/osm/osm_edit/srtm/; wget -i srtm_tiles.csv -P ./ + +osm_edit_generate_pbf: + docker run -v ./data/osm:/osm ghcr.io/bvarick/osmium-tool:2.21.0 osmium apply-changes /osm/wisconsin-latest.osm.pbf /osm/osm_edit/map_edited.osm -o /osm/osm_edit/wisconsin-latest_edited.osm.pbf --overwrite + +osm_edit_generate_brouter: diff --git a/README.md b/README.md index dd7e7bc..d9d85e6 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,9 @@ calculates the walking routes using OSRM. ## What-if analysis This allows you to make changes to the street network (add a bike path, reduce a lane on an arterial st) and see how it affects the routes that brouter chooses. This is a multi-step process: -1. Download a chunk of OpenStreetMap data: https://www.openstreetmap.org/export -2. Make edits to that file in [JOSM](https://josm.openstreetmap.de/) -3. Save the edited file as `map_edited.osm`, save both `map.osm` and `map_edited.osm` in `data/osm/osm_edit/` -4. `make osm_edit_create_pbfs` will generate two files `map.osm.pbf` and `map_edited.osm.pbf` in `docker/osm_edit/osm-data` -5. +1. Make edits to OpenStreetMap in [JOSM](https://josm.openstreetmap.de/) +2. Save the edited map as `map_edited.osm` in `data/osm/osm_edit/` (File -> Save As) +3. `make osm_edit_generate_pbf` will take those edits and apply them to the `wisconsin-latest.osm.pbf` and generate `wisconsin-latest_edited.osm.pbf` ## Misc. - [Bike Level of Traffic Stress (LTS)](https://www.dvrpc.org/webmaps/bike-lts/analysis/) From d852d5814e27cf447372dea2119bd3af53b804f2 Mon Sep 17 00:00:00 2001 From: Ben Varick Date: Fri, 31 Jan 2025 11:49:45 -0600 Subject: [PATCH 04/11] adjusted directories, edited README --- Makefile | 6 +-- README.md | 3 +- docker/brouter/.gitignore | 4 +- docker/brouter/osm_edit/.gitignore | 13 +++++ .../osm_edit/brouter_segments/.gitignore | 5 ++ docker/brouter/osm_edit/pbf_files/.gitignore | 5 ++ docker/brouter/osm_edit/process_pbf.sh | 49 +++++++++++++++++++ docker/brouter/osm_edit/srtm/.gitignore | 8 +++ docker/brouter/osm_edit/srtm/srtm_tiles.csv | 4 ++ 9 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 docker/brouter/osm_edit/.gitignore create mode 100644 docker/brouter/osm_edit/brouter_segments/.gitignore create mode 100644 docker/brouter/osm_edit/pbf_files/.gitignore create mode 100644 docker/brouter/osm_edit/process_pbf.sh create mode 100644 docker/brouter/osm_edit/srtm/.gitignore create mode 100644 docker/brouter/osm_edit/srtm/srtm_tiles.csv diff --git a/Makefile b/Makefile index 47117e1..47e427d 100644 --- a/Makefile +++ b/Makefile @@ -49,10 +49,10 @@ osm_edit_import_pbf: cd ./docker/osm_edit/; rm ./osm-data/wisconsin-latest.osm; docker run -v ./osm-data:/osm-data ghcr.io/bvarick/osmosis:0.49.2 osmosis --read-pbf "/osm-data/wisconsin-latest.osm.pbf" --write-xml file="/osm-data/wisconsin-latest.osm" osm_edit_refresh_base: - cd ./data/osm; wget https://download.geofabrik.de/north-america/us/wisconsin-latest.osm.pbf -O ./wisconsin-latest.osm.pbf - cd ./data/osm/osm_edit/srtm/; wget -i srtm_tiles.csv -P ./ + cd ./docker/brouter/osm_edit; wget https://download.geofabrik.de/north-america/us/wisconsin-latest.osm.pbf -O ./pbf_files/wisconsin-latest.osm.pbf + cd ./docker/brouter/osm_edit/srtm/; wget -i srtm_tiles.csv -P ./ osm_edit_generate_pbf: - docker run -v ./data/osm:/osm ghcr.io/bvarick/osmium-tool:2.21.0 osmium apply-changes /osm/wisconsin-latest.osm.pbf /osm/osm_edit/map_edited.osm -o /osm/osm_edit/wisconsin-latest_edited.osm.pbf --overwrite + cd ./docker/brouter/; docker run -v ./osm_edit:/osm_edit ghcr.io/bvarick/osmium-tool:2.21.0 osmium apply-changes /osm_edit/pbf_files/wisconsin-latest.osm.pbf /osm_edit/map_edited.osm -o /osm_edit/pbf_files/wisconsin-latest_edited.osm.pbf --overwrite osm_edit_generate_brouter: diff --git a/README.md b/README.md index d9d85e6..754d0ad 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,8 @@ calculates the walking routes using OSRM. This allows you to make changes to the street network (add a bike path, reduce a lane on an arterial st) and see how it affects the routes that brouter chooses. This is a multi-step process: 1. Make edits to OpenStreetMap in [JOSM](https://josm.openstreetmap.de/) -2. Save the edited map as `map_edited.osm` in `data/osm/osm_edit/` (File -> Save As) +2. Save the edited map as `map_edited.osm` in `docker/brouter/osm_edit/` (File -> Save As) +3. `make osm_edit_refresh_base` will download a fresh copy of `wisconsin-latest.osm.pbf` and the srtm tiles for Wisconsin. You don't need to run this frequently. 3. `make osm_edit_generate_pbf` will take those edits and apply them to the `wisconsin-latest.osm.pbf` and generate `wisconsin-latest_edited.osm.pbf` ## Misc. diff --git a/docker/brouter/.gitignore b/docker/brouter/.gitignore index 98f415b..97f24f0 100644 --- a/docker/brouter/.gitignore +++ b/docker/brouter/.gitignore @@ -9,5 +9,5 @@ # Except docker-compose.yml !docker-compose.yml -# Except safety profiles -!safety.brf +# Except osm_edit +!osm_edit/ \ No newline at end of file diff --git a/docker/brouter/osm_edit/.gitignore b/docker/brouter/osm_edit/.gitignore new file mode 100644 index 0000000..1851dfa --- /dev/null +++ b/docker/brouter/osm_edit/.gitignore @@ -0,0 +1,13 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore + +# Except osm_edit configuration files +!process_pbf.sh +!srtm/srtm_tiles.csv + +# Except osm_edit directories +!brouter_segments/ +!pbf_files/ +!srtm/ diff --git a/docker/brouter/osm_edit/brouter_segments/.gitignore b/docker/brouter/osm_edit/brouter_segments/.gitignore new file mode 100644 index 0000000..64f5877 --- /dev/null +++ b/docker/brouter/osm_edit/brouter_segments/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything in this directory +* + +# Except this file +!.gitignore diff --git a/docker/brouter/osm_edit/pbf_files/.gitignore b/docker/brouter/osm_edit/pbf_files/.gitignore new file mode 100644 index 0000000..64f5877 --- /dev/null +++ b/docker/brouter/osm_edit/pbf_files/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything in this directory +* + +# Except this file +!.gitignore diff --git a/docker/brouter/osm_edit/process_pbf.sh b/docker/brouter/osm_edit/process_pbf.sh new file mode 100644 index 0000000..8a857a5 --- /dev/null +++ b/docker/brouter/osm_edit/process_pbf.sh @@ -0,0 +1,49 @@ +#!/bin/bash +set -e + +cd /osm_edit + +touch lastmaprun.date + +JAVA='java -Xmx2600m -Xms2600m -Xmn32m' + +BROUTER_PROFILES="/profiles2" + +BROUTER_JAR="/brouter.jar" + +PLANET_FILE="/osm_edit/wisconsin-latest_edited.osm.pbf" + +SRTM_PATH="/osm_edit/srtm" + +rm -rf tmp +mkdir tmp +cd tmp +mkdir nodetiles +${JAVA} -cp ${BROUTER_JAR} -DavoidMapPolling=true btools.mapcreator.OsmCutter ${BROUTER_PROFILES}/lookups.dat nodetiles ways.dat relations.dat restrictions.dat ${BROUTER_PROFILES}/all.brf ${PLANET_FILE} + +mkdir ftiles +${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.NodeFilter nodetiles ways.dat ftiles + +${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.RelationMerger ways.dat ways2.dat relations.dat ${BROUTER_PROFILES}/lookups.dat ${BROUTER_PROFILES}/trekking.brf ${BROUTER_PROFILES}/softaccess.brf + +mkdir waytiles +${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.WayCutter ftiles ways2.dat waytiles + +mkdir waytiles55 +${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.WayCutter5 ftiles waytiles waytiles55 bordernids.dat + +mkdir nodes55 +${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.NodeCutter ftiles nodes55 + +mkdir unodes55 +${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.PosUnifier nodes55 unodes55 bordernids.dat bordernodes.dat ${SRTM_PATH} + +mkdir segments +${JAVA} -cp ${BROUTER_JAR} -DuseDenseMaps=true btools.mapcreator.WayLinker unodes55 waytiles55 bordernodes.dat restrictions.dat ${BROUTER_PROFILES}/lookups.dat ${BROUTER_PROFILES}/all.brf segments rd5 + +#cd .. +#rm -rf segments +#mv tmp/segments segments +#mv /osm_edit/segments4 /osm_edit/segments4_lastrun +#mv segments /osm_edit/segments4 +#rm -rf tmp diff --git a/docker/brouter/osm_edit/srtm/.gitignore b/docker/brouter/osm_edit/srtm/.gitignore new file mode 100644 index 0000000..c8b8738 --- /dev/null +++ b/docker/brouter/osm_edit/srtm/.gitignore @@ -0,0 +1,8 @@ +# Ignore everything in this directory +* + +# Except this file +!.gitignore + +# Except srtm_tiles.csv +!srtm_tiles.csv diff --git a/docker/brouter/osm_edit/srtm/srtm_tiles.csv b/docker/brouter/osm_edit/srtm/srtm_tiles.csv new file mode 100644 index 0000000..29c621e --- /dev/null +++ b/docker/brouter/osm_edit/srtm/srtm_tiles.csv @@ -0,0 +1,4 @@ +https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/ASCII/srtm_18_03.zip +https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/ASCII/srtm_18_04.zip +https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/ASCII/srtm_19_03.zip +https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/ASCII/srtm_19_04.zip From 47a4e865d6d1f74c4641581e7f5cae1245fbb838 Mon Sep 17 00:00:00 2001 From: Ben Varick Date: Fri, 31 Jan 2025 12:05:33 -0600 Subject: [PATCH 05/11] attempt at generating Brouter segment files --- Makefile | 2 ++ README.md | 5 +++-- docker/brouter/osm_edit/brouter_segments/.gitignore | 5 ----- docker/brouter/osm_edit/process_pbf.sh | 12 +++++------- 4 files changed, 10 insertions(+), 14 deletions(-) delete mode 100644 docker/brouter/osm_edit/brouter_segments/.gitignore mode change 100644 => 100755 docker/brouter/osm_edit/process_pbf.sh diff --git a/Makefile b/Makefile index 47e427d..7eb92c3 100644 --- a/Makefile +++ b/Makefile @@ -56,3 +56,5 @@ osm_edit_generate_pbf: cd ./docker/brouter/; docker run -v ./osm_edit:/osm_edit ghcr.io/bvarick/osmium-tool:2.21.0 osmium apply-changes /osm_edit/pbf_files/wisconsin-latest.osm.pbf /osm_edit/map_edited.osm -o /osm_edit/pbf_files/wisconsin-latest_edited.osm.pbf --overwrite osm_edit_generate_brouter: + docker run --rm -v ./docker/brouter/osm_edit:/osm_edit brouter /osm_edit/process_pbf.sh + diff --git a/README.md b/README.md index 754d0ad..bd14945 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,9 @@ This allows you to make changes to the street network (add a bike path, reduce a This is a multi-step process: 1. Make edits to OpenStreetMap in [JOSM](https://josm.openstreetmap.de/) 2. Save the edited map as `map_edited.osm` in `docker/brouter/osm_edit/` (File -> Save As) -3. `make osm_edit_refresh_base` will download a fresh copy of `wisconsin-latest.osm.pbf` and the srtm tiles for Wisconsin. You don't need to run this frequently. -3. `make osm_edit_generate_pbf` will take those edits and apply them to the `wisconsin-latest.osm.pbf` and generate `wisconsin-latest_edited.osm.pbf` +3. `make osm_edit_refresh_base` will download a fresh copy of `wisconsin-latest.osm.pbf` and the elevation tiles for Wisconsin. You don't need to run this frequently. +4. `make osm_edit_generate_pbf` will take those edits and apply them to the `wisconsin-latest.osm.pbf` and generate `wisconsin-latest_edited.osm.pbf` +5. `make osm_edit_generate_brouter` will generate new brouter segment files from the edited pbf file. ## Misc. - [Bike Level of Traffic Stress (LTS)](https://www.dvrpc.org/webmaps/bike-lts/analysis/) diff --git a/docker/brouter/osm_edit/brouter_segments/.gitignore b/docker/brouter/osm_edit/brouter_segments/.gitignore deleted file mode 100644 index 64f5877..0000000 --- a/docker/brouter/osm_edit/brouter_segments/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Ignore everything in this directory -* - -# Except this file -!.gitignore diff --git a/docker/brouter/osm_edit/process_pbf.sh b/docker/brouter/osm_edit/process_pbf.sh old mode 100644 new mode 100755 index 8a857a5..3070090 --- a/docker/brouter/osm_edit/process_pbf.sh +++ b/docker/brouter/osm_edit/process_pbf.sh @@ -11,7 +11,7 @@ BROUTER_PROFILES="/profiles2" BROUTER_JAR="/brouter.jar" -PLANET_FILE="/osm_edit/wisconsin-latest_edited.osm.pbf" +PLANET_FILE="/osm_edit/pbf_files/wisconsin-latest_edited.osm.pbf" SRTM_PATH="/osm_edit/srtm" @@ -41,9 +41,7 @@ ${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapc mkdir segments ${JAVA} -cp ${BROUTER_JAR} -DuseDenseMaps=true btools.mapcreator.WayLinker unodes55 waytiles55 bordernodes.dat restrictions.dat ${BROUTER_PROFILES}/lookups.dat ${BROUTER_PROFILES}/all.brf segments rd5 -#cd .. -#rm -rf segments -#mv tmp/segments segments -#mv /osm_edit/segments4 /osm_edit/segments4_lastrun -#mv segments /osm_edit/segments4 -#rm -rf tmp +rm -rf /osm_edit/segments4_lastrun +cp -R /osm_edit/segments4 /osm_edit/segments4_lastrun +mv /osm_edit/tmp/segments/ /osm_edit/segments4/ +rm -rf /osm_edit/tmp From 1baaca834ae198bb686b1b445a73fe6312b1d5fb Mon Sep 17 00:00:00 2001 From: Ben Varick Date: Fri, 31 Jan 2025 13:32:31 -0600 Subject: [PATCH 06/11] changed container called by osm_edit_generate_brouter, works now --- Makefile | 4 +- README.md | 2 +- docker/brouter/.gitignore | 3 +- docker/brouter/osm_edit/process_pbf.sh | 47 --------------------- docker/brouter/osm_edit/srtm/.gitignore | 8 ---- docker/brouter/osm_edit/srtm/srtm_tiles.csv | 4 -- 6 files changed, 5 insertions(+), 63 deletions(-) delete mode 100755 docker/brouter/osm_edit/process_pbf.sh delete mode 100644 docker/brouter/osm_edit/srtm/.gitignore delete mode 100644 docker/brouter/osm_edit/srtm/srtm_tiles.csv diff --git a/Makefile b/Makefile index 7eb92c3..3511063 100644 --- a/Makefile +++ b/Makefile @@ -50,11 +50,11 @@ osm_edit_import_pbf: osm_edit_refresh_base: cd ./docker/brouter/osm_edit; wget https://download.geofabrik.de/north-america/us/wisconsin-latest.osm.pbf -O ./pbf_files/wisconsin-latest.osm.pbf - cd ./docker/brouter/osm_edit/srtm/; wget -i srtm_tiles.csv -P ./ + cd ./docker/brouter/osm_edit/srtm3/; wget -i srtm_tiles.csv -P ./ osm_edit_generate_pbf: cd ./docker/brouter/; docker run -v ./osm_edit:/osm_edit ghcr.io/bvarick/osmium-tool:2.21.0 osmium apply-changes /osm_edit/pbf_files/wisconsin-latest.osm.pbf /osm_edit/map_edited.osm -o /osm_edit/pbf_files/wisconsin-latest_edited.osm.pbf --overwrite osm_edit_generate_brouter: - docker run --rm -v ./docker/brouter/osm_edit:/osm_edit brouter /osm_edit/process_pbf.sh + docker run --rm --user "$(id -u):$(id -g)" --env PLANET=wisconsin-latest_edited.osm.pbf --env JAVA_OPTS="-Xmx2048M -Xms2048M -Xmn256M" --env PLANET_UPDATE=0 --volume ./docker/brouter/osm_edit/brouter-tmp:/brouter-tmp --volume ./docker/brouter/osm_edit/pbf_files:/planet --volume ./docker/brouter/osm_edit/srtm3:/srtm3:ro --volume ./docker/brouter/osm_edit/segments:/segments ghcr.io/mjaschen/brouter-routingdata-builder diff --git a/README.md b/README.md index bd14945..d2113a8 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ calculates the walking routes using OSRM. This allows you to make changes to the street network (add a bike path, reduce a lane on an arterial st) and see how it affects the routes that brouter chooses. This is a multi-step process: 1. Make edits to OpenStreetMap in [JOSM](https://josm.openstreetmap.de/) -2. Save the edited map as `map_edited.osm` in `docker/brouter/osm_edit/` (File -> Save As) +2. Save the edited map as `docker/brouter/osm_edit/map_edited.osm` (File -> Save As) 3. `make osm_edit_refresh_base` will download a fresh copy of `wisconsin-latest.osm.pbf` and the elevation tiles for Wisconsin. You don't need to run this frequently. 4. `make osm_edit_generate_pbf` will take those edits and apply them to the `wisconsin-latest.osm.pbf` and generate `wisconsin-latest_edited.osm.pbf` 5. `make osm_edit_generate_brouter` will generate new brouter segment files from the edited pbf file. diff --git a/docker/brouter/.gitignore b/docker/brouter/.gitignore index 97f24f0..0dc77db 100644 --- a/docker/brouter/.gitignore +++ b/docker/brouter/.gitignore @@ -10,4 +10,5 @@ !docker-compose.yml # Except osm_edit -!osm_edit/ \ No newline at end of file +!osm_edit/ +!mapcreation/* \ No newline at end of file diff --git a/docker/brouter/osm_edit/process_pbf.sh b/docker/brouter/osm_edit/process_pbf.sh deleted file mode 100755 index 3070090..0000000 --- a/docker/brouter/osm_edit/process_pbf.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -set -e - -cd /osm_edit - -touch lastmaprun.date - -JAVA='java -Xmx2600m -Xms2600m -Xmn32m' - -BROUTER_PROFILES="/profiles2" - -BROUTER_JAR="/brouter.jar" - -PLANET_FILE="/osm_edit/pbf_files/wisconsin-latest_edited.osm.pbf" - -SRTM_PATH="/osm_edit/srtm" - -rm -rf tmp -mkdir tmp -cd tmp -mkdir nodetiles -${JAVA} -cp ${BROUTER_JAR} -DavoidMapPolling=true btools.mapcreator.OsmCutter ${BROUTER_PROFILES}/lookups.dat nodetiles ways.dat relations.dat restrictions.dat ${BROUTER_PROFILES}/all.brf ${PLANET_FILE} - -mkdir ftiles -${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.NodeFilter nodetiles ways.dat ftiles - -${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.RelationMerger ways.dat ways2.dat relations.dat ${BROUTER_PROFILES}/lookups.dat ${BROUTER_PROFILES}/trekking.brf ${BROUTER_PROFILES}/softaccess.brf - -mkdir waytiles -${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.WayCutter ftiles ways2.dat waytiles - -mkdir waytiles55 -${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.WayCutter5 ftiles waytiles waytiles55 bordernids.dat - -mkdir nodes55 -${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.NodeCutter ftiles nodes55 - -mkdir unodes55 -${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.PosUnifier nodes55 unodes55 bordernids.dat bordernodes.dat ${SRTM_PATH} - -mkdir segments -${JAVA} -cp ${BROUTER_JAR} -DuseDenseMaps=true btools.mapcreator.WayLinker unodes55 waytiles55 bordernodes.dat restrictions.dat ${BROUTER_PROFILES}/lookups.dat ${BROUTER_PROFILES}/all.brf segments rd5 - -rm -rf /osm_edit/segments4_lastrun -cp -R /osm_edit/segments4 /osm_edit/segments4_lastrun -mv /osm_edit/tmp/segments/ /osm_edit/segments4/ -rm -rf /osm_edit/tmp diff --git a/docker/brouter/osm_edit/srtm/.gitignore b/docker/brouter/osm_edit/srtm/.gitignore deleted file mode 100644 index c8b8738..0000000 --- a/docker/brouter/osm_edit/srtm/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Ignore everything in this directory -* - -# Except this file -!.gitignore - -# Except srtm_tiles.csv -!srtm_tiles.csv diff --git a/docker/brouter/osm_edit/srtm/srtm_tiles.csv b/docker/brouter/osm_edit/srtm/srtm_tiles.csv deleted file mode 100644 index 29c621e..0000000 --- a/docker/brouter/osm_edit/srtm/srtm_tiles.csv +++ /dev/null @@ -1,4 +0,0 @@ -https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/ASCII/srtm_18_03.zip -https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/ASCII/srtm_18_04.zip -https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/ASCII/srtm_19_03.zip -https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/ASCII/srtm_19_04.zip From 4ce0fadf28d7b0401b60f83388af5600acecfb93 Mon Sep 17 00:00:00 2001 From: Ben Varick Date: Fri, 31 Jan 2025 13:35:33 -0600 Subject: [PATCH 07/11] changed .gitignore to include new osm_edit dirs --- docker/brouter/osm_edit/.gitignore | 9 +++------ docker/brouter/osm_edit/brouter-tmp/.gitignore | 5 +++++ docker/brouter/osm_edit/segments/.gitignore | 5 +++++ docker/brouter/osm_edit/srtm3/.gitignore | 8 ++++++++ docker/brouter/osm_edit/srtm3/srtm_tiles.csv | 4 ++++ 5 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 docker/brouter/osm_edit/brouter-tmp/.gitignore create mode 100644 docker/brouter/osm_edit/segments/.gitignore create mode 100644 docker/brouter/osm_edit/srtm3/.gitignore create mode 100644 docker/brouter/osm_edit/srtm3/srtm_tiles.csv diff --git a/docker/brouter/osm_edit/.gitignore b/docker/brouter/osm_edit/.gitignore index 1851dfa..94b3941 100644 --- a/docker/brouter/osm_edit/.gitignore +++ b/docker/brouter/osm_edit/.gitignore @@ -3,11 +3,8 @@ # Except this file !.gitignore -# Except osm_edit configuration files -!process_pbf.sh -!srtm/srtm_tiles.csv - # Except osm_edit directories -!brouter_segments/ !pbf_files/ -!srtm/ +!srtm3/ +!brouter-tmp/ +!segments/ diff --git a/docker/brouter/osm_edit/brouter-tmp/.gitignore b/docker/brouter/osm_edit/brouter-tmp/.gitignore new file mode 100644 index 0000000..64f5877 --- /dev/null +++ b/docker/brouter/osm_edit/brouter-tmp/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything in this directory +* + +# Except this file +!.gitignore diff --git a/docker/brouter/osm_edit/segments/.gitignore b/docker/brouter/osm_edit/segments/.gitignore new file mode 100644 index 0000000..64f5877 --- /dev/null +++ b/docker/brouter/osm_edit/segments/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything in this directory +* + +# Except this file +!.gitignore diff --git a/docker/brouter/osm_edit/srtm3/.gitignore b/docker/brouter/osm_edit/srtm3/.gitignore new file mode 100644 index 0000000..c8b8738 --- /dev/null +++ b/docker/brouter/osm_edit/srtm3/.gitignore @@ -0,0 +1,8 @@ +# Ignore everything in this directory +* + +# Except this file +!.gitignore + +# Except srtm_tiles.csv +!srtm_tiles.csv diff --git a/docker/brouter/osm_edit/srtm3/srtm_tiles.csv b/docker/brouter/osm_edit/srtm3/srtm_tiles.csv new file mode 100644 index 0000000..29c621e --- /dev/null +++ b/docker/brouter/osm_edit/srtm3/srtm_tiles.csv @@ -0,0 +1,4 @@ +https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/ASCII/srtm_18_03.zip +https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/ASCII/srtm_18_04.zip +https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/ASCII/srtm_19_03.zip +https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/ASCII/srtm_19_04.zip From 00743f5d1192df1856994f193fc063d06c69532a Mon Sep 17 00:00:00 2001 From: Ben Varick Date: Fri, 31 Jan 2025 17:46:02 -0600 Subject: [PATCH 08/11] added make osm_edit_brouter_containers --- Makefile | 7 +++---- README.md | 6 +++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 3511063..41d2f2f 100644 --- a/Makefile +++ b/Makefile @@ -44,10 +44,6 @@ brouter-data: cd ./docker/brouter/brouter-web; cp config.template.js config.js cd ./docker/brouter; docker compose build -osm_edit_import_pbf: - cd ./docker/osm_edit/; wget https://download.geofabrik.de/north-america/us/wisconsin-latest.osm.pbf -O ./osm-data/wisconsin-latest.osm.pbf - cd ./docker/osm_edit/; rm ./osm-data/wisconsin-latest.osm; docker run -v ./osm-data:/osm-data ghcr.io/bvarick/osmosis:0.49.2 osmosis --read-pbf "/osm-data/wisconsin-latest.osm.pbf" --write-xml file="/osm-data/wisconsin-latest.osm" - osm_edit_refresh_base: cd ./docker/brouter/osm_edit; wget https://download.geofabrik.de/north-america/us/wisconsin-latest.osm.pbf -O ./pbf_files/wisconsin-latest.osm.pbf cd ./docker/brouter/osm_edit/srtm3/; wget -i srtm_tiles.csv -P ./ @@ -58,3 +54,6 @@ osm_edit_generate_pbf: osm_edit_generate_brouter: docker run --rm --user "$(id -u):$(id -g)" --env PLANET=wisconsin-latest_edited.osm.pbf --env JAVA_OPTS="-Xmx2048M -Xms2048M -Xmn256M" --env PLANET_UPDATE=0 --volume ./docker/brouter/osm_edit/brouter-tmp:/brouter-tmp --volume ./docker/brouter/osm_edit/pbf_files:/planet --volume ./docker/brouter/osm_edit/srtm3:/srtm3:ro --volume ./docker/brouter/osm_edit/segments:/segments ghcr.io/mjaschen/brouter-routingdata-builder +osm_edit_brouter_containers: + cd ./docker/brouter/osm_edit; docker compose up -d + diff --git a/README.md b/README.md index d2113a8..59b65bf 100644 --- a/README.md +++ b/README.md @@ -36,12 +36,16 @@ calculates the walking routes using OSRM. ## What-if analysis This allows you to make changes to the street network (add a bike path, reduce a lane on an arterial st) and see how it affects the routes that brouter chooses. + +This is currently not working, I'm trying to figure it out. + This is a multi-step process: 1. Make edits to OpenStreetMap in [JOSM](https://josm.openstreetmap.de/) -2. Save the edited map as `docker/brouter/osm_edit/map_edited.osm` (File -> Save As) +2. Save the edited map as `docker/brouter/osm_edit/map_edited.osm` (File -> Save As). Don't upload your hypothetical infrastructure to OpenStreetMap! 3. `make osm_edit_refresh_base` will download a fresh copy of `wisconsin-latest.osm.pbf` and the elevation tiles for Wisconsin. You don't need to run this frequently. 4. `make osm_edit_generate_pbf` will take those edits and apply them to the `wisconsin-latest.osm.pbf` and generate `wisconsin-latest_edited.osm.pbf` 5. `make osm_edit_generate_brouter` will generate new brouter segment files from the edited pbf file. +6. `make osm_edit_brouter_containers` starts the brouter backend and frontend using your newly created segment files with the edits you made. You can access the webui at http://127.0.0.1:8080 ## Misc. - [Bike Level of Traffic Stress (LTS)](https://www.dvrpc.org/webmaps/bike-lts/analysis/) From 4b45d240cae7b9fe07ee46f0b46f10c871464f47 Mon Sep 17 00:00:00 2001 From: Ben Varick Date: Sat, 1 Feb 2025 20:41:05 -0600 Subject: [PATCH 09/11] changed to OsmChange filetype --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 41d2f2f..c746f16 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ osm_edit_refresh_base: cd ./docker/brouter/osm_edit/srtm3/; wget -i srtm_tiles.csv -P ./ osm_edit_generate_pbf: - cd ./docker/brouter/; docker run -v ./osm_edit:/osm_edit ghcr.io/bvarick/osmium-tool:2.21.0 osmium apply-changes /osm_edit/pbf_files/wisconsin-latest.osm.pbf /osm_edit/map_edited.osm -o /osm_edit/pbf_files/wisconsin-latest_edited.osm.pbf --overwrite + cd ./docker/brouter/; docker run -v ./osm_edit:/osm_edit ghcr.io/bvarick/osmium-tool:2.21.0 osmium apply-changes /osm_edit/pbf_files/wisconsin-latest.osm.pbf /osm_edit/changes.osc -o /osm_edit/pbf_files/wisconsin-latest_edited.osm.pbf --overwrite osm_edit_generate_brouter: docker run --rm --user "$(id -u):$(id -g)" --env PLANET=wisconsin-latest_edited.osm.pbf --env JAVA_OPTS="-Xmx2048M -Xms2048M -Xmn256M" --env PLANET_UPDATE=0 --volume ./docker/brouter/osm_edit/brouter-tmp:/brouter-tmp --volume ./docker/brouter/osm_edit/pbf_files:/planet --volume ./docker/brouter/osm_edit/srtm3:/srtm3:ro --volume ./docker/brouter/osm_edit/segments:/segments ghcr.io/mjaschen/brouter-routingdata-builder From 21e55bc83704bdf16157cae3389e0a77494134b1 Mon Sep 17 00:00:00 2001 From: Ben Varick Date: Sat, 1 Feb 2025 20:46:23 -0600 Subject: [PATCH 10/11] changed readme to reflect OsmChange file --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 59b65bf..219d534 100644 --- a/README.md +++ b/README.md @@ -35,13 +35,11 @@ calculates the walking routes using OSRM. - `make cycle-brouter` will run *cycling_route_analysis_brouter.Rmd* which calculates the biking routes using brouter. ## What-if analysis -This allows you to make changes to the street network (add a bike path, reduce a lane on an arterial st) and see how it affects the routes that brouter chooses. - -This is currently not working, I'm trying to figure it out. +This allows you to make changes to the street network (add a bike path, reduce a lane on an arterial street) and see how it affects the routes that brouter chooses. This is a multi-step process: -1. Make edits to OpenStreetMap in [JOSM](https://josm.openstreetmap.de/) -2. Save the edited map as `docker/brouter/osm_edit/map_edited.osm` (File -> Save As). Don't upload your hypothetical infrastructure to OpenStreetMap! +1. Generate an OsmChange file for the changes that you want to analyze. Don't upload your hypothetical infrastructure to OpenStreetMap! +2. Save that file as `docker/brouter/osm_edit/changes.osc`. 3. `make osm_edit_refresh_base` will download a fresh copy of `wisconsin-latest.osm.pbf` and the elevation tiles for Wisconsin. You don't need to run this frequently. 4. `make osm_edit_generate_pbf` will take those edits and apply them to the `wisconsin-latest.osm.pbf` and generate `wisconsin-latest_edited.osm.pbf` 5. `make osm_edit_generate_brouter` will generate new brouter segment files from the edited pbf file. From ab7158cc7f3e6750e37c2a4943781cb76eff6dcc Mon Sep 17 00:00:00 2001 From: Ben Varick Date: Tue, 4 Feb 2025 09:01:04 -0600 Subject: [PATCH 11/11] added osm_edit docker-compose.yml --- docker/brouter/osm_edit/.gitignore | 2 ++ docker/brouter/osm_edit/docker-compose.yml | 26 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 docker/brouter/osm_edit/docker-compose.yml diff --git a/docker/brouter/osm_edit/.gitignore b/docker/brouter/osm_edit/.gitignore index 94b3941..899c425 100644 --- a/docker/brouter/osm_edit/.gitignore +++ b/docker/brouter/osm_edit/.gitignore @@ -8,3 +8,5 @@ !srtm3/ !brouter-tmp/ !segments/ + +!docker-compose.yml \ No newline at end of file diff --git a/docker/brouter/osm_edit/docker-compose.yml b/docker/brouter/osm_edit/docker-compose.yml new file mode 100644 index 0000000..e37f5cc --- /dev/null +++ b/docker/brouter/osm_edit/docker-compose.yml @@ -0,0 +1,26 @@ +--- +services: + brouter: + container_name: brouter + ports: + - 17777:17777 + volumes: + - ./segments:/segments4 + image: brouter + build: + context: ../brouter + dockerfile: Dockerfile +--- +services: + brouter-web: + container_name: brouter-web + ports: + - 127.0.0.1:8080:80 + volumes: + - ../brouter-web/config.js:/usr/share/nginx/html/config.js + - ../brouter-web/keys.js:/usr/share/nginx/html/keys.js + - ../brouter-web/profiles:/usr/share/nginx/html/profiles + image: brouter-web + build: + context: ../brouter-web + dockerfile: Dockerfile