本文整理了Java中org.locationtech.jts.geom.GeometryFactory
类的一些代码示例,展示了GeometryFactory
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeometryFactory
类的具体详情如下:
包路径:org.locationtech.jts.geom.GeometryFactory
类名称:GeometryFactory
[英]Supplies a set of utility methods for building Geometry objects from lists of Coordinates.
Note that the factory constructor methods do not change the input coordinates in any way. In particular, they are not rounded to the supplied PrecisionModel. It is assumed that input Coordinates meet the given precision.
[中]提供一组实用方法,用于从坐标列表中构建几何体对象。
请注意,工厂构造函数方法不会以任何方式更改输入坐标。特别是,它们没有四舍五入到提供的PrecisionModel。假设输入坐标满足给定精度。
代码示例来源:origin: geoserver/geoserver
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"));
代码示例来源:origin: graphhopper/graphhopper
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);
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* 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;
}
代码示例来源:origin: prestodb/presto
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]));
代码示例来源:origin: prestodb/presto
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);
代码示例来源:origin: com.h2database/h2
/**
* 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));
}
代码示例来源:origin: geotools/geotools
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);
}
代码示例来源:origin: graphhopper/graphhopper
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());
代码示例来源:origin: geotools/geotools
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);
}
代码示例来源:origin: geotools/geotools
@Override
protected Geometry getEmpty() {
if (EMPTY == null) {
EMPTY = new GeometryFactory().createMultiPoint((Point[]) null);
}
return EMPTY;
}
代码示例来源:origin: hibernate/hibernate-orm
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 " +
代码示例来源:origin: geotools/geotools
@Override
protected Geometry getEmpty() {
if (EMPTY == null) {
EMPTY = new GeometryFactory().createGeometryCollection(new Geometry[] {});
}
return EMPTY;
}
代码示例来源:origin: geoserver/geoserver
/**
* 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);
}
代码示例来源:origin: prestodb/presto
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);
}
代码示例来源:origin: geotools/geotools
@Override
protected Geometry getEmpty() {
if (EMPTY == null) {
EMPTY = new GeometryFactory().createMultiPolygon(null);
}
return EMPTY;
}
代码示例来源:origin: geotools/geotools
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);
}
}
代码示例来源:origin: graphhopper/graphhopper
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()]));
}
代码示例来源:origin: geotools/geotools
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");
}
代码示例来源:origin: graphhopper/graphhopper
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()])));
代码示例来源:origin: geotools/geotools
@Override
protected Geometry getEmpty() {
if (EMPTY == null) {
EMPTY = new GeometryFactory().createMultiLineString(null);
}
return EMPTY;
}
内容来源于网络,如有侵权,请联系作者删除!