perimeter property
double
perimeter
Returns the total length (perimeter) of the outer boundary of the polygon.
The perimeter is calculated as the sum of the distances between consecutive points in the outer polygon ring. The polygon is assumed to be closed, meaning the distance between the last point and the first point is also included in the perimeter calculation.
The distance between points is calculated using the calculateDistance method.
Returns: A double representing the total length (perimeter) of the outer boundary of the polygon, in the same units as used by calculateDistance (usually meters).
Implementation
double get perimeter {
var perimeter = 0.0;
for (var i = 0; i < coordinates[0].length - 1; i++) {
var p1 = coordinates[0][i];
var p2 = coordinates[0][i + 1];
perimeter += calculateHaversineDistance(p1[1], p1[0], p2[1], p2[0]);
}
// Add distance between the last point and the first point to close the polygon
var p1 = coordinates[0][coordinates[0].length - 1];
var p2 = coordinates[0][0];
perimeter += calculateHaversineDistance(p1[1], p1[0], p2[1], p2[0]);
return perimeter;
}