private GeometryEditor createEditor(GeometryFactory geomFactory, PrecisionModel newPM) { // no need to change if precision model is the same if (geomFactory.getPrecisionModel() == newPM) { return new GeometryEditor(); } // otherwise create a geometry editor which changes PrecisionModel GeometryFactory newFactory = this.createFactory(geomFactory, newPM); GeometryEditor geomEdit = new GeometryEditor(newFactory); return geomEdit; }
private GeometryEditor createEditor(GeometryFactory geomFactory, PrecisionModel newPM) { // no need to change if precision model is the same if (geomFactory.getPrecisionModel() == newPM) return new GeometryEditor(); // otherwise create a geometry editor which changes PrecisionModel GeometryFactory newFactory = createFactory(geomFactory, newPM); GeometryEditor geomEdit = new GeometryEditor(newFactory); return geomEdit; }
/** * Creates a deep copy of the input {@link Geometry}. * The {@link CoordinateSequenceFactory} defined for this factory * is used to copy the {@link CoordinateSequence}s * of the input geometry. * <p> * This is a convenient way to change the <tt>CoordinateSequence</tt> * used to represent a geometry, or to change the * factory used for a geometry. * <p> * {@link Geometry#clone()} can also be used to make a deep copy, * but it does not allow changing the CoordinateSequence type. * * @return a deep copy of the input geometry, using the CoordinateSequence type of this factory * @see Geometry#clone() */ public Geometry createGeometry(Geometry g) { GeometryEditor editor = new GeometryEditor(this); return editor.edit(g, new GeometryEditor.CoordinateSequenceOperation() { @Override public CoordinateSequence edit(CoordinateSequence coordSeq, Geometry geometry) { return GeometryFactory.this.coordinateSequenceFactory.create(coordSeq); } }); }
/** * Creates a deep copy of the input {@link Geometry}. * The {@link CoordinateSequenceFactory} defined for this factory * is used to copy the {@link CoordinateSequence}s * of the input geometry. * <p/> * This is a convenient way to change the <tt>CoordinateSequence</tt> * used to represent a geometry, or to change the * factory used for a geometry. * <p/> * {@link Geometry#clone()} can also be used to make a deep copy, * but it does not allow changing the CoordinateSequence type. * * @return a deep copy of the input geometry, using the CoordinateSequence type of this factory * @see Geometry#clone() */ public Geometry createGeometry(Geometry g) { GeometryEditor editor = new GeometryEditor(this); return editor.edit(g, new GeometryEditor.CoordinateSequenceOperation() { public CoordinateSequence edit(CoordinateSequence coordSeq, Geometry geometry) { return coordinateSequenceFactory.create(coordSeq); } }); }
/** * Duplicates a geometry to one that uses a different PrecisionModel, * without changing any coordinate values. * * @param geom the geometry to duplicate * @param newPM the precision model to use * @return the geometry value with a new precision model */ private Geometry changePM(Geometry geom, PrecisionModel newPM) { GeometryEditor geomEditor = this.createEditor(geom.getFactory(), newPM); // this operation changes the PM for the entire geometry tree return geomEditor.edit(geom, new GeometryEditor.NoOpGeometryOperation()); }
/** * Duplicates a geometry to one that uses a different PrecisionModel, * without changing any coordinate values. * * @param geom the geometry to duplicate * @param newPM the precision model to use * @return the geometry value with a new precision model */ private Geometry changePM(Geometry geom, PrecisionModel newPM) { GeometryEditor geomEditor = createEditor(geom.getFactory(), newPM); // this operation changes the PM for the entire geometry tree return geomEditor.edit(geom, new GeometryEditor.NoOpGeometryOperation()); }