Refine search
/** * This method will cause the ring to be computed. * It will also check any holes, if they have been assigned. */ public boolean containsPoint(Coordinate p) { LinearRing shell = getLinearRing(); Envelope env = shell.getEnvelopeInternal(); if (! env.contains(p)) return false; if (! CGAlgorithms.isPointInRing(p, shell.getCoordinates()) ) return false; for (Iterator i = holes.iterator(); i.hasNext(); ) { EdgeRing hole = (EdgeRing) i.next(); if (hole.containsPoint(p) ) return false; } return true; }
if (CGAlgorithms.signedArea(ring.getCoordinateSequence()) > 0.0) holes.add(ring); else shells.add(geomFactory.createPolygon(ring)); shell.setUserData(new ArrayList<LinearRing>()); if (shell.contains(hole)) { ((List<LinearRing>) shell.getUserData()).add(hole); break outer; for (Polygon shell : shells) { List<LinearRing> shellHoles = ((List<LinearRing>) shell.getUserData()); punched.add(geomFactory.createPolygon((LinearRing) (shell.getExteriorRing()), shellHoles.toArray(new LinearRing[shellHoles.size()])));
LinearRing lr = new LinearRing(merge.getCoordinateSequence(), this.geomFactory); Polygon concaveHull = new Polygon(lr, null, this.geomFactory); return concaveHull;
double area = CGAlgorithms.signedArea(r.getCoordinates()); if (!r.isRing()) { continue; // sanity check, could probably be handled in a isSimple() check polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[holes.size()]))); holes.clear(); polygons.add(geomFactory.createPolygon(outerPoly, holes.toArray(new LinearRing[holes.size()])));
public Geometry reverse() { Polygon poly = (Polygon) super.clone(); poly.shell = (LinearRing) ((LinearRing) shell.clone()).reverse(); poly.holes = new LinearRing[holes.length]; for (int i = 0; i < holes.length; i++) { poly.holes[i] = (LinearRing) ((LinearRing) holes[i].clone()).reverse(); } return poly;// return the clone } }
private int locateInPolygonRing(Coordinate p, LinearRing ring) { // bounding-box check if (! ring.getEnvelopeInternal().intersects(p)) return Location.EXTERIOR; return CGAlgorithms.locatePointInRing(p, ring.getCoordinates()); }
@Override public void encodeGeometryValue(Geometry value, int srid, StringBuffer sql) throws IOException { if (value == null || value.isEmpty()) { sql.append("NULL"); } else { if (value instanceof LinearRing) { //postgis does not handle linear rings, convert to just a line string value = value.getFactory().createLineString(((LinearRing) value).getCoordinateSequence()); } sql.append("ST_GeomFromText('" + value.toText() + "', " + srid + ")"); } }
GeometryFactory factory = source.getFactory(); Geometry union = source.union(CascadedPolygonUnion.union(neighbors)); for (int index = 0; index < union.getNumGeometries(); index++) { Polygon poly = (Polygon) union.getGeometryN(index); for (int i = 0; i < poly.getNumInteriorRing(); i++) { LinearRing hole = (LinearRing) poly.getInteriorRingN(i); if (prepared.disjoint(hole)) { continue; slivers.add(factory.createPolygon((LinearRing) hole.reverse())); for (int index = 0; index < source.getNumGeometries(); index++) { Polygon poly = (Polygon) source.getGeometryN(index); for (int i = 0; i < poly.getNumInteriorRing(); i++) { LinearRing hole = (LinearRing) poly.getInteriorRingN(i); interiors.add(factory.createPolygon((LinearRing) hole.reverse())); eliminated = eliminated.difference(source.getFactory().buildGeometry(interiors));
if (getNumInteriorRing() != 0) return false; if (shell == null) return false; if (shell.getNumPoints() != 5) return false; CoordinateSequence seq = shell.getCoordinateSequence(); Envelope env = getEnvelopeInternal(); for (int i = 0; i < 5; i++) { double x = seq.getX(i); if (! (x == env.getMinX() || x == env.getMaxX())) return false; double y = seq.getY(i); if (! (y == env.getMinY() || y == env.getMaxY())) return false;
Coordinate[] shellPts = shell.getCoordinates(); LinearRing polyShell = (LinearRing) p.getExteriorRing(); Coordinate[] polyPts = polyShell.getCoordinates(); Coordinate shellPt = findPtNotNode(shellPts, polyShell, graph); boolean insidePolyShell = CGAlgorithms.isPointInRing(shellPt, polyPts); if (! insidePolyShell) return; if (p.getNumInteriorRing() <= 0) { validErr = new TopologyValidationError( TopologyValidationError.NESTED_SHELLS, for (int i = 0; i < p.getNumInteriorRing(); i++) { LinearRing hole = (LinearRing) p.getInteriorRingN(i); badNestedPt = checkShellInsideHole(shell, hole, graph);
if (ring.isSimple()) { return ring.getFactory().createMultiPolygon(new Polygon[]{ ring.getFactory().createPolygon(ring, EMPTY_RING_ARRAY) }); } else { Set<LineString> lines = nodeLineString(ring.getCoordinates(), ring.getFactory()); lines = getSegments(lines); for (Object object : polygonizer.getPolygons()) { Polygon polygon = (Polygon) object; Coordinate p = polygon.getInteriorPoint().getCoordinate(); int location = RayCrossingCounter.locatePointInRing(p, ring.getCoordinateSequence()); if (location == Location.INTERIOR) { geoms.add(polygon); Geometry unionLines = UnaryUnionOp.union(lines).difference(unionPoly.getBoundary()); geoms.clear(); decompose(unionPoly, geoms); decompose(unionLines, geoms); return ring.getFactory().buildGeometry(geoms);
public final Geometry edit(Geometry geometry, GeometryFactory factory) { if (geometry instanceof LinearRing) { return factory.createLinearRing(edit( ((LinearRing)geometry).getCoordinateSequence(), geometry)); } if (geometry instanceof LineString) { return factory.createLineString(edit( ((LineString)geometry).getCoordinateSequence(), geometry)); } if (geometry instanceof Point) { return factory.createPoint(edit( ((Point)geometry).getCoordinateSequence(), geometry)); } return geometry; }
polygons[i] = geometryFactory.createPolygon(shells.get(i), hole.toArray(new LinearRing[hole.size()])); for (int i = 0, ii = holes.size(); i < ii; i++) { LinearRing hole = holes.get(i); polygons[i] = geometryFactory.createPolygon((LinearRing) hole.reverse(), new LinearRing[0]); Geometry g = geometryFactory.createMultiPolygon(polygons);
/** * Computes the boundary of this geometry * * @return a lineal geometry (which may be empty) * @see Geometry#getBoundary */ public Geometry getBoundary() { if (isEmpty()) { return getFactory().createMultiLineString(null); } LinearRing[] rings = new LinearRing[holes.length + 1]; rings[0] = shell; for (int i = 0; i < holes.length; i++) { rings[i + 1] = holes[i]; } // create LineString or MultiLineString as appropriate if (rings.length <= 1) return getFactory().createLinearRing(rings[0].getCoordinateSequence()); return getFactory().createMultiLineString(rings); }
/** * Transforms a LinearRing. * The transformation of a LinearRing may result in a coordinate sequence * which does not form a structurally valid ring (i.e. a degnerate ring of 3 or fewer points). * In this case a LineString is returned. * Subclasses may wish to override this method and check for this situation * (e.g. a subclass may choose to eliminate degenerate linear rings) * * @param geom the ring to simplify * @param parent the parent geometry * @return a LinearRing if the transformation resulted in a structurally valid ring * @return a LineString if the transformation caused the LinearRing to collapse to 3 or fewer points */ protected Geometry transformLinearRing(LinearRing geom, Geometry parent) { CoordinateSequence seq = transformCoordinates(geom.getCoordinateSequence(), geom); int seqSize = seq.size(); // ensure a valid LinearRing if (seqSize > 0 && seqSize < 4 && ! preserveType) return factory.createLineString(seq); return factory.createLinearRing(seq); }
/** * Does what it says, reverses the order of the Coordinates in the ring. * <p> * This is different then lr.reverses() in that a copy is produced using a * new coordinate sequence. * </p> * @param lr * The ring to reverse. * @return A new ring with the reversed Coordinates. */ public static final LinearRing reverseRing(LinearRing lr) { GeometryFactory gf = lr.getFactory(); CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory(); CoordinateSequence csOrig = lr.getCoordinateSequence(); int numPoints = csOrig.size(); int dimensions = csOrig.getDimension(); CoordinateSequence csNew = csf.create(numPoints, dimensions); for (int i = 0; i < numPoints; i++) { for (int j = 0; j < dimensions; j++) { csNew.setOrdinate(numPoints-1-i, j, csOrig.getOrdinate(i, j)); } } return gf.createLinearRing(csNew); }
private void buildIndex() { //Envelope env = ring.getEnvelopeInternal(); tree = new Bintree(); Coordinate[] pts = CoordinateArrays.removeRepeatedPoints(ring.getCoordinates()); List mcList = MonotoneChainBuilder.getChains(pts); for (int i = 0; i < mcList.size(); i++) { MonotoneChain mc = (MonotoneChain) mcList.get(i); Envelope mcEnv = mc.getEnvelope(); interval.min = mcEnv.getMinY(); interval.max = mcEnv.getMaxY(); tree.insert(interval, mc); } }
private void buildIndex() { sweepLine = new SweepLineIndex(); for (int i = 0; i < rings.size(); i++) { LinearRing ring = (LinearRing) rings.get(i); Envelope env = ring.getEnvelopeInternal(); SweepLineInterval sweepInt = new SweepLineInterval(env.getMinX(), env.getMaxX(), ring); sweepLine.add(sweepInt); } }
protected static Geometry transformLinearRing(CoordinateTransform ct, LinearRing linearRing) { return linearRing.getFactory().createLinearRing(transformCoordinates(ct, linearRing.getCoordinates())); }
public void filter(Geometry geom) { if (isForcedToLineString && geom instanceof LinearRing) { LineString line = geom.getFactory().createLineString( ((LinearRing) geom).getCoordinateSequence()); lines.add(line); return; } // if not being forced, and this is a linear component if (geom instanceof LineString) lines.add(geom); // else this is not a linear component, so skip it }