########################################################################################## GPXIN-20: Implement support for extensions ########################################################################################## Issue Type: New Feature ----------------------------------------------------------------------------------------- Issue Information ==================== Priority: Major Status: Open Resolution: Unresolved Project: PHP GPXIngest (GPXIN) Reported By: btasker Assigned To: btasker Affected Versions: - 1.03 Targeted for fix in version: - 1.04 Time Estimate: 0 minutes Time Logged: 0 minutes ----------------------------------------------------------------------------------------- Issue Description ================== Depending on the system used to generate the GPX file, speed may be listed under an extension, as below (from GPXIN-19) -- BEGIN SNIPPET -- 55.0 11.6 1.7 -- END SNIPPET -- There's no way to know for sure what extension the data we need will be listed under, so will need to add a method so that the class can be told what to look for (and perhaps set some known defaults too?) ----------------------------------------------------------------------------------------- Issue Relations ================ - Discovered In GPXIN-19: Bug: Speed and CalcDistance won't display - GPX Schema Documentation (http://www.topografix.com/gpx/1/1/) ----------------------------------------------------------------------------------------- Activity ========== ----------------------------------------------------------------------------------------- 2015-08-11 00:08:11 btasker ----------------------------------------------------------------------------------------- As there's no explicit namespace for extensions (http://www.topografix.com/GPX/1/1/#type_extensionsType) , there isn't a schema that can be used for a one-size-fits-all solution. I think the first thing I'd like to do is to at least get the extensions data into the object's output, then look at ways in which developers can tell the class to use those extensions. Taking the example above, it'd be good to be able to do something similar to the following -- BEGIN SNIPPET -- useExtension('nmea_speed','speed'); // Tell the class to use extensions->nmea:speed as the speed field $gpx->loadFile('test.gpx'); $gpx->ingest(); echo $json = $gpx->getJSON(); -- END SNIPPET -- But, if we can at least get the extensions written into the JSON first, there'll at least be a way to grab the raw data. ----------------------------------------------------------------------------------------- 2015-08-11 00:26:09 btasker ----------------------------------------------------------------------------------------- We'll need to read in the namespace URL from the GPX file for SimpleXML to be able to access the relevant elements though. That aside, dropping the following in seems to work OK -- BEGIN SNIPPET -- foreach ($trkpt->extensions->children('http://trekbuddy.net/2009/01/gpx/nmea') as $t){ echo $t->getName()."-".$t."\n"; } /* The above outputs course-11.6 speed-1.7 */ -- END SNIPPET -- So should just be a case of getting the class to look for namespaces in the GPX file, cycle through those and then add values for each of the extensions to an array or object. ----------------------------------------------------------------------------------------- 2015-08-11 00:38:52 btasker ----------------------------------------------------------------------------------------- OK, the basic implementation is there, the namespaces present in the GPX file are written into the object under _created->namespaces_ and then any relevant extension data is written into each of the trackpoints. Each of the namespaces is it's own array, so the seperation is maintained. Not sure if I like the implementation yet, but it is at least functional. ----------------------------------------------------------------------------------------- 2015-08-11 00:40:08 git ----------------------------------------------------------------------------------------- -- BEGIN QUOTE -- Repo: PHP-GPX-Ingest Commit: 302545f7fe9d13553ec39746037cc2127fd72713 Author: Ben Tasker