Refine search
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; }
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;
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);
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);
/** * 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)); }
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);
pts[iPt++] = coord(x, y); pts[iPt] = new Coordinate(pts[0]); LinearRing ring = geomFact.createLinearRing(pts); Polygon poly = geomFact.createPolygon(ring, null); return poly;
/** * 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)); }
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); }
/** * 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); } /**
public Polygon getGeometry(GeometryFactory fact) { LinearRing ring = fact.createLinearRing(getCoordinates()); Polygon tri = fact.createPolygon(ring, null); return tri; }
/** * 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); }
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);
/** * 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); }
/** * 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); }
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);
/** *@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); }
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); }
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()),
LinearRing shell = geometryFactory.createLinearRing(pts); seqIndex++; LinearRing hole = geometryFactory.createLinearRing(holePts); holes.add(hole); seqIndex++; polys.add(geometryFactory.createPolygon(shell, holeArray));