edit method
Edits a Geometry by returning a new Geometry with a modification. The returned geometry may be:
- the input geometry itself. The returned Geometry might be the same as the Geometry passed in.
null
if the geometry is to be deleted.
@param geometry the Geometry to modify @param factory the factory with which to construct the modified Geometry (may be different to the factory of the input geometry) @return a new Geometry which is a modification of the input Geometry @return null if the Geometry is to be deleted completely
Implementation
Geometry? edit(Geometry? geometry, GeometryFactory? gfactory) {
if (geometry is LinearRing) {
return gfactory
?.createLinearRing(editCoords(geometry.getCoordinates(), geometry));
}
if (geometry is LineString) {
return gfactory
?.createLineString(editCoords(geometry.getCoordinates(), geometry));
}
if (geometry is Point) {
List<Coordinate> newCoordinates =
editCoords(geometry.getCoordinates(), geometry);
return gfactory
?.createPoint((newCoordinates.length > 0) ? newCoordinates[0] : null);
}
return geometry;
}