Changes to parsing of KML displayName

To avoid loss of information the behaviour
of parsing the displayName (if a name attribute is
also given) is changed.
This commit is contained in:
Kai Volland
2019-04-04 16:54:17 +02:00
committed by ahocevar
parent 9b6fcf8d7b
commit bebd7b6b26
2 changed files with 18 additions and 29 deletions

View File

@@ -682,9 +682,9 @@ class KML extends XMLFeature {
const localName = n.localName;
if (includes(NAMESPACE_URIS, n.namespaceURI) &&
(localName == 'Document' ||
localName == 'Folder' ||
localName == 'Placemark' ||
localName == 'kml')) {
localName == 'Folder' ||
localName == 'Placemark' ||
localName == 'kml')) {
const name = this.readNameFromNode(n);
if (name) {
return name;
@@ -748,8 +748,8 @@ class KML extends XMLFeature {
const localName = n.localName;
if (includes(NAMESPACE_URIS, n.namespaceURI) &&
(localName == 'Document' ||
localName == 'Folder' ||
localName == 'kml')) {
localName == 'Folder' ||
localName == 'kml')) {
extend(networkLinks, this.readNetworkLinksFromNode(n));
}
}
@@ -811,8 +811,8 @@ class KML extends XMLFeature {
const localName = n.localName;
if (includes(NAMESPACE_URIS, n.namespaceURI) &&
(localName == 'Document' ||
localName == 'Folder' ||
localName == 'kml')) {
localName == 'Folder' ||
localName == 'kml')) {
extend(regions, this.readRegionFromNode(n));
}
}
@@ -1797,7 +1797,12 @@ function dataParser(node, objectStack) {
const name = node.getAttribute('name');
parseNode(DATA_PARSERS, node, objectStack);
const featureObject = /** @type {Object} */ (objectStack[objectStack.length - 1]);
if (name !== null) {
if (name && featureObject.displayName) {
featureObject[name] = {
value: featureObject.value,
displayName: featureObject.displayName
};
} else if (name !== null) {
featureObject[name] = featureObject.value;
} else if (featureObject.displayName !== null) {
featureObject[featureObject.displayName] = featureObject.value;