Skip to content

Commit f138914

Browse files
jushgithub-actions[bot]
authored andcommitted
Address pending calculateBoundingBox comments (#4497)
Addressing comments from PR mapbox/mapbox-sdk#4278 cc @mapbox/maps-android GitOrigin-RevId: ac5e36e60303358fad07962dc83c61f564533c24
1 parent 482c83e commit f138914

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

maps-sdk/src/main/java/com/mapbox/maps/MapboxMap.kt

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,34 +2983,31 @@ class MapboxMap :
29832983
if (points.size <= 2) {
29842984
return points
29852985
}
2986-
val bbox = DoubleArray(4)
2987-
bbox[0] = Double.POSITIVE_INFINITY
2988-
bbox[1] = Double.POSITIVE_INFINITY
2989-
bbox[2] = Double.NEGATIVE_INFINITY
2990-
bbox[3] = Double.NEGATIVE_INFINITY
2991-
2992-
@Suppress("ReplaceManualRangeWithIndicesCalls")
2993-
for (i in 0 until points.size) {
2994-
val point: Point = points[i]
2986+
var minLongitude = Double.POSITIVE_INFINITY
2987+
var minLatitude = Double.POSITIVE_INFINITY
2988+
var maxLongitude = Double.NEGATIVE_INFINITY
2989+
var maxLatitude = Double.NEGATIVE_INFINITY
2990+
2991+
for (point in points) {
29952992
val longitude = point.longitude()
29962993
val latitude = point.latitude()
29972994

2998-
if (bbox[0] > longitude) {
2999-
bbox[0] = longitude
2995+
if (minLongitude > longitude) {
2996+
minLongitude = longitude
30002997
}
3001-
if (bbox[1] > latitude) {
3002-
bbox[1] = latitude
2998+
if (minLatitude > latitude) {
2999+
minLatitude = latitude
30033000
}
3004-
if (bbox[2] < longitude) {
3005-
bbox[2] = longitude
3001+
if (maxLongitude < longitude) {
3002+
maxLongitude = longitude
30063003
}
3007-
if (bbox[3] < latitude) {
3008-
bbox[3] = latitude
3004+
if (maxLatitude < latitude) {
3005+
maxLatitude = latitude
30093006
}
30103007
}
30113008
return listOf(
3012-
Point.fromLngLat(bbox[0], bbox[1]),
3013-
Point.fromLngLat(bbox[2], bbox[3])
3009+
Point.fromLngLat(minLongitude, minLatitude),
3010+
Point.fromLngLat(maxLongitude, maxLatitude)
30143011
)
30153012
}
30163013
}

0 commit comments

Comments
 (0)