ticofab / android-gpx-parser

A library to parse XML Gpx files, built for Android.
Apache License 2.0
123 stars 44 forks source link

Added custom extensions support for points and segments #55

Closed savked closed 11 months ago

savked commented 11 months ago

Solves #54

I was in need of the same thing and decided to contribute. However I was more in a need of an extension for segments, but the principle is the same so I added for both segments and points.

I have only added an extension in first segment and point for testing, feel free to edit that and perhaps include the extensions in logging of the test activity.

ticofab commented 11 months ago

Thanks for opening this PR. Will give a look as soon as possible!

ticofab commented 11 months ago

Hey @savked , thanks a lot for this PR! I merged it into the branch called "road-to-2.4.0", and one of the tests fails with

org.xmlpull.v1.XmlPullParserException: expected: END_TAG {null}extensions (position:END_TAG </{http://www.garmin.com/xmlschemas/GpxExtensions/v3}gpxx:DisplayMode>@21:59 in java.io.InputStreamReader@491f74f)
at com.android.org.kxml2.io.KXmlParser.require(KXmlParser.java:2067)
at io.ticofab.androidgpxparser.parser.GPXParser.readExtensions(GPXParser.java:584)
at io.ticofab.androidgpxparser.parser.GPXParser.readPoint(GPXParser.java:337)

It would be great if you could fix that 🙏 And maybe also modify the README file to explain the new feature :) Thanks again!

savked commented 11 months ago

No problem! I didn't look at the tests, sorry about that. Will check it out sometime soon!

martin-gudmundson commented 11 months ago

@ticofab & @savked I had need of nested extensions (and also write support). I made a fork and did the changes i needed. It's breaking changes since i've removed your Extensions class but maybe you find it interesting for a potential 3.0 rewrite. I'm sorry I don't have time to create a PR for this myself at the moment. You can check it out in my fork here: https://github.com/martin-gudmundson/android-gpx-parser

Thanks for a nice framework!