Reading GPS Data File

edited October 2014 in Library Questions

Hello,

I am trying to find a library or another way of reading a .gpx file or a .tcx file to plot a GPS route in a processing sketch as a line (i.e without the map background). I can't seem to find a library for either file types so if anyone knows of any then that would be great, or if this is not possible then please let me know! Thanks!

Tagged:

Answers

  • If you type GPX in the search box of the main site, you will get lot of hits...

    https://www.google.com/search?as_sitesearch=processing.org&as_q=gpx

  • So I have started experimenting with tomc.gpx and I hope to be able to plot the elevation of a .GPX file. And also the route as it appears on a map.

    I'm just experimenting at the moment but I think this might be the elevation as it looks similar but I could be wrong:

    import tomc.gpx.*;
    
    // outside setup()
    GPX gpx;
    
    
    
    // inside setup()
    
    void setup() {
      background(255, 255, 255);
      gpx = new GPX(this);
      size(800, 800);
    
      // when you want to load data
      gpx.parse("stage1.gpx"); // or a URL
    }
    void draw() {
      // inside draw()
    
      for (int i = 0; i < gpx.getTrackCount(); i++) {
        GPXTrack trk = gpx.getTrack(i);
    
    
        // do something with trk.name
    
    
        for (int j = 0; j < trk.size(); j++) {
    
    
          GPXTrackSeg trkseg = trk.getTrackSeg(j);
    
    
          for (int k = 0; k < trkseg.size(); k++) {
    
            GPXPoint pt = trkseg.getPoint(k);
    
    
            // do something with pt.lat or pt.lon
    
    noStroke();
    fill(0,0,0);
    
    
            ellipse(width-j*2, height-k*2, 1, 1);
    
    
          }
        }
    
      }
    
        for (int i = 0; i < gpx.getWayPointCount(); i++) {
          GPXWayPoint wpt = gpx.getWayPoint(i);
          // do something with wpt.lat or wpt.lon or wpt.name or wpt.type
        }
      }
    
Sign In or Register to comment.