You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code shows a bug, where the original feature collection contains a multipolygon with two shapes, but the resulting buffered output only has one of those polygons
Note, this is a very ugly hack/fix to this problem. Looks like the underlying jsts is not doing the right thing, so instead I just buffer each polygon inside the MultiPolygon separately. Obviously not the ultimate solution, but it unblocks me for now until a proper fix is made:
var bufferOp = function(feature, radius) {
var reader = new jsts.io.GeoJSONReader();
var parser = new jsts.io.GeoJSONParser();
var geom, buffered, polyCoord, polyGeom;
var mulitCoords = [];
if (feature.geometry.type === 'MultiPolygon') {
// Work around a bug where jsts drops entire polygons from multipolygons
for (var i = 0; i < feature.geometry.coordinates.length; i++) {
polyCoord = feature.geometry.coordinates[i];
polyGeom = {
type: 'Polygon',
coordinates: polyCoord
};
geom = reader.read(JSON.stringify(polyGeom));
buffered = geom.buffer(radius);
buffered = parser.write(buffered);
mulitCoords.push(buffered.coordinates);
}
buffered.type = 'MultiPolygon';
buffered.coordinates = mulitCoords;
} else {
geom = reader.read(JSON.stringify(feature.geometry));
buffered = geom.buffer(radius);
buffered = parser.write(buffered);
}
return {
type: 'Feature',
geometry: buffered,
properties: feature.properties
};
};
(note: my hack can produce geojson which is subsequently not able to be merged with turf-merge (causes an exception to be thrown by jsts. I'm not raising that as a bug, since I suspect my hack isn't quite right... )
The following code shows a bug, where the original feature collection contains a multipolygon with two shapes, but the resulting buffered output only has one of those polygons
The text was updated successfully, but these errors were encountered: