Open edorphy opened 5 years ago
Hi @edorphy,
Technically, it is possible to read and write extensions data using GPXExtensions
right now.
Maybe you would want to try that out? It surely isn't as polished as a hard coded approach, but that is what it is for now. I am thinking that it maybe possible where I support some common extensions types like from Garmin, and this, etc.
Looking at the export though, I am surprised to see that Apple appears to be generating a rather non standard GPX file, considering that there is no extension schema provided in the gpx tag.
@vincentneo
I did try using the extensions and extension elements. I was able to get it close to Apple, but it added the parent tag, as expected from the library.
When I was reading the gpx spec (web ref from topografix), I couldn't discern if the extensions type could be any xml nodes, or if they needed to be nested within a parent schema. Is this what you were referring to as apple being non-standard?
Thanks for the reply!
@edorphy
Did some codes, and found GPXExtensions rather defective at this point - i just didn't notice it. Using .append(parent: nil, contents: ["":""])
shouldn't generate a parent tag, but it did.
Will attempt to fix in a couple of days hopefully.
By the way, the reason why I said that Apple's approach seems non-standard is because of this:
<gpx
version="1.1"
creator="Runkeeper - http://www.runkeeper.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.topografix.com/GPX/1/1"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1">
Normally, a schema will be appended to the gpx tag. The extensions in the whole file should follow what is listed in the schema, but Apple's approach in your example did not show that, which, meant that they may change something near future, without telling the user/app developer of what it should be.
Apple Health exports any workout routes as GPX as of iOS 13.1. It would be nice if this library supported generating files with the same extension fields on tracepoints. Specifically the other properties on CLLocation objects, speed, course, hAcc, vAcc.
Sample generated from watch/iPhone simulator and then exported.