Merge pull request #11721 from mike-000/patch-21

Handle empty Z coordinates in KML
This commit is contained in:
Andreas Hocevar
2020-11-06 13:38:06 +01:00
committed by GitHub
2 changed files with 50 additions and 1 deletions

View File

@@ -468,6 +468,54 @@ describe('ol.format.KML', function () {
expect(g.get('altitudeMode')).to.be('absolute');
});
it('can read XY coordinates', function () {
const text =
'<kml xmlns="http://earth.google.com/kml/2.2">' +
' <Placemark>' +
' <LineString>' +
' <coordinates>1,2 3,4</coordinates>' +
' <extrude>0</extrude>' +
' <tessellate>1</tessellate>' +
' <altitudeMode>absolute</altitudeMode>' +
' </LineString>' +
' </Placemark>' +
'</kml>';
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
const f = fs[0];
expect(f).to.be.an(Feature);
const g = f.getGeometry();
expect(g).to.be.an(LineString);
expect(g.getCoordinates()).to.eql([
[1, 2, 0],
[3, 4, 0],
]);
});
it('can read empty Z coordinates', function () {
const text =
'<kml xmlns="http://earth.google.com/kml/2.2">' +
' <Placemark>' +
' <LineString>' +
' <coordinates>1,2, 3,4,</coordinates>' +
' <extrude>0</extrude>' +
' <tessellate>1</tessellate>' +
' <altitudeMode>absolute</altitudeMode>' +
' </LineString>' +
' </Placemark>' +
'</kml>';
const fs = format.readFeatures(text);
expect(fs).to.have.length(1);
const f = fs[0];
expect(f).to.be.an(Feature);
const g = f.getGeometry();
expect(g).to.be.an(LineString);
expect(g.getCoordinates()).to.eql([
[1, 2, 0],
[3, 4, 0],
]);
});
it('can write XY LineString geometries', function () {
const layout = 'XY';
const lineString = new LineString(