editPolygon method
Implementation
Polygon editPolygon(Polygon? polygon, GeometryEditorOperation operation) {
Polygon? newPolygon = operation.edit(polygon, _geomFactory) as Polygon;
// create one if needed
if (newPolygon == null) newPolygon = _geomFactory!.createPolygonEmpty();
if (newPolygon.isEmpty()) {
//RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino]
return newPolygon;
}
LinearRing? shell =
edit(newPolygon.getExteriorRing(), operation) as LinearRing;
if (shell == null || shell.isEmpty()) {
//RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino]
return _geomFactory!.createPolygonEmpty();
}
List<LinearRing> holes = [];
for (int i = 0; i < newPolygon.getNumInteriorRing(); i++) {
LinearRing? hole =
edit(newPolygon.getInteriorRingN(i), operation) as LinearRing;
if (hole == null || hole.isEmpty()) {
continue;
}
holes.add(hole);
}
return _geomFactory!.createPolygon(shell, holes);
}