Merge pull request #9400 from KaiVolland/kml-fixes
Changes to parsing of KML displayName
This commit is contained in:
@@ -682,9 +682,9 @@ class KML extends XMLFeature {
|
|||||||
const localName = n.localName;
|
const localName = n.localName;
|
||||||
if (includes(NAMESPACE_URIS, n.namespaceURI) &&
|
if (includes(NAMESPACE_URIS, n.namespaceURI) &&
|
||||||
(localName == 'Document' ||
|
(localName == 'Document' ||
|
||||||
localName == 'Folder' ||
|
localName == 'Folder' ||
|
||||||
localName == 'Placemark' ||
|
localName == 'Placemark' ||
|
||||||
localName == 'kml')) {
|
localName == 'kml')) {
|
||||||
const name = this.readNameFromNode(n);
|
const name = this.readNameFromNode(n);
|
||||||
if (name) {
|
if (name) {
|
||||||
return name;
|
return name;
|
||||||
@@ -748,8 +748,8 @@ class KML extends XMLFeature {
|
|||||||
const localName = n.localName;
|
const localName = n.localName;
|
||||||
if (includes(NAMESPACE_URIS, n.namespaceURI) &&
|
if (includes(NAMESPACE_URIS, n.namespaceURI) &&
|
||||||
(localName == 'Document' ||
|
(localName == 'Document' ||
|
||||||
localName == 'Folder' ||
|
localName == 'Folder' ||
|
||||||
localName == 'kml')) {
|
localName == 'kml')) {
|
||||||
extend(networkLinks, this.readNetworkLinksFromNode(n));
|
extend(networkLinks, this.readNetworkLinksFromNode(n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -811,8 +811,8 @@ class KML extends XMLFeature {
|
|||||||
const localName = n.localName;
|
const localName = n.localName;
|
||||||
if (includes(NAMESPACE_URIS, n.namespaceURI) &&
|
if (includes(NAMESPACE_URIS, n.namespaceURI) &&
|
||||||
(localName == 'Document' ||
|
(localName == 'Document' ||
|
||||||
localName == 'Folder' ||
|
localName == 'Folder' ||
|
||||||
localName == 'kml')) {
|
localName == 'kml')) {
|
||||||
extend(regions, this.readRegionFromNode(n));
|
extend(regions, this.readRegionFromNode(n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1797,7 +1797,15 @@ function dataParser(node, objectStack) {
|
|||||||
const name = node.getAttribute('name');
|
const name = node.getAttribute('name');
|
||||||
parseNode(DATA_PARSERS, node, objectStack);
|
parseNode(DATA_PARSERS, node, objectStack);
|
||||||
const featureObject = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
const featureObject = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
if (name !== null) {
|
if (name && featureObject.displayName) {
|
||||||
|
featureObject[name] = {
|
||||||
|
value: featureObject.value,
|
||||||
|
displayName: featureObject.displayName,
|
||||||
|
toString: function() {
|
||||||
|
return featureObject.value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else if (name !== null) {
|
||||||
featureObject[name] = featureObject.value;
|
featureObject[name] = featureObject.value;
|
||||||
} else if (featureObject.displayName !== null) {
|
} else if (featureObject.displayName !== null) {
|
||||||
featureObject[featureObject.displayName] = featureObject.value;
|
featureObject[featureObject.displayName] = featureObject.value;
|
||||||
|
|||||||
@@ -1709,7 +1709,7 @@ describe('ol.format.KML', function() {
|
|||||||
expect(f.get('population')).to.be('60000000');
|
expect(f.get('population')).to.be('60000000');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can read ExtendedData with displayName when name undefined', function() {
|
it('can read ExtendedData with displayName', function() {
|
||||||
const text =
|
const text =
|
||||||
'<kml xmlns="http://earth.google.com/kml/2.2">' +
|
'<kml xmlns="http://earth.google.com/kml/2.2">' +
|
||||||
' <Placemark xmlns="http://earth.google.com/kml/2.2">' +
|
' <Placemark xmlns="http://earth.google.com/kml/2.2">' +
|
||||||
@@ -1730,7 +1730,8 @@ describe('ol.format.KML', function() {
|
|||||||
const f = fs[0];
|
const f = fs[0];
|
||||||
expect(f).to.be.an(Feature);
|
expect(f).to.be.an(Feature);
|
||||||
expect(f.get('capital')).to.be('London');
|
expect(f.get('capital')).to.be('London');
|
||||||
expect(f.get('country')).to.be('United-Kingdom');
|
expect(f.get('country').value).to.be('United-Kingdom');
|
||||||
|
expect(f.get('country').displayName).to.be('Country');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user