Merge pull request #5208 from probins/rtewpt
Stop GPX writing rtept properties
This commit is contained in:
@@ -432,6 +432,8 @@ ol.format.GPX.prototype.handleReadExtensions_ = function(features) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the first feature from a GPX source.
|
* Read the first feature from a GPX source.
|
||||||
|
* Routes (`<rte>`) are converted into LineString geometries, and tracks (`<trk>`)
|
||||||
|
* into MultiLineString. Any properties on route and track waypoints are ignored.
|
||||||
*
|
*
|
||||||
* @function
|
* @function
|
||||||
* @param {Document|Node|Object|string} source Source.
|
* @param {Document|Node|Object|string} source Source.
|
||||||
@@ -466,6 +468,8 @@ ol.format.GPX.prototype.readFeatureFromNode = function(node, opt_options) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Read all features from a GPX source.
|
* Read all features from a GPX source.
|
||||||
|
* Routes (`<rte>`) are converted into LineString geometries, and tracks (`<trk>`)
|
||||||
|
* into MultiLineString. Any properties on route and track waypoints are ignored.
|
||||||
*
|
*
|
||||||
* @function
|
* @function
|
||||||
* @param {Document|Node|Object|string} source Source.
|
* @param {Document|Node|Object|string} source Source.
|
||||||
@@ -569,7 +573,9 @@ ol.format.GPX.writeWptType_ = function(node, coordinate, objectStack) {
|
|||||||
default:
|
default:
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
var orderedKeys = ol.format.GPX.WPT_TYPE_SEQUENCE_[namespaceURI];
|
var orderedKeys = (node.nodeName == 'rtept') ?
|
||||||
|
ol.format.GPX.RTEPT_TYPE_SEQUENCE_[namespaceURI] :
|
||||||
|
ol.format.GPX.WPT_TYPE_SEQUENCE_[namespaceURI];
|
||||||
var values = ol.xml.makeSequence(properties, orderedKeys);
|
var values = ol.xml.makeSequence(properties, orderedKeys);
|
||||||
ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
|
ol.xml.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
|
||||||
({node: node, 'properties': properties}),
|
({node: node, 'properties': properties}),
|
||||||
@@ -723,6 +729,17 @@ ol.format.GPX.RTE_SERIALIZERS_ = ol.xml.makeStructureNS(
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {Object.<string, Array.<string>>}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.format.GPX.RTEPT_TYPE_SEQUENCE_ = ol.xml.makeStructureNS(
|
||||||
|
ol.format.GPX.NAMESPACE_URIS_, [
|
||||||
|
'ele', 'time'
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {Object.<string, Array.<string>>}
|
* @type {Object.<string, Array.<string>>}
|
||||||
|
|||||||
@@ -117,6 +117,20 @@ describe('ol.format.GPX', function() {
|
|||||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not write rte attributes in rtepts', function() {
|
||||||
|
var text =
|
||||||
|
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||||
|
' <rte>' +
|
||||||
|
' <name>Name</name>' +
|
||||||
|
' <rtept lat="1" lon="2"/>' +
|
||||||
|
' <rtept lat="3" lon="4"/>' +
|
||||||
|
' </rte>' +
|
||||||
|
'</gpx>';
|
||||||
|
var fs = format.readFeatures(text);
|
||||||
|
var serialized = format.writeFeaturesNode(fs);
|
||||||
|
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('trk', function() {
|
describe('trk', function() {
|
||||||
@@ -295,6 +309,38 @@ describe('ol.format.GPX', function() {
|
|||||||
expect(serialized).to.xmleql(ol.xml.parse(text));
|
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not write trk attributes in trkpts', function() {
|
||||||
|
var text =
|
||||||
|
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||||
|
' <trk>' +
|
||||||
|
' <name>Name</name>' +
|
||||||
|
' <trkseg>' +
|
||||||
|
' <trkpt lat="1" lon="2">' +
|
||||||
|
' <ele>3</ele>' +
|
||||||
|
' <time>2010-01-10T09:29:12Z</time>' +
|
||||||
|
' </trkpt>' +
|
||||||
|
' <trkpt lat="5" lon="6">' +
|
||||||
|
' <ele>7</ele>' +
|
||||||
|
' <time>2010-01-10T09:30:12Z</time>' +
|
||||||
|
' </trkpt>' +
|
||||||
|
' </trkseg>' +
|
||||||
|
' <trkseg>' +
|
||||||
|
' <trkpt lat="8" lon="9">' +
|
||||||
|
' <ele>10</ele>' +
|
||||||
|
' <time>2010-01-10T09:31:12Z</time>' +
|
||||||
|
' </trkpt>' +
|
||||||
|
' <trkpt lat="11" lon="12">' +
|
||||||
|
' <ele>13</ele>' +
|
||||||
|
' <time>2010-01-10T09:32:12Z</time>' +
|
||||||
|
' </trkpt>' +
|
||||||
|
' </trkseg>' +
|
||||||
|
' </trk>' +
|
||||||
|
'</gpx>';
|
||||||
|
var fs = format.readFeatures(text);
|
||||||
|
var serialized = format.writeFeaturesNode(fs);
|
||||||
|
expect(serialized).to.xmleql(ol.xml.parse(text));
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('wpt', function() {
|
describe('wpt', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user