Skip to content

Commit 169daf0

Browse files
- Converted Radius in meter
1 parent 9bf13b3 commit 169daf0

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

.idea/sonarIssues.xml

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

geofirequery/src/main/java/com/ckdroid/geofirequery/utils/BoundingBoxUtils.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ class BoundingBoxUtils(private val distanceUnit: DistanceUnit) {
9191
}
9292

9393
private fun pointAtDistance(queryLocation: QueryLocation, distance: Double): GeoPoint {
94-
val sinLat = Math.sin(queryLocation.latitude)
95-
val cosLat = Math.cos(queryLocation.latitude)
94+
val sinLat = sin(queryLocation.latitude)
95+
val cosLat = cos(queryLocation.latitude)
9696

9797
val bearing = Math.random().times(TWO_PI)
9898
val theta = when (distanceUnit) {
99-
DistanceUnit.KILOMETERS -> distance.div(EARTH_RADIUS_KM)
100-
DistanceUnit.MILES -> distance.div(EARTH_RADIUS_MILES)
99+
DistanceUnit.KILOMETERS -> distance.times(1000).div(EARTH_RADIUS_KM)
100+
DistanceUnit.MILES -> distance.times(1000).div(EARTH_RADIUS_MILES)
101101
}
102102

103103
val sinBearing = sin(bearing)
@@ -115,11 +115,11 @@ class BoundingBoxUtils(private val distanceUnit: DistanceUnit) {
115115

116116
companion object {
117117

118-
private val EARTH_RADIUS_KM = 6371.000//6371.001
119-
private val EARTH_RADIUS_MILES = 3958.756
118+
private const val EARTH_RADIUS_KM = 6371000//6371.001
119+
private const val EARTH_RADIUS_MILES = 3958756
120120

121-
private val THREE_PI = Math.PI.times(3)
122-
private val TWO_PI = Math.PI.times(2)
121+
private const val THREE_PI = Math.PI.times(3)
122+
private const val TWO_PI = Math.PI.times(2)
123123

124124
private val MINIMUM_LATITUDE = Math.toRadians(-90.0) // -PI/2
125125
private val MAXIMUM_LATITUDE = Math.toRadians(90.0) // PI/2

0 commit comments

Comments
 (0)