Allow flat coordinates for Polygon constructor

This commit is contained in:
ahocevar
2018-07-07 14:16:39 +02:00
parent 9ddd7e4751
commit 1da43d90af
10 changed files with 53 additions and 85 deletions

View File

@@ -988,14 +988,19 @@ export function createBox() {
return (
function(coordinates, opt_geometry) {
const extent = boundingExtent(coordinates);
const geometry = opt_geometry || new Polygon(null);
geometry.setCoordinates([[
const boxCoordinates = [[
getBottomLeft(extent),
getBottomRight(extent),
getTopRight(extent),
getTopLeft(extent),
getBottomLeft(extent)
]]);
]];
let geometry = opt_geometry;
if (geometry) {
geometry.setCoordinates(boxCoordinates);
} else {
geometry = new Polygon(boxCoordinates);
}
return geometry;
}
);