jts
jts copied to clipboard
The geometry's SRID unexpectedly resets to 0 (EPSG:0) after spatial operations like buffer.
import org.locationtech.jts.geom._ val geometryFactory :GeometryFactory= new GeometryFactory() val coor=new Coordinate(116.0, 36.0) val geom: Geometry = geometryFactory.createPoint(coor) geom.setSRID(4326) val bufferGeom=geom.buffer(0.5) println(bufferGeom.getSRID) //result: 0
This result is unexpected because it requires manually setting the SRID each time, which is inconvenient.
If you set the SRID value on the GeometryFactory you should be all set:
GeometryFactory gf = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING), 4326);
Geometry geom = gf.createPoint(new Coordinate(116.0, 36.0));
Geometry bufferGeom = geom.buffer(0.5);