Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wingkwong committed Jun 25, 2023
1 parent fa3e81f commit 0e627e1
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/src/geodesy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ class Geodesy {
}

/// GetRectangleBounds
List<LatLng> getRectangleBounds(List<LatLng> polygonCoords) {
num minLatitude = double.infinity.toDouble();
num maxLatitude = double.negativeInfinity.toDouble();
Expand Down Expand Up @@ -301,17 +300,17 @@ class Geodesy {
return [topLeft, bottomRight];
}

/// finds the centroid of polygons:
LatLng findPolygonCentroid(List<LatLng> polygon) {
/// finds the centroid of polygons
LatLng findPolygonCentroid(List<LatLng> polygons) {
num x = 0;
num y = 0;
num signedArea = 0;

num vertexCount = polygon.length;
num vertexCount = polygons.length;

for (int i = 0; i < vertexCount; i++) {
final LatLng currentVertex = polygon[i];
final LatLng nextVertex = polygon[(i + 1) % vertexCount.toInt()];
final LatLng currentVertex = polygons[i];
final LatLng nextVertex = polygons[(i + 1) % vertexCount.toInt()];

num a = currentVertex.longitude * nextVertex.latitude -
nextVertex.longitude * currentVertex.latitude;
Expand All @@ -323,6 +322,7 @@ class Geodesy {
signedArea *= 0.5;
x /= (6 * signedArea);
y /= (6 * signedArea);

// Return the centroid as LatLng object
return LatLng(
y.toDouble(),
Expand Down Expand Up @@ -352,7 +352,6 @@ class Geodesy {
}
}
}

return intersectionPoints;
}

Expand Down

0 comments on commit 0e627e1

Please sign in to comment.