kb0 / dart-gpx

Dart package for load, manipulate, and save GPS data in GPX format (a light-weight XML data format for the interchange of GPS data - waypoints, routes, and tracks).
Apache License 2.0
23 stars 27 forks source link

adding garmin extensions #26

Open Sprechen opened 1 month ago

Sprechen commented 1 month ago

I need to add information to my trk infos, specifically I need to add the speed of each point in the segment. This is defined by the garmin extension https://www8.garmin.com/xmlschemas/TrackPointExtensionv2.xsd. As I understand, for each point I can use the extensions map to add additional data for each Wpt point, but how I can add schemas to the Gpx node?

kb0 commented 1 month ago

It's possible to use GpxWriter().asXml. For ex.:

final gpxXml = GpxWriter().asXml(gpx);
gpxXml.children[1].setAttribute("xmlns:trp", "http://www.garmin.com/xmlschemas/TripExtensions/v1");
gpxXml.children[1].setAttribute("xsi:schemaLocation", "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd");
gpxXml.toXmlString()
Sprechen commented 1 month ago

It's possible to use GpxWriter().asXml. For ex.:

final gpxXml = GpxWriter().asXml(gpx);
gpxXml.children[1].setAttribute("xmlns:trp", "http://www.garmin.com/xmlschemas/TripExtensions/v1");
gpxXml.children[1].setAttribute("xsi:schemaLocation", "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd");
gpxXml.toXmlString()

Ok thank you! So, no native support for that! Maybe, I can make a pull request with this feature