Hi Alejandro,
As Ludwig mentions there is no direct way to convert shape file to mapsforge file, but it can be done in few simple steps, I've managed to do this with both Merkaartor and JOSM.
If you use Merkaartor:
- Import .shp file into Merkaartor and save it as .osm file. Edit .osm file with text editor, go to end of the file and remove bounding box tag that Merkaartor adds (it will cause osmosis to fail at next step)
- Run osmosis with mapwriter plugin:
osmosis --rx file="path_to_osm_converted_from_shp" --sort --mw file="path_to_generated_map_file" bbox=xxx,xxx,xxx,xx map-start-zoom=16 tag-conf-file=path_to_your_custom_tag-mapping.xml
At this point you should remember to specify correct bounding box. Also take notice of last tag-conf-file parameter.
The tricky part is to understand how mapwriter works. That was the part that I got stuck (thanks guys for feedback!). Take a look at:
In short - this is the file that (as far as I know) defines what tags from .osm file will be included in its binary .map representation .You can download this file, edit it and place your own tags. If you do that don't forget to define custom render theme for the map file that will tell mapsforge library how to display/draw objects from your added tags. You can read more about rendertheme at
https://code.google.com/p/mapsforge/wiki/RenderThemeAPI
If you use JOSM:
- Import .shp file into JOSM and save it as .osm file to the disk. Bad news is that JOSM is not fully compatible with openstreetmaps API v0.6, so when trying to generate .map file osmosis will throw errors. My solution for this is to manually parse .osm file and add required missing tags (version, and timestamp). For this you can use SED – with this tool even big .osm files won’t be a problem.
- Run osmosis with mapwriter plugin:
osmosis --rx file="path_to_osm_converted_from_shp" --sort --mw file="path_to_generated_map_file" bbox=xxx,xxx,xxx,xx map-start-zoom=16 tag-conf-file=path_to_your_custom_tag-mapping.xml
As above, don’t forget about current bbox parameter, tag-mapping and custom render theme.
That should generally be it, hope this helps!
Cheers