Locus Map - forum

Support => Troubles & Questions => Topic started by: moudi on April 13, 2025, 21:01:46

Title: Create .map from .shp - empty map?
Post by: moudi on April 13, 2025, 21:01:46
Hi all

I tried to create a custom map from a SHP file following the article here:
https://docs.locusmap.app/doku.php?id=manual:advanced:map_tools:conversion#how_to_convert_shp_file_for_locus (https://docs.locusmap.app/doku.php?id=manual:advanced:map_tools:conversion#how_to_convert_shp_file_for_locus)
But I only get a blank map in Locus (no errors in the whole conversion).

Could somebody please have a look at it? I spent already quite a while digging in it, but have no clue why it isn't working.  :'(

The article seems a bit outdated, so I had to adopt it a bit.
First of all, the download link for the SHP file is not working anymore, so I downloaded one for switzerland:
https://geodata.ucdavis.edu/gadm/gadm4.1/shp/gadm41_CHE_shp.zip (https://geodata.ucdavis.edu/gadm/gadm4.1/shp/gadm41_CHE_shp.zip)
The conversion to .osm in Merkaartor was working and the generated .osm file seems to be ok to me.
In the .osm file, I moved the boundary on top as the first element.
The tags in the file are a bit different as well. All elements have: <tag k="_ENGTYPE_1_" v="Canton"/>

The versions for Osmosis and the Mapwriter plugin are both outdated in the article.
I tried it both with the mentioned ones (osmosis 0.40.1 / map-writer 0.5.0) and the newest versions (osmosis 0.49.2 / map-writer 0.25.0).
Both run without errors and generated a .map file with identical size (very small with 136KB). See the attached console log.
In my opinien, I expect the problem to be here in the .map file generation. 136KB seems to me very small (empty?).
Also, if I set the osm-tag to enabled="false", the generated .map file has the same size.

I adopted the theme according to the different tag.

I copied both files to the mentioned folders in Locus and Locus was able to open/load the map without error, but showed an empty screen.
To be sure that I'm in the correct region, I checked with the "center map" function in Locus.

I've attached the following files:
- cantons.osm
- tag-mapping-shp.xml
- osmosis.log
- cantons-theme.xml
- cantons.osm.map

Does anybody have an idea what's going wrong here?
Thank you very much
Dominik
Title: Re: Create .map from .shp - empty map?
Post by: voldapet on April 17, 2025, 09:22:46
Hi Dominik,

conversion of SHP to Mapsforge vector map is overcomplicated and the article is really old...maybe is better to convert data to raster mbtiles (but it depends on area of coverage).
Anyway, before any exploration of the issues - could I ask you what your use case is? Or what data you want to display?

I would also like to note that we are developing another application called Locus GIS which is aimed at more professional use cases and can directly import SHP https://play.google.com/store/apps/details?id=menion.android.locus.gis

Thanks, Petr
Title: Re: Create .map from .shp - empty map?
Post by: moudi on April 17, 2025, 19:17:01
Hi Petr, thanks for your reply.

I have a dataset with 130'000 pathways (simple lines) with special categorization (e.g. easy/moderate/hard) which I would like to use as an overlay map while navigating. (the dataset is not available for the public, so I can't share it here)

The coverage is quite big with roughly 119'000 km^2. I expect that a raster based map would result in a way too large file. The SHP file itself is 88MB.

Locus GIS looks nice, but I think it's not the right tool for my use case.

My first approach was to create a KML file, but Locus was not able to handle it and crashed. I assume the file was just too big.
If SHP to Mapsforge is that troublesome, are you aware of a better choice? QGIS supports the export to many other vector formats, so I'm not bound to SHP.

Thanks for your help
Dominik
Title: Re: Create .map from .shp - empty map?
Post by: moudi on June 06, 2025, 22:54:52
Hi Petr and all

I got it finally working!  8)
For those of you who experience the same troubles as I did, here is the solution.

The issue is that osmosis is not able to handle the .osm file created by Merkaartor. I don't know if Merkaartor creates an invalid file or if osmosis is handling it the wrong way.
However, in the .osm file, the <way> element is before its referenced <node> elements - and that's not working. If the nodes are before its way, osmosis handles it correctly.
Since i have more than 100'000 ways, it was not possible to change this manually. I did the following:
1. Install JOSM and the extensions opendata and pbf https://josm.openstreetmap.de/
2. Import the shape file
3. Export as *.osm.pbf
4. Run osmosis with this parameters:
bin\osmosis.bat --read-pbf mymap.osm.pbf --mapfile-writer file=mymap.osm.map tag-conf-file=tag-mapping.xml bbox=minLat,minLon,maxLat,maxLon
- The bbox parameter is required as the pbf file has no bounding box specified. I took the values from the .osm file created by Merkaartor.

- You have to use the .pbf format because the .osm exported from JOSM can also not be handled by osmosis. The .osm export from JOSM is still helpful to get the correct tag names.

- osmosis seems to create a v3 map. I created a v1 rendertheme to make it running in Locus.

That's it, have fun
Dominik