@Test public void testAreaMultiPolygon() { Polygon poly1 = gf.createPolygon(constructRing( 0, 0, 0, 1, 1, 1, 1, 0, 0, 0 )); Polygon poly2 = gf.createPolygon(constructRing( 2, 0, 2, 1, 3, 1, 3, 0, 2, 0 )); MultiPolygon mpoly = gf.createMultiPolygon(new Polygon[] { poly1, poly2 }); assertEquals(2.0, Geo.areaOf(mpoly) / Geo.areaOf(poly1), 0.0001); }
public static double areaOf(Polygon poly) { double area = 0.0; area += Math.abs(ringArea((LinearRing) poly.getExteriorRing())); for (int i = 0; i < poly.getNumInteriorRing(); i++) { area -= Math.abs(ringArea((LinearRing) poly.getInteriorRingN(i))); } return area; }
Geo { public static double areaOf(Polygon poly) { double area = 0.0; area += Math.abs(ringArea((LinearRing) poly.getExteriorRing())); for (int i = 0; i < poly.getNumInteriorRing(); i++) { area -= Math.abs(ringArea((LinearRing) poly.getInteriorRingN(i))); } return area; } }
Geo { public static double areaOf(Polygon poly) { double area = 0.0; area += Math.abs(ringArea((LinearRing) poly.getExteriorRing())); for (int i = 0; i < poly.getNumInteriorRing(); i++) { area -= Math.abs(ringArea((LinearRing) poly.getInteriorRingN(i))); } return area; }  }
Geo { public static double areaOf(Polygon poly) { double area = 0.0; area += Math.abs(ringArea((LinearRing) poly.getExteriorRing())); for (int i = 0; i < poly.getNumInteriorRing(); i++) { area -= Math.abs(ringArea((LinearRing) poly.getInteriorRingN(i))); } return area; }  static double distanceBetweenCoordinatesHaversine(
      double lat1, double lng1, double lat2, double lng2
  ); static double distanceBetweenCoordinates(
      double lat1, double lng1, double lat2, double lng2
  ); static double lengthOf(LineString line); static double lengthOf(MultiLineString multiline); static double lengthOf(GeometryCollection geometryCollection); static double lengthOf(Geometry geom); static double areaOf(Polygon poly); static double areaOf(MultiPolygon multipoly); static double areaOf(GeometryCollection geometryCollection); static double areaOf(Geometry geom); static double ringArea(LinearRing ring); static Geometry clip(Geometry obj, OSHDBBoundingBox bbox); static Geometry clip(Geometry obj, P poly); }
Geo { public static double areaOf(Polygon poly) { double area = 0.0; area += Math.abs(ringArea((LinearRing) poly.getExteriorRing())); for (int i = 0; i < poly.getNumInteriorRing(); i++) { area -= Math.abs(ringArea((LinearRing) poly.getInteriorRingN(i))); } return area; }  static double distanceBetweenCoordinatesHaversine(
      double lat1, double lng1, double lat2, double lng2
  ); static double distanceBetweenCoordinates(
      double lat1, double lng1, double lat2, double lng2
  ); static double lengthOf(LineString line); static double lengthOf(MultiLineString multiline); static double lengthOf(GeometryCollection geometryCollection); static double lengthOf(Geometry geom); static double areaOf(Polygon poly); static double areaOf(MultiPolygon multipoly); static double areaOf(GeometryCollection geometryCollection); static double areaOf(Geometry geom); static double ringArea(LinearRing ring); static Geometry clip(Geometry obj, OSHDBBoundingBox bbox); static Geometry clip(Geometry obj, P poly); static double earthRadius; }