Update 'README.md'
This commit is contained in:
parent
bd1f850bf4
commit
00bd29de73
153
README.md
153
README.md
@ -35,103 +35,74 @@ The two main folders are `inputs` and `outputs`:
|
||||
|
||||
- `outputs` is the default folder for generated output.
|
||||
|
||||
### Obtaining PBF files
|
||||
|
||||
You can download PBF files for multiple regions on Geofabrik: [https://download.geofabrik.de/index.html](https://download.geofabrik.de/index.html)
|
||||
|
||||
You should put the PBF file in subfolders, e.g. if you want to use `bretagne.pbf`, you should save it to:
|
||||
|
||||
```bash
|
||||
inputs/bretagne/bretagne.pbf
|
||||
```
|
||||
|
||||
Doing so will avoid having a messy `inputs` folder due to region-specific files generated by `coastline-fix.sh`.
|
||||
|
||||
### Generating maps
|
||||
|
||||
Only manual generation using `osmosis` is supported currently.
|
||||
#### Step 1 - Obtaining a PBF file.
|
||||
|
||||
#### Mapsforge file:
|
||||
You should create a PBF files containining the region you want:
|
||||
|
||||
- Download a complete region from Geofabrik: [http://download.geofabrik.de/](http://download.geofabrik.de/)
|
||||
- Chop a region previously downloaded:
|
||||
|
||||
*Using a bounding box:*
|
||||
|
||||
```bash
|
||||
# You do not need to specify a bounding-box if you did not use the coastline fix or
|
||||
# do not want it. You can use type=ram to speed-up the process for small maps.
|
||||
bin/osmosis --rb inputs/bretagne/bretagne_merge.pbf \
|
||||
--mapfile-writer file=outputs/morbihan.mapfg bbox=47.234,-3.598,47.997,-1.648 type=hd threads=2
|
||||
bin/osmosis --rb inputs/bretagne/bretagne-latest.osm.pbf \ # Specify your input PBF
|
||||
--bounding-box bottom=47.160000 left=-3.855000 top=48.330000 right=-1.915000 completeWays=yes \ # Specify the bounding bo
|
||||
--write-pbf inputs/bretagne/morbihan.pbf # Specify the output file
|
||||
```
|
||||
|
||||
*Using a polygon:*
|
||||
|
||||
```bash
|
||||
osmosis --rb inputs/bretagne/bretagne-latest.osm.pbf \ # Specify your input PBF
|
||||
--bounding-polygon file=inputs/bbox/morbihan.poly completeWays=yes \ # Specify your bounding polygon
|
||||
--write-pbf file=inputs/bretagne/morbihan.pbf # Specify your output file
|
||||
```
|
||||
|
||||
The `inputs/bbox` directory contains bounding-box (`.bbox`) and bounding polygon (`.poly`) for some regions. You can find polygon for a lots of region here: [http://polygons.openstreetmap.fr/index.py](http://polygons.openstreetmap.fr/index.py) (to find the id of the relation, search it on openstreetmap, e.g. [https://www.openstreetmap.org/relation/7447](https://www.openstreetmap.org/relation/7447)).
|
||||
|
||||
#### Step 1 Bis - Fixing coastlines and sea.
|
||||
|
||||
Skip this step if your region does not contain sea or big inner lakes, or if you do not want to generate mapsforge file.
|
||||
|
||||
We need to add sea information to the PBF file to generate a correct mapsforge map. To do so, a script `coastline-fix.sh` is provided. Run it simply:
|
||||
|
||||
```bash
|
||||
./coastline-fix.sh bretagne/morbihan.pbf
|
||||
```
|
||||
|
||||
To apply the fix, you need a polygon file (`morbihan.poly` — not another name), either in the same directory as the PBF or in the `inputs/bbox` directory (recommended).
|
||||
|
||||
This script will generate multiple intermediate files, but only two are importants:
|
||||
|
||||
- `inputs/bbox/morbihan.bbox`, actual bounding-box of the PBF file — This will overwrite the old bounding-box if there was one.
|
||||
- `inputs/bretagne/morbihan_merge.pbf`, merged file that you should use as input for mapsforge.
|
||||
|
||||
|
||||
#### Step 2 - Binary graph files
|
||||
|
||||
```bash
|
||||
# You can use either "insa2016" or "insa2018" writers, and you should change the map id to your need.
|
||||
bin/osmosis --rb inputs/bretagne/morbihan.pbf \
|
||||
--used-node \
|
||||
--tf reject-relations \
|
||||
--tf accept-ways highway=(cat inputs/highway-filter.cmd) natural=coastline \
|
||||
--osm2graph file=outputs/morbihan.mapgr writer=insa2018 map-id=0x235
|
||||
```
|
||||
|
||||
#### Step 3 - Mapsforge files
|
||||
|
||||
```bash
|
||||
# You must specify a bounding-box if you used the coastline fix.
|
||||
# You can use type=ram to speed-up the process for small maps.
|
||||
bin/osmosis --rb inputs/bretagne/morbihan_merge.pbf \
|
||||
--mapfile-writer file=outputs/morbihan.mapfg bbox=$(cat inputs/bbox/morbihan.bbox) type=hd threads=2
|
||||
|
||||
```
|
||||
|
||||
#### Binary graph files
|
||||
#### Extra informations:
|
||||
|
||||
```bash
|
||||
# You do not need to specify a bounding box if you do not need it. You can use either "insa2016" or
|
||||
# "insa2018" writers, and you should change the map id to your need.
|
||||
bin/osmosis --rb inputs/bretagne/bretagne-latest.osm.pbf \
|
||||
--used-node --bounding-box top=48.1749 left=-1.7709 right=-1.5014 bottom=48.0644 completeWays=yes \
|
||||
--tf reject-relations --tf accept-ways highway=(cat inputs/highway-filter.cmd) natural=coastline --lp \
|
||||
--osm2graph file=outputs/rennes.mapgr writer=insa2018 map-id=0x235
|
||||
```
|
||||
|
||||
#### Combining generations
|
||||
|
||||
You can combine both generation using the `--tee` option of `osmosis`:
|
||||
|
||||
```bash
|
||||
# The order is important! You do not want to use osmosis filters/bounding-box before mapfile-writer.
|
||||
bin/osmosis --rb inputs/bretagne/bretagne_merge.pbf --tee \
|
||||
--mapfile-writer file=outputs/morbihan.mapfg bbox=$(cat inputs/bbox/morbihan.bbox) type=hd threads=2 \
|
||||
--bounding-box $(cat inputs/bbox/morbihan.bbox | tr "," " " | xargs printf "bottom=%f left=%f top=%f right=%f") completeWays=yes
|
||||
--used-node --tf reject-relations --tf accept-ways highway=(cat inputs/highway-filter.cmd) natural=coastline
|
||||
--osm2graph file=ouputs/morbihan.mapgr writer=insa2018 map-id=0x400
|
||||
```
|
||||
|
||||
**Note**: You can add logging by specifying `--lp` between `osmosis` tasks.
|
||||
|
||||
|
||||
### Bounding box
|
||||
|
||||
Bounding box files should contain a single line with comma-separated (**without spaces**) values:
|
||||
|
||||
```bash
|
||||
minLat,minLon,maxLat,maxLon
|
||||
```
|
||||
|
||||
To use it with `osmosis`:
|
||||
|
||||
- for `mapfile-writer`, simply `cat` the file to set the `bbox` argument:
|
||||
|
||||
```bash
|
||||
bbox=$(cat inputs/bbox/morbihan.bbox)
|
||||
```
|
||||
|
||||
- for `osm2graph`, it is a bit more complicated:
|
||||
|
||||
```bash
|
||||
--bounding-box $(cat inputs/bbox/morbihan.bbox | tr "," " " | xargs printf "bottom=%f left=%f top=%f right=%f") completeWays=yes
|
||||
```
|
||||
|
||||
### Fixing coastline
|
||||
|
||||
When generating mapsforge file that contains sea, you will need to fix the PBF file prior to running osmosis.
|
||||
The fix is an adaptation from [https://github.com/mapsforge/mapsforge-creator](https://github.com/mapsforge/mapsforge-creator)
|
||||
— It basically does the same but does not download PBF or do the final osmosis run for you.
|
||||
|
||||
You will first need a PBF file and its associated polygon file, you can get these from [https://download.geofabrik.de/index.html](https://download.geofabrik.de/index.html). You need to put those file in a region folder, e.g. if you want to fix `bretagne`, you should have:
|
||||
|
||||
```bash
|
||||
# Do not rename these files!
|
||||
inputs/bretagne/bretagne-latest.osm.pbf
|
||||
inputs/bretagne/bretagne.poly
|
||||
```
|
||||
|
||||
You should also have run the `init.sh` script without the `--no-shapefile` option (you should see a folder named `land-polygons-split-4326` in the `inputs` folder).
|
||||
|
||||
Once you have the requested files, you can simply run (from the `inputs` folder):
|
||||
|
||||
```bash
|
||||
# If you are not already in the inputs folder
|
||||
cd inputs
|
||||
|
||||
# Change bretagne to whatever region...
|
||||
bash coastline-fix.sh bretagne
|
||||
```
|
||||
- Using a polygon to crop your region is preferred if you plan on applying the coastline fix.
|
||||
- I do not recommend using the merged file as input for `osm2graph` because coastlines are often very long OpenStreetMap ways, and the plugin will not cut them (typically, you could reach Spain when using the merged Morbihan file).
|
||||
- I do not recommend using `osmosis` bounding-box option with `osm2graph` and/or `mapfile-writer` unless your bounding-box is small and does not contain sea or coastline. It is always preferred to generate an intermediate PBF file containing only your region (using `--write-pbf`).
|
Loading…
Reference in New Issue
Block a user