-
Notifications
You must be signed in to change notification settings - Fork 10
/
README
executable file
·61 lines (40 loc) · 1.91 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
About
-----
Read and manipulate data in the GPX format. (see http://www.topografix.com/GPX/ for more).
Uses Processing's XML parser so only basic information (lat/lon/ele/time) is parsed.
A GPX file is an xml file with a collection of GPX Tracks inside. Each GPX Track has a name, and is a collection of GPX Track Segments, and each segment is a collection of GPX Points. Each point has a latitude and longitude as well as an elevation and timestamp. No other information is parsed by this library. A GPX file can also contain waypoints, with lat/lon position and name and type.
This library has only been tested with a few different files, and I expect it will need updating to properly handle things like waypoints with elevation, and so on. If you find a file that breaks it, please send it to me.
Usage
-----
import tomc.gpx.*;
// outside setup()
GPX gpx;
// inside setup()
gpx = new GPX(this);
// when you want to load data
gpx.parse("test.gpx"); // or a URL
// 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
}
}
}
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
}
Installation
------------
Place this folder (gpx) into your Processing/libraries folder, then restart Processing.
Then choose GPX from the library import options in the Processing application menu.
If it's working, "import tomc.gpx" should be added to the top of your application file.
Bugs / Requests
---------------
Please file an issue at https://github.com/RandomEtc/processing-gpx/issues
Enjoy! -- TomC.