return GEOMETRY_FACTORY.createMultiPolygon(); return GEOMETRY_FACTORY.createPolygon(); polygons.add(GEOMETRY_FACTORY.createPolygon(shell, holes.toArray(new LinearRing[0]))); holes.clear(); polygons.add(GEOMETRY_FACTORY.createPolygon(shell, holes.toArray(new LinearRing[0])));
holes.add(ring); else shells.add(geometryFactory.createPolygon(ring)); for (Polygon shell : shells) { List<LinearRing> shellHoles = ((List<LinearRing>) shell.getUserData()); punched.add(geometryFactory.createPolygon((LinearRing) (shell.getExteriorRing()), shellHoles.toArray(new LinearRing[shellHoles.size()])));
properties.put("bucket", features.size()); feature.setProperties(properties); feature.setGeometry(geometryFactory.createPolygon(polygonShell)); features.add(feature);
private static Geometry readEnvelope(SliceInput input) { verify(input.available() > 0); double xMin = input.readDouble(); double yMin = input.readDouble(); double xMax = input.readDouble(); double yMax = input.readDouble(); Coordinate[] coordinates = new Coordinate[5]; coordinates[0] = new Coordinate(xMin, yMin); coordinates[1] = new Coordinate(xMin, yMax); coordinates[2] = new Coordinate(xMax, yMax); coordinates[3] = new Coordinate(xMax, yMin); coordinates[4] = coordinates[0]; return GEOMETRY_FACTORY.createPolygon(coordinates); }
/** * Converts the specified {@code Envelope} to a {@code Polygon} having the specified srid. * * @param env The envelope to convert * @param srid The srid for the polygon * * @return The Polygon */ public static Polygon toPolygon(Envelope env, int srid) { final Coordinate[] coords = new Coordinate[5]; coords[0] = new Coordinate( env.getMinX(), env.getMinY() ); coords[1] = new Coordinate( env.getMinX(), env.getMaxY() ); coords[2] = new Coordinate( env.getMaxX(), env.getMaxY() ); coords[3] = new Coordinate( env.getMaxX(), env.getMinY() ); coords[4] = new Coordinate( env.getMinX(), env.getMinY() ); final LinearRing shell = geomFactory.createLinearRing( coords ); final Polygon pg = geomFactory.createPolygon( shell, null ); pg.setSRID( srid ); return pg; }
/** * Convience constructor for GeometryFactory.createPolygon. * * <p>The provided xy ordinates are turned into a linear rings. * * @param xy Two dimensional ordiantes. * @return Polygon */ public Polygon polygon(int[] xy) { LinearRing shell = ring(xy); return gf.createPolygon(shell, null); }
public Polygon createPolygon(LinearRing shell) { if (shell instanceof CurvedGeometry) { return new CurvePolygon(shell, (LinearRing[]) null, this, tolerance); } else { return delegate.createPolygon(shell); } }
/** * Creates an empty 3D Polygon. * * @return an empty Polygon */ public Polygon polygonZ() { return geomFact.createPolygon(linearRingZ(), null); }
/** * Creates a Polygon from a list of XY coordinates. * * @param ord a list of XY ordinates * @return a Polygon */ public Polygon polygon(double... ord) { return geomFact.createPolygon(linearRing(ord), null); }
/** * Create a simple polygon (no holes). * * @param coords the coords of the polygon. * @return the {@link Polygon}. */ public static Polygon createSimplePolygon(Coordinate[] coords) { return GF.createPolygon(GF.createLinearRing(coords), null); }
protected Polygon toPolygonS4J(GeometryFactory factory) { final LinearRing shell = linearRingS4J(factory, this.shell.coordinates); final LinearRing[] holes = new LinearRing[this.holes.size()]; Iterator<LineStringBuilder> iterator = this.holes.iterator(); for (int i = 0; iterator.hasNext(); i++) { holes[i] = linearRingS4J(factory, iterator.next().coordinates); } return factory.createPolygon(shell, holes); }
}; Polygon window = geometryFactory.createPolygon( coordinates ); Event event = entityManager.createQuery( "select e " +
public Polygon createPolygon(LinearRing shell, LinearRing[] holes) { if (shell instanceof CurvedGeometry || containsCurves(holes)) { return new CurvePolygon(shell, holes, this, tolerance); } else { return delegate.createPolygon(shell, holes); } }
private static Geometry smoothLineString( GeometryFactory factory, GeometrySmoother smoother, Geometry geom, double fit) { if (geom instanceof LinearRing) { // Treat as a Polygon Polygon poly = factory.createPolygon((LinearRing) geom, null); Polygon smoothed = smoother.smooth(poly, fit); return smoothed.getExteriorRing(); } else { return smoother.smooth((LineString) geom, fit); } }
/** As if the ring is the outer ring of a polygon */ SpatialRelation relateEnclosedRing(LinearRing ring) { SpatialRelation rel = relateLineString(ring); if (rel == SpatialRelation.DISJOINT && ctx.getGeometryFactory().createPolygon(ring, null).contains(ctrGeom)) { // If it contains the circle center point, then the result is CONTAINS rel = SpatialRelation.CONTAINS; } return rel; }
private Polygon readPolygon() throws IOException { int numRings = dis.readInt(); LinearRing[] holes = null; if (numRings > 1) holes = new LinearRing[numRings - 1]; LinearRing shell = readLinearRing(); for (int i = 0; i < numRings - 1; i++) { holes[i] = readLinearRing(); } return factory.createPolygon(shell, holes); }
private void addFullAreaPolygon(List<Polygon> geometriesList) { Coordinate[] coordinateArray = new Coordinate[5]; coordinateArray[0] = new Coordinate(imageProperties.minX - 1, imageProperties.minY - 1); coordinateArray[1] = new Coordinate(imageProperties.maxX, imageProperties.minY - 1); coordinateArray[2] = new Coordinate(imageProperties.maxX, imageProperties.maxY); coordinateArray[3] = new Coordinate(imageProperties.minX - 1, imageProperties.maxY); coordinateArray[4] = new Coordinate(imageProperties.minX - 1, imageProperties.minY - 1); LinearRing linearRing = GF.createLinearRing(coordinateArray); Polygon polygon = GF.createPolygon(linearRing, null); geometriesList.add(polygon); }
public void testCreateSchemaAndInsertPolyRectangle() throws Exception { LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); GeometryFactory gf = new GeometryFactory(csf); LinearRing shell = gf.createLinearRing( csf.create( new double[] {0, 0, 99, 1, 0, 33, 1, 1, 66, 0, 1, 33, 0, 0, 99}, 3)); Polygon poly = gf.createPolygon(shell, null); checkCreateSchemaAndInsert(poly); }
public void testContainsFilter() throws Exception { FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); // should match only "r2" GeometryFactory gf = new GeometryFactory(); PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory(); LinearRing shell = gf.createLinearRing(sf.create(new double[] {2, -1, 2, 5, 4, 5, 4, -1, 2, -1}, 2)); Polygon polygon = gf.createPolygon(shell, null); Contains cs = ff.contains(ff.literal(polygon), ff.property(aname("geom"))); FeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(cs); checkSingleResult(features, "r2"); }
@Test public void smoothPolygon() { Coordinate[] coords = getPolyCoords(); Polygon poly = factory.createPolygon(factory.createLinearRing(coords), null); Geometry smoothed = JTS.smooth(poly, 0); assertTrue(smoothed instanceof Polygon); CoordList list = new CoordList(smoothed.getCoordinates()); assertTrue(list.containsAll(coords)); Envelope polyEnv = poly.getEnvelopeInternal(); Envelope smoothEnv = smoothed.getEnvelopeInternal(); assertTrue(smoothEnv.covers(polyEnv)); }