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 the area defined by an array of * coordinates. The array must be a ring; * i.e. end with the same coordinate as it starts with. * @param ring an array of {@link Coordinate}s */ public void add(Coordinate[] ring) { setBasePoint(ring[0]); addShell(ring); }
private void addTriangle(Coordinate p0, Coordinate p1, Coordinate p2, boolean isPositiveArea) { double sign = (isPositiveArea) ? 1.0 : -1.0; centroid3( p0, p1, p2, triangleCent3 ); double area2 = area2( p0, p1, p2 ); cg3.x += sign * area2 * triangleCent3.x; cg3.y += sign * area2 * triangleCent3.y; areasum2 += sign * area2; } /**
/** * Adds the area defined by a Geometry to the centroid total. * If the geometry has no area it does not contribute to the centroid. * * @param geom the geometry to add */ public void add(Geometry geom) { if (geom instanceof Polygon) { Polygon poly = (Polygon) geom; setBasePoint(poly.getExteriorRing().getCoordinateN(0)); add(poly); } else if (geom instanceof GeometryCollection) { GeometryCollection gc = (GeometryCollection) geom; for (int i = 0; i < gc.getNumGeometries(); i++) { add(gc.getGeometryN(i)); } } }
CentroidArea cent = new CentroidArea(); cent.add(this); centPt = cent.getCentroid();
/** * Adds the area defined by a Geometry to the centroid total. * If the geometry has no area it does not contribute to the centroid. * * @param geom the geometry to add */ public void add(Geometry geom) { if (geom instanceof Polygon) { Polygon poly = (Polygon) geom; setBasePoint(poly.getExteriorRing().getCoordinateN(0)); add(poly); } else if (geom instanceof GeometryCollection) { GeometryCollection gc = (GeometryCollection) geom; for (int i = 0; i < gc.getNumGeometries(); i++) { add(gc.getGeometryN(i)); } } }
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)
/** * Adds the area defined by an array of * coordinates. The array must be a ring; * i.e. end with the same coordinate as it starts with. * @param ring an array of {@link Coordinate}s */ public void add(Coordinate[] ring) { setBasePoint(ring[0]); addShell(ring); }
private void addTriangle(Coordinate p0, Coordinate p1, Coordinate p2, boolean isPositiveArea) { double sign = (isPositiveArea) ? 1.0 : -1.0; centroid3( p0, p1, p2, triangleCent3 ); double area2 = area2( p0, p1, p2 ); cg3.x += sign * area2 * triangleCent3.x; cg3.y += sign * area2 * triangleCent3.y; areasum2 += sign * area2; } /**
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)