I've been working to incorporate GPX file handling within my application with a pretty good degree of success but have just encountered an issue which I don't know how to solve.
When drag/dropping a file which contains shapes I've discovered that these are incorrectly interpreted as routes and it seems that the API can not read the extensions node by default. The trouble is I have no idea how to configure the readExtensions function of the GPX format to deal with this.
I don't really want to have to parse these features manually as the default drag/drop parsing is superfast and I'm sure there'd be a performance hit. This is what I have so far...
var CustomFormatGPX = function () {
ol.format.GPX.call(this, {
// custom options
readExtensions: function (feature, extensionsNode) {
console.log(extensionsNode);
console.log(feature);
}
});
};
ol.inherits(CustomFormatGPX, ol.format.GPX);
session.routeFeaturesGPX = formatGPX.writeFeatures(event.features);
So event.features is Openlayers' GeoJSON interpretation of the information and formatGPX.writeFeatures will rewrite this as GPX albeit without reading the extensions correctly. Is there a third party solution which will reparse this as GeoJSON or am I approaching this the wrong way?
There is an issue on the OL3 Github pages but my javascript knowledge is sometimes deficient and I'm struggling to understand what to place in this function. A colleague suggested XPath to try to read and manipulate the data but apparently cross-browser support is patchy. Does anyone have any experience of this?