Resolves #2239 by adding a compass arrow for direction of nearest item (#5433)

* Resolves issue #2239 by adding an arrow for direction

* Removed unnecessary change in styles.xml

* spacing

* javadoc

---------

Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
Shashwat Kedia 2024-01-15 10:27:44 +05:30 committed by GitHub
parent e99ff1c044
commit e5c789e874
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 105 additions and 5 deletions

View file

@ -106,6 +106,29 @@ class LengthUtilsTest {
assertDistanceBetween(20015115.07, pointA, pointB)
}
// Test LengthUtils.formatDistanceBetween()
@Test
fun testBearingPoleToPole() {
val pointA = LatLng(90.0, 0.0, 0f)
val pointB = LatLng(-90.0, 0.0, 0f)
assertBearing(180.00, pointA, pointB)
}
@Test
fun testBearingRandomPoints() {
val pointA = LatLng(27.17, 78.04, 0f)
val pointB = LatLng(-40.69, 04.13, 0f)
assertBearing(227.46, pointA, pointB)
}
@Test
fun testBearingSamePlace() {
val pointA = LatLng(90.0, 0.0, 0f)
val pointB = LatLng(90.0, 0.0, 0f)
assertBearing(0.0, pointA, pointB)
}
// Test assertion helper functions
private fun assertFormattedDistanceBetween(expected: String, pointA: LatLng, pointB: LatLng) =
@ -117,4 +140,8 @@ class LengthUtilsTest {
private fun assertDistanceBetween(expected: Double, pointA: LatLng, pointB: LatLng) =
// Acceptable error: 1cm
assertEquals(expected, LengthUtils.computeDistanceBetween(pointA, pointB), 0.01)
private fun assertBearing(expected: Double, pointA: LatLng, pointB: LatLng) =
// Acceptable error: 1 degree
assertEquals(expected, LengthUtils.computeBearing(pointA,pointB), 1.0)
}