本文整理了Java中com.vividsolutions.jts.geom.GeometryFactory.createPolygon()
方法的一些代码示例,展示了GeometryFactory.createPolygon()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeometryFactory.createPolygon()
方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.GeometryFactory
类名称:GeometryFactory
方法名:createPolygon
[英]Constructs a Polygon
with the given exterior boundary.
[中]使用给定的外部边界构造一个Polygon
。
代码示例来源:origin: stackoverflow.com
points.add(new Coordinate(-10, -10));
points.add(new Coordinate(-10, 10));
points.add(new Coordinate(10, 10));
points.add(new Coordinate(10, -10));
points.add(new Coordinate(-10, -10));
final Polygon polygon = gf.createPolygon(new LinearRing(new CoordinateArraySequence(points
.toArray(new Coordinate[points.size()])), gf), null);
代码示例来源:origin: opentripplanner/OpenTripPlanner
private Polygon toJTSPolygon(VLPolygon visibilityPolygon) {
if (visibilityPolygon.vertices.isEmpty()) {
return null;
}
// incomprehensibly, visilibity's routines for figuring out point-polygon containment are
// too broken
// to use here, so we have to fall back to JTS.
Coordinate[] coordinates = new Coordinate[visibilityPolygon.n() + 1];
for (int p = 0; p < coordinates.length; ++p) {
VLPoint vlPoint = visibilityPolygon.get(p);
coordinates[p] = new Coordinate(vlPoint.x, vlPoint.y);
}
LinearRing shell = GeometryUtils.getGeometryFactory().createLinearRing(coordinates);
Polygon poly = GeometryUtils.getGeometryFactory().createPolygon(shell, new LinearRing[0]);
return poly;
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
shell = factory.createLinearRing(toCoordinates(geometry));
} catch (IllegalArgumentException e) {
throw new RingConstructionException();
LinearRing linearRing = factory.createLinearRing(toCoordinates(ring.geometry));
Polygon polygon = factory.createPolygon(linearRing, new LinearRing[0]);
for (Iterator<Polygon> it = polygonHoles.iterator(); it.hasNext();) {
Polygon otherHole = it.next();
LinearRing ring = factory.createLinearRing(line.getCoordinates());
lrholelist.add(ring);
jtsPolygon = factory.createPolygon(shell, lrholes);
return jtsPolygon;
代码示例来源:origin: opentripplanner/OpenTripPlanner
if (geoJsonGeom instanceof org.geojson.Point) {
org.geojson.Point geoJsonPoint = (org.geojson.Point) geoJsonGeom;
return gf.createPoint(new Coordinate(geoJsonPoint.getCoordinates().getLongitude(), geoJsonPoint
.getCoordinates().getLatitude()));
LinearRing shell = gf.createLinearRing(convertPath(geoJsonPolygon.getExteriorRing()));
LinearRing[] holes = new LinearRing[geoJsonPolygon.getInteriorRings().size()];
int i = 0;
for (List<LngLatAlt> hole : geoJsonPolygon.getInteriorRings()) {
holes[i++] = gf.createLinearRing(convertPath(hole));
return gf.createPolygon(shell, holes);
代码示例来源:origin: com.vividsolutions/jts
/**
* Constructs a <code>Polygon</code> with the given exterior boundary.
*
* @param shell
* the outer boundary of the new <code>Polygon</code>, or
* <code>null</code> or an empty <code>LinearRing</code> if
* the empty geometry is to be created.
* @throws IllegalArgumentException if the boundary ring is invalid
*/
public Polygon createPolygon(Coordinate[] coordinates) {
return createPolygon(createLinearRing(coordinates));
}
代码示例来源:origin: org.n52.shetland/shetland
public static Geometry createPolygonFromEnvelope(double minx, double miny, double maxx, double maxy, int srid) {
GeometryFactory fac = getGeometryFactoryForSRID(srid);
return fac.createPolygon(new Coordinate[] {
new Coordinate(minx, miny),
new Coordinate(minx, maxy),
new Coordinate(maxx, maxy),
new Coordinate(maxx, miny),
new Coordinate(minx, miny) });
}
代码示例来源:origin: com.vividsolutions/jts
pts[iPt++] = coord(x, y);
pts[iPt] = new Coordinate(pts[0]);
LinearRing ring = geomFact.createLinearRing(pts);
Polygon poly = geomFact.createPolygon(ring, null);
return poly;
代码示例来源:origin: com.vividsolutions/jts
/**
* Constructs a <code>Polygon</code> with the given exterior boundary.
*
* @param shell
* the outer boundary of the new <code>Polygon</code>, or
* <code>null</code> or an empty <code>LinearRing</code> if
* the empty geometry is to be created.
* @throws IllegalArgumentException if the boundary ring is invalid
*/
public Polygon createPolygon(CoordinateSequence coordinates) {
return createPolygon(createLinearRing(coordinates));
}
代码示例来源:origin: matsim-org/matsim
private Geometry createBounds() {
if (bounds != null)
return bounds;
double[] box = NetworkUtils.getBoundingBox(network.getNodes().values());
return factory.createPolygon(new Coordinate[]{
new Coordinate(box[0], box[1]),
new Coordinate(box[2], box[1]),
new Coordinate(box[2], box[3]),
new Coordinate(box[0], box[3]),
new Coordinate(box[0], box[1])});
}
}
代码示例来源:origin: com.vividsolutions/jts
/**
* Creates an elliptical {@link Polygon}.
* If the supplied envelope is square the
* result will be a circle.
*
* @return an ellipse or circle
*/
public Polygon createEllipse()
{
Envelope env = dim.getEnvelope();
double xRadius = env.getWidth() / 2.0;
double yRadius = env.getHeight() / 2.0;
double centreX = env.getMinX() + xRadius;
double centreY = env.getMinY() + yRadius;
Coordinate[] pts = new Coordinate[nPts + 1];
int iPt = 0;
for (int i = 0; i < nPts; i++) {
double ang = i * (2 * Math.PI / nPts);
double x = xRadius * Math.cos(ang) + centreX;
double y = yRadius * Math.sin(ang) + centreY;
pts[iPt++] = coord(x, y);
}
pts[iPt] = new Coordinate(pts[0]);
LinearRing ring = geomFact.createLinearRing(pts);
Polygon poly = geomFact.createPolygon(ring, null);
return (Polygon) rotate(poly);
}
/**
代码示例来源:origin: com.vividsolutions/jts
public Polygon getGeometry(GeometryFactory fact) {
LinearRing ring = fact.createLinearRing(getCoordinates());
Polygon tri = fact.createPolygon(ring, null);
return tri;
}
代码示例来源:origin: sinergise/Sentinel2ProductIngestor
private static Polygon toJts(List<LngLatAlt> geoJsonExtRing, GeometryFactory gf) {
List<Coordinate> coordinates = geoJsonExtRing.stream()
.map(lla -> new Coordinate(lla.getLongitude(), lla.getLatitude())).collect(Collectors.toList());
return gf.createPolygon(coordinates.toArray(new Coordinate[coordinates.size()]));
}
代码示例来源:origin: com.vividsolutions/jts
pts[8 * nSegsInOct - i] = coordTrans(-x, y, centre);
pts[pts.length-1] = new Coordinate(pts[0]);
LinearRing ring = geomFact.createLinearRing(pts);
Polygon poly = geomFact.createPolygon(ring, null);
return (Polygon) rotate(poly);
代码示例来源:origin: com.vividsolutions/jts
/**
* Gets the geometry for the triangles in a triangulated subdivision as a {@link GeometryCollection}
* of triangular {@link Polygon}s.
*
* @param geomFact the GeometryFactory to use
* @return a GeometryCollection of triangular Polygons
*/
public Geometry getTriangles(GeometryFactory geomFact) {
List triPtsList = getTriangleCoordinates(false);
Polygon[] tris = new Polygon[triPtsList.size()];
int i = 0;
for (Iterator it = triPtsList.iterator(); it.hasNext();) {
Coordinate[] triPt = (Coordinate[]) it.next();
tris[i++] = geomFact
.createPolygon(geomFact.createLinearRing(triPt), null);
}
return geomFact.createGeometryCollection(tris);
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
public static GeometryType makeEnvelope(double xmin, double ymin,
double xmax, double ymax, Integer srid) {
Geometry geom = GEOMETRY_FACTORY.createPolygon(new Coordinate[] {new Coordinate(xmin, ymin), new Coordinate(xmin, ymax), new Coordinate(xmax, ymax), new Coordinate(xmax, ymin), new Coordinate(xmin, ymin)});
if (srid != null) {
geom.setSRID(srid);
}
return getGeometryType(geom);
}
代码示例来源:origin: com.vividsolutions/jts
Coordinate px00 = new Coordinate(minX, minA - minX);
Coordinate px01 = new Coordinate(minX, minX - minB);
Coordinate px10 = new Coordinate(maxX, maxX - maxB);
Coordinate px11 = new Coordinate(maxX, maxA - maxX);
return geomFactory.createPolygon(geomFactory.createLinearRing(pts), null);
代码示例来源:origin: com.vividsolutions/jts
/**
*@param vertices the vertices of a linear ring, which may or may not be
* flattened (i.e. vertices collinear)
*@return a 2-vertex <code>LineString</code> if the vertices are
* collinear; otherwise, a <code>Polygon</code> with unnecessary
* (collinear) vertices removed
*/
private Geometry lineOrPolygon(Coordinate[] coordinates) {
coordinates = cleanRing(coordinates);
if (coordinates.length == 3) {
return geomFactory.createLineString(new Coordinate[]{coordinates[0], coordinates[1]});
// return new LineString(new Coordinate[]{coordinates[0], coordinates[1]},
// geometry.getPrecisionModel(), geometry.getSRID());
}
LinearRing linearRing = geomFactory.createLinearRing(coordinates);
return geomFactory.createPolygon(linearRing, null);
}
代码示例来源:origin: org.teiid/teiid-engine
public static GeometryType makeEnvelope(double xmin, double ymin,
double xmax, double ymax, Integer srid) {
Geometry geom = GEOMETRY_FACTORY.createPolygon(new Coordinate[] {new Coordinate(xmin, ymin), new Coordinate(xmin, ymax), new Coordinate(xmax, ymax), new Coordinate(xmax, ymin), new Coordinate(xmin, ymin)});
if (srid != null) {
geom.setSRID(srid);
}
return getGeometryType(geom);
}
代码示例来源:origin: com.vividsolutions/jts
return createPoint(new Coordinate(envelope.getMinX(), envelope.getMinY()));
|| envelope.getMinY() == envelope.getMaxY()) {
return createLineString(new Coordinate[]{
new Coordinate(envelope.getMinX(), envelope.getMinY()),
new Coordinate(envelope.getMaxX(), envelope.getMaxY())
});
return createPolygon(createLinearRing(new Coordinate[]{
new Coordinate(envelope.getMinX(), envelope.getMinY()),
new Coordinate(envelope.getMinX(), envelope.getMaxY()),
代码示例来源:origin: com.vividsolutions/jts
public static Geometry toPolygon(Vertex[] v) {
Coordinate[] ringPts = new Coordinate[] { v[0].getCoordinate(),
v[1].getCoordinate(), v[2].getCoordinate(), v[0].getCoordinate() };
GeometryFactory fact = new GeometryFactory();
LinearRing ring = fact.createLinearRing(ringPts);
Polygon tri = fact.createPolygon(ring, null);
return tri;
}
内容来源于网络,如有侵权,请联系作者删除!