area2D method
Returns the area of this geometry calculated in a cartesian 2D plane.
The area is zero or a positive double value. For points and line string
the result is 0.0
, and for polygon geometries the area of an polygon
(more specifically the area represented by an exterior ring minus areas of
any interior rings or holes). Multi geometries and geometry collections
returns the sum of areas of contained geometries.
To calculate (2D) area on the surface of the earth, see spherical
extensions for Iterable<Geographic>
and PositionSeries
implemented by
the package:geobase/geodesy.dart
library.
Implementation
@override
double area2D() {
var area = 0.0;
final ext = exterior;
if (ext != null) {
// area of an exterior ring
area += ext.signedArea2D().abs();
// areas of interior rings
for (final hole in interior) {
area -= hole.signedArea2D().abs();
}
}
return area;
}