Accept polygons and flat coordinates in MultiPolygon constructor

This commit is contained in:
ahocevar
2018-07-07 17:31:35 +02:00
parent 0ec0491ef6
commit ce97cee6a6
7 changed files with 59 additions and 90 deletions

View File

@@ -122,11 +122,7 @@ GML3.prototype.readMultiSurface_ = function(node, objectStack) {
const polygons = pushParseAndPop([],
this.MULTISURFACE_PARSERS_, node, objectStack, this);
if (polygons) {
const multiPolygon = new MultiPolygon(null);
multiPolygon.setPolygons(polygons);
return multiPolygon;
} else {
return undefined;
return new MultiPolygon(polygons);
}
};

View File

@@ -337,11 +337,7 @@ GMLBase.prototype.readMultiPolygon = function(node, objectStack) {
/** @type {Array.<module:ol/geom/Polygon>} */
const polygons = pushParseAndPop([], this.MULTIPOLYGON_PARSERS_, node, objectStack, this);
if (polygons) {
const multiPolygon = new MultiPolygon(null);
multiPolygon.setPolygons(polygons);
return multiPolygon;
} else {
return undefined;
return new MultiPolygon(polygons);
}
};

View File

@@ -1108,8 +1108,7 @@ function readMultiGeometry(node, objectStack) {
multiGeometry = new MultiLineString(geometries);
setCommonGeometryProperties(multiGeometry, geometries);
} else if (type == GeometryType.POLYGON) {
multiGeometry = new MultiPolygon(null);
multiGeometry.setPolygons(geometries);
multiGeometry = new MultiPolygon(geometries);
setCommonGeometryProperties(multiGeometry, geometries);
} else if (type == GeometryType.GEOMETRY_COLLECTION) {
multiGeometry = new GeometryCollection(geometries);

View File

@@ -311,7 +311,7 @@ MVT.prototype.createFeature_ = function(pbf, rawFeature, opt_options) {
values[this.layerName_] = rawFeature.layer.name;
const flatCoordinates = [];
let ends = [];
const ends = [];
this.readRawGeometry_(pbf, rawFeature, flatCoordinates, ends);
const geometryType = getGeometryType(type, ends.length);
@@ -333,8 +333,7 @@ MVT.prototype.createFeature_ = function(pbf, rawFeature, opt_options) {
offset = end;
}
if (endss.length > 1) {
ends = endss;
geom = new MultiPolygon(null);
geom = new MultiPolygon(flatCoordinates, GeometryLayout.XY, endss);
} else {
geom = new Polygon(flatCoordinates, GeometryLayout.XY, ends);
}