mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
* 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:
parent
e99ff1c044
commit
e5c789e874
6 changed files with 105 additions and 5 deletions
|
|
@ -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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue