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

@@ -1047,9 +1047,7 @@ function readLinearRing(node, objectStack) {
const flatCoordinates =
readFlatCoordinatesFromNode(node, objectStack);
if (flatCoordinates) {
const polygon = new Polygon(null);
polygon.setFlatCoordinates(GeometryLayout.XYZ, flatCoordinates,
[flatCoordinates.length]);
const polygon = new Polygon(flatCoordinates, GeometryLayout.XYZ, [flatCoordinates.length]);
polygon.setProperties(properties);
return polygon;
} else {
@@ -1179,14 +1177,13 @@ function readPolygon(node, objectStack) {
const flatLinearRings = pushParseAndPop([null],
FLAT_LINEAR_RINGS_PARSERS, node, objectStack);
if (flatLinearRings && flatLinearRings[0]) {
const polygon = new Polygon(null);
const flatCoordinates = flatLinearRings[0];
const ends = [flatCoordinates.length];
for (let i = 1, ii = flatLinearRings.length; i < ii; ++i) {
extend(flatCoordinates, flatLinearRings[i]);
ends.push(flatCoordinates.length);
}
polygon.setFlatCoordinates(GeometryLayout.XYZ, flatCoordinates, ends);
const polygon = new Polygon(flatCoordinates, GeometryLayout.XYZ, ends);
polygon.setProperties(properties);
return polygon;
} else {