Spooky Case of the Wem Ghost
Reading Email with PHP and IMAP/POP3
Installing Proprietary nVidia Drivers on Ubuntu Linux
Garmin Edge 205 GPS Cycle Training Tool
Nasa's Space Shuttle Atlantis Transiting the Sun
Javascript Snippets

XML Parsing and Display of GPX data in Java

Mon 26 Jan 2009
3:24PM
compton
With all these GPX recordings of routes I'm collecting, I wanted to view and compare details of past routes in a more user-friendly manner than poring through reams of XML output. The Google Maps API would be great to incorporate somehow, and it is freely available for JavaScript use. However I decided to be awkward and write a desktop application in Java. I'm figuring that I'll find some way around the problem of getting graphical map imagery later.

So far I have a small Java Swing/AWT application which reads an XML file of GPS points from a recording of a cycle ride and displays the route in a JPanel within a JFrame:

There are three primary classes - quickChart which extends JFrame, chartPanel which extends JPanel, and gpxParser which extends org.xml.sax.helpers.DefaultHandler.

When the JFrame fires up, it sets the JPanel to visible. The JFrame also has a menu bar, with only two options at present: Open and Exit. Exit is obvious, and Open calls the gpxParser class to read a XML document via SAX. There are 600 to 4000 points in a file, and as it walks through the XML tree gpxParser reads each one into an ArrayList. This array list is then passed over to the JPanel, which iterates through them when rendering the route, and also when checking for 'mouseovers' (the point under the mouse is selected, as shown in orange on the route graphic).
1 2   

Quique

6:19 pm, Tuesday, 6 April 10

Hi, I want to use your gpx parser (probably modified) in a personal project. Can I do that? What license or conditions will apply?
Thanks.
 
 

compton

1:01 am, Thursday, 8 April 10

Hi Quique, please feel free to make use of the code here. I haven't done any work on it for a while, so I'm glad to hear it could be useful to someone.

No restrictions, but I'd be interested to hear how it goes!
 
 
1 2  Leave Comment