area property

double get area

The area pf the Polygon in square meters.

Example:

Polygon polygon = Polygon([
  LinearRing([
    Coordinate(0, 0),
    Coordinate(0, 1),
    Coordinate(1, 1),
    Coordinate(1, 0),
    Coordinate(0, 0),
  ]),
]);
print(polygon.area); // 1

Implementation

double get area {
  double polyArea = 0;

  polyArea += (coordinates[0].area).abs();
  for (var hole in coordinates.sublist(1)) {
    polyArea -= (hole.area).abs();
  }

  return polyArea;
}