本文整理了Java中com.vividsolutions.jts.geom.GeometryFactory.createLinearRing()
方法的一些代码示例,展示了GeometryFactory.createLinearRing()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeometryFactory.createLinearRing()
方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.GeometryFactory
类名称:GeometryFactory
方法名:createLinearRing
[英]Creates a LinearRing using the given CoordinateSequence. A null or empty array creates an empty LinearRing. The points must form a closed and simple linestring.
[中]使用给定的坐标序列创建线性阵列。null或空数组将创建空的LinearRing。这些点必须形成闭合的简单线串。
代码示例来源: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
Coordinate B = getCoordinate(e.B.index);
Coordinate C = interpolate(A, B, e.A.z, e.B.z, z0);
Coordinate C1 = new Coordinate(C.x + (B.y - A.y) * 0.1, C.y + (B.x - A.x) * 0.1);
Coordinate C2 = new Coordinate(C.x - (B.y - A.y) * 0.1, C.y - (B.x - A.x) * 0.1);
debugGeom
.add(geomFactory.createLineString(new Coordinate[] { A, C, C1, C2, C, B }));
LinearRing ring = geomFactory.createLinearRing(polyPoints
.toArray(new Coordinate[polyPoints.size()]));
rings.add(ring);
代码示例来源: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(CoordinateSequence coordinates) {
return createPolygon(createLinearRing(coordinates));
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
Coordinate cB = e.getB().getCoordinates();
double k = zMetric.interpolate(e.getA().getZ(), e.getB().getZ(), z0);
Coordinate cC = new Coordinate(cA.x * (1.0 - k) + cB.x * k, cA.y * (1.0 - k) + cB.y
LinearRing ring = geometryFactory.createLinearRing(polyPoints
.toArray(new Coordinate[polyPoints.size()]));
rings.add(ring);
代码示例来源: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(Coordinate[] coordinates) {
return createPolygon(createLinearRing(coordinates));
}
代码示例来源:origin: com.vividsolutions/jts
private LinearRing createSquareHole(double x, double y, double width)
{
Coordinate[] pts = new Coordinate[]{
new Coordinate(x, y),
new Coordinate(x + width, y),
new Coordinate(x + width, y + width),
new Coordinate(x, y + width),
new Coordinate(x, y)
} ;
return geomFactory.createLinearRing(pts);
}
代码示例来源: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: org.geotools/gt-main
/**
* Creates a ring from the specified (<var>x</var>,<var>y</var>) coordinates.
* The coordinates are stored in a flat array.
*/
public LinearRing ring( int[] xy ){
Coordinate[] coords = new Coordinate[xy.length / 2];
for (int i = 0; i < xy.length; i += 2) {
coords[i / 2] = new Coordinate(xy[i], xy[i + 1]);
}
return gf.createLinearRing(coords);
}
代码示例来源: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.geotools/gt2-main
/**
* Creates a ring from the specified (<var>x</var>,<var>y</var>) coordinates.
* The coordinates are stored in a flat array.
*/
public LinearRing ring( int[] xy ){
Coordinate[] coords = new Coordinate[xy.length / 2];
for (int i = 0; i < xy.length; i += 2) {
coords[i / 2] = new Coordinate(xy[i], xy[i + 1]);
}
return gf.createLinearRing(coords);
}
代码示例来源: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: com.vividsolutions/jts-core
private LinearRing createSquareHole(double x, double y, double width)
{
Coordinate[] pts = new Coordinate[]{
new Coordinate(x, y),
new Coordinate(x + width, y),
new Coordinate(x + width, y + width),
new Coordinate(x, y + width),
new Coordinate(x, y)
} ;
return geomFactory.createLinearRing(pts);
}
代码示例来源: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
LinearRing shell = geometryFactory.createLinearRing(pts);
seqIndex++;
LinearRing hole = geometryFactory.createLinearRing(holePts);
holes.add(hole);
seqIndex++;
polys.add(geometryFactory.createPolygon(shell, holeArray));
内容来源于网络,如有侵权,请联系作者删除!