Difficulties with Map Thing and Unfolding (show GPX)

Hello all,

can someone please recommend a library to show many gpx tracks in a map and calc the middle position of one track?

Thank you all!

1 Like

As I was just using chatGPT I asked it. Here what it says…
Not sure if make any sense… : )

For displaying GPX tracks on a map and calculating the middle position of a track, you can use the following libraries with Processing:

  1. Unfolding Maps: Unfolding Maps is a library for interactive maps and geovisualizations in Processing. It supports various map providers (like OpenStreetMap, Google Maps, Microsoft Bing Maps) and allows you to easily display GPX tracks on the map. You can calculate the middle position of a track by averaging the latitudes and longitudes of all points in the track.
  2. GpxParser: GpxParser is a library specifically designed for parsing GPX files in Processing. While it doesn’t provide direct map visualization capabilities, you can combine it with other mapping libraries like Unfolding Maps or Google Maps for displaying GPX tracks and calculating the middle position.

Here’s how you can use these libraries for your tasks:

Using Unfolding Maps:

  • Displaying GPX Tracks: Unfolding Maps provides examples and documentation on how to load and display GPX tracks. You can use the LoadGPXTrackApp example as a reference.
  • Calculating Middle Position: Iterate through the GPX track’s waypoints, calculate the average latitude and longitude, and use this as the middle position.

Using GpxParser:

  • Parsing GPX Files: Use GpxParser to parse the GPX files and extract waypoint information. Here’s a basic example of how you can use GpxParser:

javaCopy code

import de.fhpotsdam.unfolding.geo.Location;
import de.fhpotsdam.unfolding.utils.GpxUtils;

void setup() {
  size(800, 600);
  String gpxData = loadStrings("your_track.gpx");
  Location[] locations = GpxUtils.getLocationsFromGpx(this, gpxData);
  // Use locations array to display on map or calculate middle position
}
  • Calculating Middle Position: Iterate through the Location array obtained from GpxParser, calculate the average latitude and longitude, and use this as the middle position.

Both libraries offer flexibility and ease of use for displaying GPX tracks and performing calculations with them in Processing. Choose the one that best fits your project requirements and preferences.

2 Likes

Thanks
Unfolding seems to be the best

Can someone show how to load and show an gpx file here?

1 Like

Hello @vkbr,

It helps to post the question you ask ChatGPT.

The Chat GPT response at that time was not helpful and I found other solutions.

loadStrings() returns an array!

Google Search:
Your search - GpxUtils.getLocationsFromGpx - did not match any documents.

There was more but I don’t care to revisit this.

ChatGPT can be useful at times but not always.

:)

2 Likes

Unfolding has a GPXReader with very basic functionality.

Example:

I was also able to write my own custom code from the GPXReader source example and custom parse the JSON files which gave me much more flexibility.

You can also load the GPX files with loadStrings() and parse these for the data you want and plot the tracks.

Reference:
unfolding/src/de/fhpotsdam/unfolding/data/GPXReader.java at master · tillnagel/unfolding · GitHub

:)

1 Like

Thank you!

my program for this is described here: What I am working on (my current projects)

(number 6)