areaSquareMeters property
Calculates the approximate area of the polygon in square meters.
Uses the Shoelace formula with geodesic corrections.
Implementation
double get areaSquareMeters {
if (vertices.length < 3) return 0;
// Earth's radius in meters
const earthRadius = 6371000.0;
// Convert to radians and use spherical excess formula
double area = 0;
final n = vertices.length;
for (int i = 0; i < n; i++) {
final j = (i + 1) % n;
final lat1 = vertices[i].latitude * math.pi / 180;
final lng1 = vertices[i].longitude * math.pi / 180;
final lat2 = vertices[j].latitude * math.pi / 180;
final lng2 = vertices[j].longitude * math.pi / 180;
area += (lng2 - lng1) * (2 + math.sin(lat1) + math.sin(lat2));
}
area = (area * earthRadius * earthRadius / 2).abs();
return area;
}