private boolean isHole(Coordinate[] pts) { return CGAlgorithms.isCCW(pts); }
/** * 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 void addShell(Coordinate[] pts) { boolean isPositiveArea = ! CGAlgorithms.isCCW(pts); for (int i = 0; i < pts.length - 1; i++) { addTriangle(basePt, pts[i], pts[i+1], isPositiveArea); } addLinearSegments(pts); } private void addHole(Coordinate[] pts)
private void addHole(Coordinate[] pts) { boolean isPositiveArea = CGAlgorithms.isCCW(pts); for (int i = 0; i < pts.length - 1; i++) { addTriangle(basePt, pts[i], pts[i+1], isPositiveArea); } addLinearSegments(pts); } private void addTriangle(Coordinate p0, Coordinate p1, Coordinate p2, boolean isPositiveArea)
/** * Adds an offset curve for a polygon ring. * The side and left and right topological location arguments * assume that the ring is oriented CW. * If the ring is in the opposite orientation, * the left and right locations must be interchanged and the side flipped. * * @param coord the coordinates of the ring (must not contain repeated points) * @param offsetDistance the distance at which to create the buffer * @param side the side of the ring on which to construct the buffer line * @param cwLeftLoc the location on the L side of the ring (if it is CW) * @param cwRightLoc the location on the R side of the ring (if it is CW) */ private void addPolygonRing(Coordinate[] coord, double offsetDistance, int side, int cwLeftLoc, int cwRightLoc) { // don't bother adding ring if it is "flat" and will disappear in the output if (offsetDistance == 0.0 && coord.length < LinearRing.MINIMUM_VALID_SIZE) return; int leftLoc = cwLeftLoc; int rightLoc = cwRightLoc; if (coord.length >= LinearRing.MINIMUM_VALID_SIZE && CGAlgorithms.isCCW(coord)) { leftLoc = cwRightLoc; rightLoc = cwLeftLoc; side = Position.opposite(side); } Coordinate[] curve = curveBuilder.getRingCurve(coord, side, offsetDistance); addCurve(curve, leftLoc, rightLoc); }
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()); } }
if (CGAlgorithms.isCCW(coord)) { left = cwRight; right = cwLeft;
private boolean isHole(Coordinate[] pts) { return CGAlgorithms.isCCW(pts); }
/** * Computes 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. */ public void computeHole() { LinearRing ring = getRing(); isHole = CGAlgorithms.isCCW(ring.getCoordinates()); }
private void addShell(Coordinate[] pts) { boolean isPositiveArea = ! CGAlgorithms.isCCW(pts); for (int i = 0; i < pts.length - 1; i++) { addTriangle(basePt, pts[i], pts[i+1], isPositiveArea); } addLinearSegments(pts); } private void addHole(Coordinate[] pts)
private void addHole(Coordinate[] pts) { boolean isPositiveArea = CGAlgorithms.isCCW(pts); for (int i = 0; i < pts.length - 1; i++) { addTriangle(basePt, pts[i], pts[i+1], isPositiveArea); } addLinearSegments(pts); } private void addTriangle(Coordinate p0, Coordinate p1, Coordinate p2, boolean isPositiveArea)
private void addHole(Coordinate[] pts) { boolean isPositiveArea = CGAlgorithms.isCCW(pts); for (int i = 0; i < pts.length - 1; i++) { addTriangle(areaBasePt, pts[i], pts[i+1], isPositiveArea); } addLineSegments(pts); } private void addTriangle(Coordinate p0, Coordinate p1, Coordinate p2, boolean isPositiveArea)
private boolean isCCW(int idTri) { return CGAlgorithms.isCCW(inputTriangles.getGeometryN(idTri).getCoordinates()); }
private void addShell(Coordinate[] pts) { if (pts.length > 0) setBasePoint(pts[0]); boolean isPositiveArea = ! CGAlgorithms.isCCW(pts); for (int i = 0; i < pts.length - 1; i++) { addTriangle(areaBasePt, pts[i], pts[i+1], isPositiveArea); } addLineSegments(pts); }
private static boolean isCCW( LinearRing c ) { Points ps = c.getControlPoints(); Coordinate[] cs = new Coordinate[ps.size()]; int i = 0; for ( Point p : ps ) { cs[i++] = new Coordinate( p.get0(), p.get1() ); } return CGAlgorithms.isCCW( cs ); }
private static Ring fixOrientation( Ring ring, boolean forceClockwise ) { if ( ring.getRingType() != LinearRing ) { throw new UnsupportedOperationException(); } LinearRing jtsRing = (LinearRing) ( (AbstractDefaultGeometry) ring ).getJTSGeometry(); Coordinate[] coords = jtsRing.getCoordinates(); // TODO check if inversions can be applied in any case (i.e. whether JTS has a guaranteed orientation of // intersection result polygons) boolean needsInversion = isCCW( coords ) == forceClockwise; if ( needsInversion ) { return invertOrientation( ring ); } return ring; }
void setAll(Coordinate p0, Coordinate p1, Coordinate p2, double m1, double m2, double m3) { setCoordinates(p0, p1, p2); setMarkers(m1, m2, m3); if (!CGAlgorithms.isCCW(this.getRing())) { this.setCoordinates(p2, p1, p0); this.m1 = m3; this.m3 = m1; } }
void setAll(Coordinate p0, Coordinate p1, Coordinate p2, double m1, double m2, double m3) { setCoordinates(p0, p1, p2); setMarkers(m1, m2, m3); if (!CGAlgorithms.isCCW(this.getRing())) { this.setCoordinates(p2, p1, p0); this.m1 = m3; this.m3 = m1; } }
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()); } }