Are there any Java libraries for parsing GPX files? I need to parse many GPX files into our own data structure (our own database).
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Very nice. However, I needed to do:
BTW I used http://www.topografix.com/GPX/1/1.
-Ken
This question is too old and so do the answers. Thanks to the open source world, we have now jgpx, on google code (forked multiple times on github) and GPXParser, on sourceforge.net. There are also a lot of results for a search on Github.
I'm not sure which one is more mature (one of them is marked as Alpha) but you can try them and let us know here.
Edit
Have a look at processing-gpx, it seems promising.
Here is a quick example
I'm not aware of any library specialized in parsing GPX files, but since GPX is XML you can use your preferred Java XML parser for reading it.
The GPX format is documented here (includes XSD schema): http://www.topografix.com/gpx.asp
After some research, there is really no Java API/Lib for parsing GPX files, but I found a nice approach for parsing it using JAXB
Using this Tutorial: http://www.oracle.com/technetwork/articles/javase/index-140168.html
Steps:
1. Download GPX 1.0 and 1.1 Schema file (xsd)
2. Generate Java File from it using Eclipse Plugin
3. Init JAXBContext with package name of generated GPX java files (mine was "topografix.gpx.schema10")
4. Parse GPX File
Ready to use, open source, and fully functional java GpxParser (and much more) here https://sourceforge.net/projects/geokarambola/
Details here https://plus.google.com/u/0/communities/110606810455751902142
With the above library parsing a GPX file is a one liner:
Getting its points, routes or tracks trivial too: