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