double area = CGAlgorithms.signedArea(r.getCoordinates());
double area = CGAlgorithms.signedArea(r.getCoordinates());
public SimplePointInRing(LinearRing ring) { pts = ring.getCoordinates(); }
private void normalize(LinearRing ring, boolean clockwise) { if (ring.isEmpty()) { return; } Coordinate[] uniqueCoordinates = new Coordinate[ring.getCoordinates().length - 1]; System.arraycopy(ring.getCoordinates(), 0, uniqueCoordinates, 0, uniqueCoordinates.length); Coordinate minCoordinate = CoordinateArrays.minCoordinate(ring.getCoordinates()); CoordinateArrays.scroll(uniqueCoordinates, minCoordinate); System.arraycopy(uniqueCoordinates, 0, ring.getCoordinates(), 0, uniqueCoordinates.length); ring.getCoordinates()[uniqueCoordinates.length] = uniqueCoordinates[0]; if (CGAlgorithms.isCCW(ring.getCoordinates()) == clockwise) { CoordinateArrays.reverse(ring.getCoordinates()); } }
public Coordinate[] getCoordinates() { if (isEmpty()) { return new Coordinate[]{}; } Coordinate[] coordinates = new Coordinate[getNumPoints()]; int k = -1; Coordinate[] shellCoordinates = shell.getCoordinates(); for (int x = 0; x < shellCoordinates.length; x++) { k++; coordinates[k] = shellCoordinates[x]; } for (int i = 0; i < holes.length; i++) { Coordinate[] childCoordinates = holes[i].getCoordinates(); for (int j = 0; j < childCoordinates.length; j++) { k++; coordinates[k] = childCoordinates[j]; } } return coordinates; }
/** * Compute a LinearRing from the point list previously collected. * Test if the ring is a hole (i.e. if it is CCW) and set the hole flag * accordingly. */ public void computeRing() { if (ring != null) return; // don't compute more than once Coordinate[] coord = new Coordinate[pts.size()]; for (int i = 0; i < pts.size(); i++) { coord[i] = (Coordinate) pts.get(i); } ring = geometryFactory.createLinearRing(coord); isHole = CGAlgorithms.isCCW(ring.getCoordinates()); //Debug.println( (isHole ? "hole - " : "shell - ") + WKTWriter.toLineString(new CoordinateArraySequence(ring.getCoordinates()))); } abstract public DirectedEdge getNext(DirectedEdge de);
/** * Tests whether this ring is a hole. * Due to the way the edges in the polyongization graph are linked, * a ring is a hole if it is oriented counter-clockwise. * @return <code>true</code> if this ring is a hole */ public boolean isHole() { LinearRing ring = getRing(); return CGAlgorithms.isCCW(ring.getCoordinates()); }
private int locateInPolygonRing(Coordinate p, LinearRing ring) { // bounding-box check if (! ring.getEnvelopeInternal().intersects(p)) return Location.EXTERIOR; return CGAlgorithms.locatePointInRing(p, ring.getCoordinates()); }
public boolean isNonNested() { for (int i = 0; i < rings.size(); i++) { LinearRing innerRing = (LinearRing) rings.get(i); Coordinate[] innerRingPts = innerRing.getCoordinates(); for (int j = 0; j < rings.size(); j++) { LinearRing searchRing = (LinearRing) rings.get(j); Coordinate[] searchRingPts = searchRing.getCoordinates(); if (innerRing == searchRing) continue; if (! innerRing.getEnvelopeInternal().intersects(searchRing.getEnvelopeInternal())) continue; Coordinate innerRingPt = IsValidOp.findPtNotNode(innerRingPts, searchRing, graph); Assert.isTrue(innerRingPt != null, "Unable to find a ring point not a node of the search ring"); //Coordinate innerRingPt = innerRingPts[0]; boolean isInside = CGAlgorithms.isPointInRing(innerRingPt, searchRingPts); if (isInside) { nestedPt = innerRingPt; return false; } } } return true; }
/** * 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; }
private boolean isInside(LinearRing innerRing, LinearRing searchRing) { Coordinate[] innerRingPts = innerRing.getCoordinates(); Coordinate[] searchRingPts = searchRing.getCoordinates(); if (! innerRing.getEnvelopeInternal().intersects(searchRing.getEnvelopeInternal())) return false; Coordinate innerRingPt = IsValidOp.findPtNotNode(innerRingPts, searchRing, graph); Assert.isTrue(innerRingPt != null, "Unable to find a ring point not a node of the search ring"); boolean isInside = CGAlgorithms.isPointInRing(innerRingPt, searchRingPts); if (isInside) { nestedPt = innerRingPt; return true; } return false; }
/** * Determines whether a point lies in a LinearRing, * using the ring envelope to short-circuit if possible. * * @param p the point to test * @param ring a linear ring * @return true if the point lies inside the ring */ private static boolean isPointInRing(Coordinate p, LinearRing ring) { // short-circuit if point is not in ring envelope if (! ring.getEnvelopeInternal().intersects(p)) return false; return CGAlgorithms.isPointInRing(p, ring.getCoordinates()); }
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); } }
Coordinate[] innerRingPts = innerRing.getCoordinates(); Coordinate[] searchRingPts = searchRing.getCoordinates();
Coordinate[] innerRingPts = innerRing.getCoordinates(); Coordinate[] searchRingPts = searchRing.getCoordinates();
Coordinate[] shellPts = shell.getCoordinates(); Coordinate[] holePts = hole.getCoordinates();
private void writeLinearRing(LinearRing lr, Writer writer, int level) throws IOException { startLine(level, writer); startGeomTag(GMLConstants.GML_LINEARRING, lr, writer); write(lr.getCoordinates(), writer, level + 1); startLine(level, writer); endGeomTag(GMLConstants.GML_LINEARRING, writer); }
Coordinate[] shellCoord = CoordinateArrays.removeRepeatedPoints(shell.getCoordinates()); Coordinate[] holeCoord = CoordinateArrays.removeRepeatedPoints(hole.getCoordinates());
/** * Checks validity of a LinearRing. */ private void checkValid(LinearRing g) { checkInvalidCoordinates(g.getCoordinates()); if (validErr != null) return; checkClosedRing(g); if (validErr != null) return; GeometryGraph graph = new GeometryGraph(0, g); checkTooFewPoints(graph); if (validErr != null) return; LineIntersector li = new RobustLineIntersector(); graph.computeSelfNodes(li, true); checkNoSelfIntersectingRings(graph); }
Coordinate[] coord = CoordinateArrays.removeRepeatedPoints(lr.getCoordinates());