GeometryFactory gf = new GeometryFactory(); SimpleFeatureType featureType = DataUtilities.createType( Integer.valueOf(1), new Double(1.1), gf.createPoint(new Coordinate(1, 1)) }, "fid.1")); Integer.valueOf(2), new Double(2.2), gf.createPoint(new Coordinate(2, 2)) }, "fid.2")); Integer.valueOf(3), new Double(3.3), gf.createPoint(new Coordinate(3, 3)) }, "fid.3"));
public LineString toLineString(boolean includeElevation) { GeometryFactory gf = new GeometryFactory(); Coordinate[] coordinates = new Coordinate[getSize() == 1 ? 2 : getSize()]; for (int i = 0; i < getSize(); i++) { coordinates[i] = includeElevation ? new Coordinate( round6(getLongitude(i)), round6(getLatitude(i)), round2(getElevation(i))) : new Coordinate( round6(getLongitude(i)), round6(getLatitude(i))); } // special case as just 1 point is not supported in the specification #1412 if (getSize() == 1) coordinates[1] = coordinates[0]; return gf.createLineString(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; }
if (partCount == 0) { if (multitype) { return GEOMETRY_FACTORY.createMultiPolygon(); return GEOMETRY_FACTORY.createPolygon(); polygons.add(GEOMETRY_FACTORY.createPolygon(shell, holes.toArray(new LinearRing[0]))); holes.clear(); verify(holes.isEmpty(), "shell is null but holes found"); shell = GEOMETRY_FACTORY.createLinearRing(coordinates); holes.add(GEOMETRY_FACTORY.createLinearRing(coordinates)); polygons.add(GEOMETRY_FACTORY.createPolygon(shell, holes.toArray(new LinearRing[0]))); return GEOMETRY_FACTORY.createMultiPolygon(polygons.toArray(new Polygon[0]));
if (partCount == 0) { if (multitype) { return GEOMETRY_FACTORY.createMultiLineString(); return GEOMETRY_FACTORY.createLineString(); lineStrings[i] = GEOMETRY_FACTORY.createLineString(readCoordinates(input, partLengths[i])); return GEOMETRY_FACTORY.createMultiLineString(lineStrings);
/** * Get the union. * * @param r the other geometry * @return the union of this geometry envelope and another geometry envelope */ public Value getEnvelopeUnion(ValueGeometry r) { GeometryFactory gf = new GeometryFactory(); Envelope mergedEnvelope = new Envelope(getGeometryNoCopy().getEnvelopeInternal()); mergedEnvelope.expandToInclude(r.getGeometryNoCopy().getEnvelopeInternal()); return get(gf.toGeometry(mergedEnvelope)); }
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); }
GeometryFactory geometryFactory = new GeometryFactory(); QueryGraph queryGraph = new QueryGraph(graphHopperStorage); final EdgeFilter filter = DefaultEdgeFilter.allEdges(graphHopperStorage.getEncodingManager().getEncoder("foot")); MultiPoint exploredPoints = geometryFactory.createMultiPointFromCoords(z1.keySet().toArray(new Coordinate[0])); return wrap(exploredPoints); } else { router.calcLabelsAndNeighbors(queryResult.getClosestNode(), -1, initialTime, blockedRouteTypes, sptVisitor, label -> label.currentTime <= targetZ); MultiPoint exploredPointsAndNeighbors = geometryFactory.createMultiPointFromCoords(z1.keySet().toArray(new Coordinate[0])); for (Vertex vertex : (Collection<Vertex>) tin.getVertices(true)) { JsonFeature feature = new JsonFeature(); feature.setGeometry(geometryFactory.createPoint(vertex.getCoordinate())); HashMap<String, Object> properties = new HashMap<>(); properties.put("z", vertex.getZ());
public void testMixedEmptyMultiLine() throws SchemaException, IllegalAttributeException { GeometryFactory gf = new GeometryFactory(); StyleBuilder sb = new StyleBuilder(); SimpleFeatureType pointType = DataUtilities.createType("emptyRings", "geom:MultiLineString,name:String"); LineString emptyLine = gf.createLineString((Coordinate[]) null); LineString realLine = gf.createLineString(new Coordinate[] {new Coordinate(0, 0), new Coordinate(1, 1)}); MultiLineString mls = gf.createMultiLineString(new LineString[] {emptyLine, realLine}); SimpleFeature f = SimpleFeatureBuilder.build(pointType, new Object[] {mls, "name"}, null); Style style = sb.createStyle(sb.createPolygonSymbolizer()); renderEmptyGeometry(f, style); }
@Override protected Geometry getEmpty() { if (EMPTY == null) { EMPTY = new GeometryFactory().createMultiPoint((Point[]) null); } return EMPTY; }
event.setId( 1L); event.setName( "Hibernate ORM presentation"); Point point = geometryFactory.createPoint( new Coordinate( 10, 5 ) ); event.setLocation( point ); }; Polygon window = geometryFactory.createPolygon( coordinates ); Event event = entityManager.createQuery( "select e " +
@Override protected Geometry getEmpty() { if (EMPTY == null) { EMPTY = new GeometryFactory().createGeometryCollection(new Geometry[] {}); } return EMPTY; }
/** * Crops the coverage to the specified bounds * * @param coverage * @param bounds */ public static GridCoverage2D crop(final GridCoverage2D coverage, final Envelope bounds) { // checks final ReferencedEnvelope cropBounds = new ReferencedEnvelope(bounds); final ReferencedEnvelope coverageBounds = new ReferencedEnvelope(coverage.getEnvelope()); if (cropBounds.contains((org.locationtech.jts.geom.Envelope) coverageBounds)) { return coverage; } Polygon polygon = JTS.toGeometry(cropBounds); Geometry roi = polygon.getFactory().createMultiPolygon(new Polygon[] {polygon}); // perform the crops final ParameterValueGroup param = PROCESSOR.getOperation("CoverageCrop").getParameters(); param.parameter("Source").setValue(coverage); param.parameter("Envelope").setValue(bounds); param.parameter("ROI").setValue(roi); return (GridCoverage2D) PROCESSOR.doOperation(param); }
private static Point readPoint(SliceInput input) { Coordinate coordinates = readCoordinate(input); if (isNaN(coordinates.x) || isNaN(coordinates.y)) { return GEOMETRY_FACTORY.createPoint(); } return GEOMETRY_FACTORY.createPoint(coordinates); }
@Override protected Geometry getEmpty() { if (EMPTY == null) { EMPTY = new GeometryFactory().createMultiPolygon(null); } return EMPTY; }
private GeometryCollection wrap(Geometry geometry) { if (geometry instanceof Point) { return geometry.getFactory().createMultiPoint(new Point[] {(Point) geometry}); } else if (geometry instanceof LineString) { return geometry.getFactory() .createMultiLineString(new LineString[] {(LineString) geometry}); } else if (geometry instanceof Polygon) { return geometry.getFactory().createMultiPolygon(new Polygon[] {(Polygon) geometry}); } throw new IllegalArgumentException("Unable to create multi geometry from " + geometry); } }
private Geometry lineStringFromEdges(List<Label.Transition> transitions) { List<Coordinate> coordinates = new ArrayList<>(); final Iterator<Label.Transition> iterator = transitions.iterator(); iterator.next(); coordinates.addAll(toCoordinateArray(iterator.next().edge.edgeIteratorState.fetchWayGeometry(3))); iterator.forEachRemaining(transition -> coordinates.addAll(toCoordinateArray(transition.edge.edgeIteratorState.fetchWayGeometry(2)))); return geometryFactory.createLineString(coordinates.toArray(new Coordinate[coordinates.size()])); }
public void testIntersectsRingFilter() throws Exception { FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); // should match only "r1" GeometryFactory gf = new GeometryFactory(); PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory(); LineString ls = gf.createLinearRing(sf.create(new double[] {2, 1, 2, 3, 0, 3, 2, 1}, 2)); Intersects is = ff.intersects(ff.property(aname("geom")), ff.literal(ls)); FeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(is); checkSingleResult(features, "r1"); }
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()])));
@Override protected Geometry getEmpty() { if (EMPTY == null) { EMPTY = new GeometryFactory().createMultiLineString(null); } return EMPTY; }