jts
jts copied to clipboard
GeometryPrecisionReducer does not change factory/PrecisionModel of output
I'm using the GeometryPrecisionReducer to adjust the precision of a geometry. This works but the precision model of the output geometry is not changed although this is explicitly enabled with setChangePrecisionModel(true)
.
It seems that under the hood a NoOpGeometryOperation
is used. This does nothing but returning the input geometry.
Here is a unit test to demonstrate (my) expectation:
void testChangePrecisionModel() throws ParseException {
PrecisionModel precisionModel = new PrecisionModel(1000);
GeometryPrecisionReducer precisionReducer = new GeometryPrecisionReducer(precisionModel);
precisionReducer.setChangePrecisionModel(true);
Geometry geom = new WKTReader().read("LINESTRING (612955.157 5975669.491, 579339.471 5936922.488)");
System.out.println("PM orig: " + geom.getFactory().getPrecisionModel());
Geometry geomReduced = precisionReducer.reduce(geom);
System.out.println("PM redu: " + geomReduced.getFactory().getPrecisionModel());
assertEquals(precisionModel.getType(), geomReduced.getFactory().getPrecisionModel().getType());
}