jts icon indicating copy to clipboard operation
jts copied to clipboard

The geometry's SRID unexpectedly resets to 0 (EPSG:0) after spatial operations like buffer.

Open zglmcr opened this issue 3 months ago • 1 comments

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.

zglmcr avatar Sep 20 '25 13:09 zglmcr

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);

FObermaier avatar Sep 22 '25 07:09 FObermaier