Allow flat coordinates for Polygon constructor
This commit is contained in:
@@ -247,7 +247,6 @@ GML3.prototype.readSurface_ = function(node, objectStack) {
|
||||
const flatLinearRings = pushParseAndPop([null],
|
||||
this.SURFACE_PARSERS_, node, objectStack, this);
|
||||
if (flatLinearRings && flatLinearRings[0]) {
|
||||
const polygon = new Polygon(null);
|
||||
const flatCoordinates = flatLinearRings[0];
|
||||
const ends = [flatCoordinates.length];
|
||||
let i, ii;
|
||||
@@ -255,9 +254,7 @@ GML3.prototype.readSurface_ = function(node, objectStack) {
|
||||
extend(flatCoordinates, flatLinearRings[i]);
|
||||
ends.push(flatCoordinates.length);
|
||||
}
|
||||
polygon.setFlatCoordinates(
|
||||
GeometryLayout.XYZ, flatCoordinates, ends);
|
||||
return polygon;
|
||||
return new Polygon(flatCoordinates, GeometryLayout.XYZ, ends);
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -444,7 +444,6 @@ GMLBase.prototype.readPolygon = function(node, objectStack) {
|
||||
const flatLinearRings = pushParseAndPop([null],
|
||||
this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this);
|
||||
if (flatLinearRings && flatLinearRings[0]) {
|
||||
const polygon = new Polygon(null);
|
||||
const flatCoordinates = flatLinearRings[0];
|
||||
const ends = [flatCoordinates.length];
|
||||
let i, ii;
|
||||
@@ -452,8 +451,7 @@ GMLBase.prototype.readPolygon = function(node, objectStack) {
|
||||
extend(flatCoordinates, flatLinearRings[i]);
|
||||
ends.push(flatCoordinates.length);
|
||||
}
|
||||
polygon.setFlatCoordinates(GeometryLayout.XYZ, flatCoordinates, ends);
|
||||
return polygon;
|
||||
return new Polygon(flatCoordinates, GeometryLayout.XYZ, ends);
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -336,17 +336,19 @@ MVT.prototype.createFeature_ = function(pbf, rawFeature, opt_options) {
|
||||
ends = endss;
|
||||
geom = new MultiPolygon(null);
|
||||
} else {
|
||||
geom = new Polygon(null);
|
||||
geom = new Polygon(flatCoordinates, GeometryLayout.XY, ends);
|
||||
}
|
||||
} else {
|
||||
geom = geometryType === GeometryType.POINT ? new Point(null) :
|
||||
geometryType === GeometryType.LINE_STRING ? new LineString(null) :
|
||||
geometryType === GeometryType.POLYGON ? new Polygon(null) :
|
||||
geometryType === GeometryType.POLYGON ? new Polygon(flatCoordinates, GeometryLayout.XY, ends) :
|
||||
geometryType === GeometryType.MULTI_POINT ? new MultiPoint (null) :
|
||||
geometryType === GeometryType.MULTI_LINE_STRING ? new MultiLineString(null) :
|
||||
null;
|
||||
}
|
||||
geom.setFlatCoordinates(GeometryLayout.XY, flatCoordinates, ends);
|
||||
if (geometryType !== GeometryType.POLYGON) {
|
||||
geom.setFlatCoordinates(GeometryLayout.XY, flatCoordinates, ends);
|
||||
}
|
||||
feature = new this.featureClass_();
|
||||
if (this.geometryName_) {
|
||||
feature.setGeometryName(this.geometryName_);
|
||||
|
||||
@@ -175,9 +175,7 @@ OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
let geometry;
|
||||
if (values.ndrefs[0] == values.ndrefs[values.ndrefs.length - 1]) {
|
||||
// closed way
|
||||
geometry = new Polygon(null);
|
||||
geometry.setFlatCoordinates(GeometryLayout.XY, flatCoordinates,
|
||||
[flatCoordinates.length]);
|
||||
geometry = new Polygon(flatCoordinates, GeometryLayout.XY, [flatCoordinates.length]);
|
||||
} else {
|
||||
geometry = new LineString(null);
|
||||
geometry.setFlatCoordinates(GeometryLayout.XY, flatCoordinates);
|
||||
|
||||
Reference in New Issue
Block a user