-
Notifications
You must be signed in to change notification settings - Fork 1
How to obtain map data for application use
- Source data for this application come from Natural Earth Data project. You have to download "Admin 0 - Countries" map data.
- pnorman's ogr2osm script - https://github.com/pnorman/ogr2osm
- Osmconvert tool - https://wiki.openstreetmap.org/wiki/Osmconvert
- Osmosis tool - https://wiki.openstreetmap.org/wiki/Osmosis with installed Mapsforge plugin
-
Use ogr2osm to convert source shapefile to OSM format. I also supplied custom hooks containing conversion rules with
-t
option. It can be found in MapDataTools repository../ogr2osm.py ne_50m_admin_0_countries.shp -o ogr2osm_ocean_translated.osm -t admin_countries.py
-
We now have OSM file. The problem is, that the nodes are not "sorted" as Mapsforge plugin for Osmosis expects. The solution is to set "neutral" values to attributes where sorting is expected. We can use
xapi_attrs.py
script for this, which can be found in MapDataTools repository../xapi_attr.py ogr2osm_admin_translated.osm .
-
In this step we can cut the map area to contain only Europe using Osmconvert tool with
-b
option supplying Europe's bounding box:osmconvert --complete-ways --drop-broken-refs -b=-31.266,27.636,39.869,81.009 ogr2osm_admin_translated_attr.osm -o=europe.osm
-
Finally, we can convert OSM file to binary file requested by Mapsforge library using Mapsforge plugin for Osmosis:
~/apps/osmosis-latest/bin/osmosis --rx file=europe.osm --mw file=europe.map zoom-interval-conf=5,0,7
If we would omit attribute conversion using custom hooks, final
.map
file would be empty because Mapsforge plugin won't recognize tags in this file.