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

@@ -1670,25 +1670,6 @@ describe('ol.format.KML', function() {
expect(f.get('bar')).to.be(undefined);
});
it('can read ExtendedData with displayName instead of name', function() {
const text =
'<kml xmlns="http://earth.google.com/kml/2.2">' +
' <Placemark xmlns="http://earth.google.com/kml/2.2">' +
' <ExtendedData>' +
' <Data>' +
' <displayName>foo</displayName>' +
' <value>bar</value>' +
' </Data>' +
' </ExtendedData>' +
' </Placemark>' +
'</kml>';
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
const f = fs[0];
expect(f).to.be.an(Feature);
expect(f.get('foo')).to.be('bar');
});
it('can read SchemaData', function() {
const text =
'<kml xmlns="http://earth.google.com/kml/2.2">' +
@@ -1709,7 +1690,7 @@ describe('ol.format.KML', function() {
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 =
'<kml xmlns="http://earth.google.com/kml/2.2">' +
' <Placemark xmlns="http://earth.google.com/kml/2.2">' +
@@ -1730,7 +1711,10 @@ describe('ol.format.KML', function() {
const f = fs[0];
expect(f).to.be.an(Feature);
expect(f.get('capital')).to.be('London');
expect(f.get('country')).to.be('United-Kingdom');
expect(f.get('country')).to.eql({
value: 'United-Kingdom',
displayName: 'Country'
});
});
});