Handle multipolygons with empty polygons
This commit is contained in:
@@ -516,6 +516,26 @@ describe('ol/format/GeoJSON.js', function () {
|
||||
expect(array[1]).to.be.a(LineString);
|
||||
expect(array[1].getLayout()).to.eql('XY');
|
||||
});
|
||||
|
||||
it('works with empty coordinate arrays', function () {
|
||||
const coordinates = [
|
||||
[
|
||||
[
|
||||
[1, 2],
|
||||
[3, 4],
|
||||
[5, 6],
|
||||
[1, 2],
|
||||
],
|
||||
],
|
||||
[],
|
||||
];
|
||||
const geojson = {
|
||||
type: 'MultiPolygon',
|
||||
coordinates: coordinates,
|
||||
};
|
||||
const geometry = format.readGeometry(geojson);
|
||||
expect(geometry.getCoordinates()).to.eql(coordinates);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#readProjection', function () {
|
||||
@@ -1025,5 +1045,28 @@ describe('ol/format/GeoJSON.js', function () {
|
||||
[43, 39],
|
||||
]);
|
||||
});
|
||||
|
||||
it('works with empty coordinate arrays', function () {
|
||||
const coordinates = [
|
||||
[
|
||||
[
|
||||
[1, 2],
|
||||
[3, 4],
|
||||
[5, 6],
|
||||
[1, 2],
|
||||
],
|
||||
],
|
||||
[],
|
||||
];
|
||||
const geometry = new MultiPolygon([
|
||||
new Polygon(coordinates[0]),
|
||||
new Polygon(coordinates[1]),
|
||||
]);
|
||||
const geojson = format.writeGeometryObject(geometry);
|
||||
expect(geojson).to.eql({
|
||||
type: 'MultiPolygon',
|
||||
coordinates: coordinates,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user