Skip to content

Commit 9936fae

Browse files
committed
refactor: Minor code style and readability improvements
This commit includes minor code cleanup across several files: - Removes extra newlines in `GeoJson*`, and `Layer` classes. - Fixes indentation in `PolyUtil`. - Improves readability in `SphericalUtil.computeSignedArea`
1 parent a0fbc94 commit 9936fae

7 files changed

Lines changed: 6 additions & 14 deletions

File tree

library/src/main/java/com/google/maps/android/PolyUtil.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ object PolyUtil {
301301
* simplified poly.
302302
* @return a simplified poly produced by the Douglas-Peucker algorithm
303303
*/
304-
@JvmStatic
304+
@JvmStatic
305305
fun simplify(poly: Polyline, tolerance: Double): Polyline {
306306
require(poly.isNotEmpty()) { "Polyline must have at least 1 point" }
307307
require(tolerance > 0) { "Tolerance must be greater than zero" }

library/src/main/java/com/google/maps/android/SphericalUtil.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ object SphericalUtil {
240240
@JvmStatic
241241
fun computeSignedArea(path: Polygon) = computeSignedArea(path, EARTH_RADIUS)
242242

243-
244243
/**
245244
* Returns the signed area of a closed path on a sphere of given radius.
246245
* The computed area uses the same units as the radius squared.
@@ -261,9 +260,12 @@ object SphericalUtil {
261260
return polarTriangleArea(tanLat1, lng2, tanLat2, lng1)
262261
}
263262

263+
// Create a sequence of edges, including the final edge that closes the polygon.
264+
// Using a sequence avoids creating an intermediate list.
265+
val edges = path.asSequence().zipWithNext() + (path.last() to path.first())
266+
264267
// Use a sequence to avoid creating intermediate lists
265-
val totalArea = (path.asSequence().zipWithNext() + (path.last() to path.first()))
266-
.sumOf { (p1, p2) -> polarArea(p1, p2) }
268+
val totalArea = edges.sumOf { (p1, p2) -> polarArea(p1, p2) }
267269

268270
return totalArea * (radius * radius)
269271
}

library/src/main/java/com/google/maps/android/data/Layer.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ abstract class Layer<T : Feature> {
103103
return renderer?.features ?: emptyList()
104104
}
105105

106-
107106
/**
108107
* Retrieves a corresponding Feature instance for the given Object
109108
* Allows maps with multiple layers to determine which layer the Object
@@ -145,7 +144,6 @@ abstract class Layer<T : Feature> {
145144
return (renderer as? KmlRenderer)?.nestedContainers
146145
}
147146

148-
149147
/**
150148
* Gets an iterable of KmlGroundOverlay objects
151149
*

library/src/main/java/com/google/maps/android/data/geojson/GeoJsonGeometryCollection.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ public String getGeometryType() {
3838
return "GeometryCollection";
3939
}
4040

41-
42-
4341
/**
4442
* Gets the stored Geometry objects
4543
*

library/src/main/java/com/google/maps/android/data/geojson/GeoJsonMultiLineString.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ public String getGeometryType() {
3939
return "MultiLineString";
4040
}
4141

42-
43-
4442
/**
4543
* Gets a list of GeoJsonLineStrings
4644
*

library/src/main/java/com/google/maps/android/data/geojson/GeoJsonMultiPoint.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ public String getGeometryType() {
3939
return "MultiPoint";
4040
}
4141

42-
43-
4442
/**
4543
* Gets a list of GeoJsonPoints
4644
*

library/src/main/java/com/google/maps/android/data/geojson/GeoJsonMultiPolygon.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public String getGeometryType() {
4040
return "MultiPolygon";
4141
}
4242

43-
44-
4543
/**
4644
* Gets a list of GeoJsonPolygons
4745
*

0 commit comments

Comments
 (0)