Overlay GPX tracks as Vector Map

Mister Smith shared this question 3 months ago
Answered

I want to display 250 GPX tracks covering a large portion of California as a VECTOR map layer, not individual GPX files. Actively displaying that many tracks at once slows the app down significantly. In the Garmin ecosystem, there's an app that can convert all 250 GPX tracks into a Garmin .IMG map file (IMGfromGPX). The resulting VECTOR map for Garmin contains all the data, and only takes up 3 MB of space.


I copied the .IMG file to /data/menion.android.locus.pro/Locus/mapsVector. The map displays fine, with all the GPX tracks showing as green lines. The problem I'm facing is that the .IMG format does not allow any customization for Locus. I use four colors for the tracks to indicate the type of road or trail each track represents.


I'm looking for a way to build this map in a native .map or other format that is truly a vector map for Locus. I've been struggling with Mapsforge and QGIS for several days and I just can't seem to find a way to do this.


I don't want to calibrate a PNG/PDF file or use any other tile-based raster option. I want a true vector map like the .IMG file that allows me to color-code the tracks and overlay it on my active map.


Do you have any ideas or suggestions that can help?

Replies (4)

photo
1

Hi,

we are sorry but this request is way beyond the scope of the app support.

photo
1

You don't have any advice on how to create a vector map for Locus that is made up of lines on a transparent background?

photo
1

Hi,

to be honest, we don't create maps from GPX traces, but directly from OpenStreetMap. However, I can briefly describe the steps you need to perform to create a vector map for Locus. I would like to point out, that there is no software in which you can do the conversion easily. You will have to edit a few XML files and work with the command line... maybe simple scripting (depending on your data). Is this ok for you?


Maybe it would be better to use QGIS and create a raster map and then use that as an overlay in Locus. But the map file will be larger - it depends on the area covered by your trails...

photo
1

Thank you for responding. I would be interested in a better understanding of the Vector map creation for Locus. I'm not adverse to editing a little XML, but I'm surprised there's nothing like QGIS for making Vector maps. I have been working with MapBox, but I still have not found a friendly solution for creating a vector map for Locus. Raster maps for the area size and zoom levels I need become huge. As I mentioned in my post, the Garmin IMG map only uses 3 MB to display all that data and I can zoom all the way up to the highest level.

photo
1

However, I see a way you'll get what you want:


- GPSbabel can convert GPS to OSM (OPenStreetMap) format (never used it - conclusion from quick web search)


- osmosis can turn an OSM file into a .map file (vector) that Locus can use.


Have you tried?

photo
1

I don't know how to get GPSbabel to load 250 GPX files while retaining their color coding when converting to OSM.

I'm unable to find a walk through video or instructions on the process of OSM conversion in Osmosis.

Have you done this with favorable results?

photo
1

I only did a quick search for the gpx conversion as I wrote. You need to try.

Firestar is another name I found today.


Producing a .map file is easy, once you have the osm file. Look here: https://github.com/mapsforge/mapsforge/blob/master/docs/Getting-Started-Map-Writer.md


This is the plugin for osmosis you need. Forget all the filters and options, as you want to have all in the map that you feed.

photo
1

Maybe it would be easier to convert GXP files to raster mbtiles format using QGIS:

- import GPX files (set preferred style - color, width, etc)

- hide background map (if any)

- export to MBTILES format https://www.youtube.com/watch?v=e7PcmuIRTA0

- try different range of zoom levels to get ideal combination of level of detail and map size

- copy map to the phone and select it for import

- display mbtiles map as overlay https://docs.locusmap.app/doku.php?id=manual:user_guide:maps_tools:overlays

photo
1

You're correct, it is easier, and I have done it...but... it uses GB of space, and I'm looking to do it in MB of space via a vector map.

photo
1

Yes, the map can be big - this is why I asked what the coverage area is. You can try to limit the zoom levels (set a lower max zoom level).
If you want to really generate the vector map in "locus" mapsforge format:
1. Convert GPX to OSM format (you can use probably ogr2ogr - https://gdal.org/en/latest/programs/ogr2ogr.html, JOSM SW https://josm.openstreetmap.de or probably Babel as Michael described)
2. Set proper OSM tags (key/value) - you can use again JOSM for this https://wiki.openstreetmap.org/wiki/Tags
3. Define Mapsforge tag-mapping.xml file, generate map and create map theme - all of these steps are well described at https://github.com/mapsforge/mapsforge/blob/master/docs/MapCreation.md
Regards
Petr

photo
1

Considering this an interesting challenge I played a little bit:

1) Maperitive can directly load gpx tracks and display them, as well as create tiles. With a full map background for 5kmx2km, zoom levels 4 to 16, it created 2.7MB in 98 tiles; with only the track and transparent background, it created 90KB in 45 files., a factor of 30 in size. Hence, a tile based approach might be feasible.

2) With a little assistance from chatgpt I quickly crafted an awk script to turn GPX to OSM (ogr2ogr also needs plugins from GPSbabel, BTW), selected the relevant elements from the default Maperitive rules (kind of theme) file and fed the generated OSM to Maperitive

Why try #2 when #1 is working? Curiosity - and colors: the built in gps track feature of Maperitive cannot deal with colors. Maybe there would be a way around by filtering.

But also for #1 you'd need to deal with different colors, which means adding a color code into the GPX2OSM script and creating copies of the Maperitive rule for each color code (but there should not be dozens of trail types - are there?).

Just my 2c

photo
1

Something to play with further ...

photo
photo
1

Ask in the Openandromaps forum. Maybe someone there can help you.

photo
1

Mr.Smith: what is the purpose of having those 250 GPXs displayed?

Always, going forward?

Producing screenshots from time to time?

Anything else?

photo
1

I'm traveling throughout the Sierra Nevada mountains on 4X4, biking, and hiking trails. There's little or no cellular/data coverage in these areas. The tracks represent my previous journeys and are classified (colored) by road/trail type. I like being able to overlay that info on my map quickly via a layer so I can adjust my journey as necessary. Viewing all the tracks as an overlay is handy for planning. If I activate all the GPX tracks at once, Locus performance will degrade and be very slow. I had the same problem on my Garmin GPS which is terrible at managing tracks. The solution for Garmin is outlined in my post above. It works perfectly. What I'm getting very frustrated with is that Locus is better than every GPS program on the planet, but making a Vector map like what I'm asking seems impossible. I don't understand why mapsforge maps are so mystical and difficult to make.

photo
photo
1

Well, it's not necessarily the purpose of a smartphone app. - My view.

However, I see a way you'll get what you want:

- GPSbabel can convert GPS to OSM (OPenStreetMap) format (never used it - conclusion from quick web search)

- osmosis can turn an OSM file into a .map file (vector) that Locus can handle

Just my 2c.

Good luck and cheers

Michael

PS: as memory is a nobrainer today, I would not rule out a raster tile based approach, BTW.

The tooling differs from step 2 on, however:

- use Maperitive to produce - from an OSM file - a folder structure with the raster tiles with (only) the tracks (one tree per zoom level; a clip level will omit empty tiles)

- use MOBAC to turn such a folder "forest" into an sqliteDB for Locus.

Leave a Comment
 
Attach a file