public Geometry createGeometry(Geometry g) { return delegate.createGeometry(g); }
/** * Sets the geometry contained in this lite shape. Convenient to reuse this object instead of * creating it again and again during rendering * * @param g * @throws TransformException * @throws FactoryException */ public void setGeometry(Geometry g) throws TransformException, FactoryException { if (g != null) { this.geometry = getGeometryFactory().createGeometry(g); transformGeometry(geometry); } }
g = factory.createGeometry(g);
/** * Creates a new LiteShape object. * * @param geom - the wrapped geometry * @param at - the transformation applied to the geometry in order to get to the shape points * @param generalize - set to true if the geometry need to be generalized during rendering */ public LiteShape(Geometry geom, AffineTransform at, boolean generalize) { if (geom != null) this.geometry = getGeometryFactory().createGeometry(geom); this.affineTransform = at; this.generalize = generalize; if (at == null) { yScale = xScale = 1; return; } xScale = (float) Math.sqrt( (at.getScaleX() * at.getScaleX()) + (at.getShearX() * at.getShearX())); yScale = (float) Math.sqrt( (at.getScaleY() * at.getScaleY()) + (at.getShearY() * at.getShearY())); }
public Object visit(Literal expression, Object extraData) { if (!(expression.getValue() instanceof Geometry)) return super.visit(expression, extraData); // check if reprojection is needed Geometry geom = (Geometry) expression.getValue(); if (geom.getUserData() != null && geom.getUserData() instanceof CoordinateReferenceSystem) return super.visit(expression, extraData); // clone the geometry and assign the new crs Geometry clone = geom.getFactory().createGeometry(geom); clone.setUserData(defaultCrs); // clone return ff.literal(clone); } }
public static Geometry clone(Geometry g) { return gf.createGeometry(g); } }
public @Override Optional<Geometry> get(int index, GeometryFactory gf) { Geometry g = (Geometry) values[index]; Geometry g2 = null; if (g != null) { g2 = gf.createGeometry(g); } return Optional.fromNullable(g2); }
public @Override Optional<Geometry> get(int index, GeometryFactory gf) { Geometry g = (Geometry) values[index]; Geometry g2 = null; if (g != null) { g2 = gf.createGeometry(g); } return Optional.fromNullable(g2); }
public void testEqualsFilter() throws Exception { FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); // should match only "r3" GeometryFactory gf = new GeometryFactory(); Geometry g = gf.createGeometry((Geometry) td.roadFeatures[2].getDefaultGeometry()); Equals cs = ff.equal(ff.literal(g), ff.property(aname("geom"))); FeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(cs); checkSingleResult(features, "r3"); }
private Point editPoint(Point geom) { Point newGeom = (Point) operation.edit(geom, targetFactory); if (newGeom == null) { // null return means create an empty one newGeom = targetFactory.createPoint((CoordinateSequence) null); } else if (newGeom == geom) { // If geometry was not modified, copy it newGeom = (Point) targetFactory.createGeometry(geom); } return newGeom; }
private LinearRing editLinearRing(LinearRing geom) { LinearRing newGeom = (LinearRing) operation.edit(geom, targetFactory); if (newGeom == null) { // null return means create an empty one newGeom = targetFactory.createLinearRing((CoordinateSequence) null); } else if (newGeom == geom) { // If geometry was not modified, copy it newGeom = (LinearRing) targetFactory.createGeometry(geom); } return newGeom; }
private LineString editLineString(LineString geom) { LineString newGeom = (LineString) operation.edit(geom, targetFactory); if (newGeom == null) { // null return means create an empty one newGeom = targetFactory.createLineString((CoordinateSequence) null); } else if (newGeom == geom) { // If geometry was not modified, copy it newGeom = (LineString) targetFactory.createGeometry(geom); } return newGeom; }
private Geometry fixPolygonalTopology(Geometry geom) { /** * If precision model was *not* changed, need to flip * geometry to targetPM, buffer in that model, then flip back */ Geometry geomToBuffer = geom; if (! changePrecisionModel) { geomToBuffer = changePM(geom, targetPM); } Geometry bufGeom = geomToBuffer.buffer(0); Geometry finalGeom = bufGeom; if (! changePrecisionModel) { // a slick way to copy the geometry with the original precision factory finalGeom = geom.getFactory().createGeometry(bufGeom); } return finalGeom; }
@Nullable private TopoGeom createObject(String featureId, Geometry geom, Map<String, Object> properties) throws MismatchedDimensionException, TransformException { // // snap to pixel geom = fixedGeometryFactory.createGeometry(geom); if (geom.isEmpty()) { return null; } if (geom instanceof GeometryCollection && geom.getNumGeometries() == 1) { geom = geom.getGeometryN(0); } TopoGeom geometry = createGeometry(geom); geometry.setProperties(properties); geometry.setId(featureId); return geometry; }
private void checkCreateGeometryExact(String wkt) throws ParseException { Geometry g = read(wkt); Geometry g2 = geometryFactory.createGeometry(g); assertTrue(g.equalsExact(g2)); }
public void testDeepCopy() throws ParseException { Point g = (Point) read("POINT ( 10 10) "); Geometry g2 = geometryFactory.createGeometry(g); g.getCoordinateSequence().setOrdinate(0, 0, 99); assertTrue(! g.equalsExact(g2)); }
/** * Returns a new ROI created by applying the given transform to * this ROI. * * @param at the transform * * @return the new ROI */ @Override public ROI transform(AffineTransform at) { Geometry cloned = theGeom.getGeometry().copy(); cloned.apply(new AffineTransformation(at.getScaleX(), at.getShearX(), at.getTranslateX(), at.getShearY(), at.getScaleY(), at.getTranslateY())); if (useFixedPrecision){ Geometry fixed = PRECISE_FACTORY.createGeometry(cloned); Coordinate[] coords = fixed.getCoordinates(); for (Coordinate coord : coords) { Coordinate precise = coord; PRECISION.makePrecise(precise); } cloned = fixed; } return buildROIGeometry(cloned); }
/** * Returns a new ROI created by applying the given transform to * this ROI. * * @param at the transform * * @return the new ROI */ @Override public ROI transform(AffineTransform at) { Geometry cloned = (Geometry) theGeom.getGeometry().clone(); cloned.apply(new AffineTransformation(at.getScaleX(), at.getShearX(), at.getTranslateX(), at.getShearY(), at.getScaleY(), at.getTranslateY())); if (useFixedPrecision){ Geometry fixed = PRECISE_FACTORY.createGeometry(cloned); Coordinate[] coords = fixed.getCoordinates(); for (Coordinate coord : coords) { Coordinate precise = coord; PRECISION.makePrecise(precise); } cloned = fixed; } return buildROIGeometry(cloned); }
/** * Returns a new ROI created by applying the given transform to * this ROI. * * @param at the transform * * @return the new ROI */ @Override public ROI transform(AffineTransform at) { Geometry cloned = (Geometry) theGeom.getGeometry().clone(); cloned.apply(new AffineTransformation(at.getScaleX(), at.getShearX(), at.getTranslateX(), at.getShearY(), at.getScaleY(), at.getTranslateY())); if (useFixedPrecision){ Geometry fixed = PRECISE_FACTORY.createGeometry(cloned); Coordinate[] coords = fixed.getCoordinates(); for (Coordinate coord : coords) { Coordinate precise = coord; PRECISION.makePrecise(precise); } cloned = fixed; } return buildROIGeometry(cloned); }
/** * CoordinateArraySequences default their dimension to 3 unless explicitly told otherwise. * This test ensures that GeometryFactory.createGeometry() recreates the input dimension properly. * * @throws ParseException */ public void testCopyGeometryWithNonDefaultDimension() throws ParseException { GeometryFactory gf = new GeometryFactory(CoordinateArraySequenceFactory.instance()); CoordinateSequence mpSeq = gf.getCoordinateSequenceFactory().create(1, 2); mpSeq.setOrdinate(0, 0, 50); mpSeq.setOrdinate(0, 1, -2); Point g = gf.createPoint(mpSeq); CoordinateSequence pSeq = ((Point) g.getGeometryN(0)).getCoordinateSequence(); assertEquals(2, pSeq.getDimension()); Point g2 = (Point) geometryFactory.createGeometry(g); assertEquals(2, g2.getCoordinateSequence().getDimension()); }