mirror of
https://github.com/Pygmalion69/OpenTopoMapViewer.git
synced 2025-10-05 15:52:55 +02:00
Merge remote branch “origin/master”
This commit is contained in:
@@ -54,10 +54,10 @@ class CacheSettingsFragment : DialogFragment() {
|
||||
val newExternalStorage = swExternalStorage.isChecked
|
||||
val newTileCache = etTileCache.text.toString()
|
||||
val newCacheSizeText = etCacheSize.text.toString()
|
||||
val newCacheSize = try {
|
||||
newCacheSizeText.toInt()
|
||||
} catch (e: NumberFormatException) {
|
||||
Log.e(TAG, "Invalid cache size: $newCacheSizeText", e)
|
||||
val newCacheSize = newCacheSizeText.toIntOrNull() ?: -1
|
||||
|
||||
if (newCacheSize == -1) {
|
||||
Log.e(TAG, "Invalid cache size: $newCacheSizeText")
|
||||
}
|
||||
|
||||
if (newCacheSize > 0) {
|
||||
|
@@ -1021,7 +1021,7 @@ class MapFragment : Fragment(), LocationListener, PopupMenu.OnMenuItemClickListe
|
||||
fun getGpx(): Gpx?
|
||||
|
||||
/**
|
||||
* Clear GOX so it won't ne restored on config change
|
||||
* Clear GPX so it won't be restored on config change
|
||||
*/
|
||||
fun clearGpx()
|
||||
|
||||
|
@@ -0,0 +1,33 @@
|
||||
package org.nitri.opentopo
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.nitri.opentopo.util.DistanceCalculator
|
||||
|
||||
class DistanceCalculatorTest {
|
||||
|
||||
@Test
|
||||
fun distanceReturnsZeroForIdenticalPoints() {
|
||||
val latitude = 48.8566
|
||||
val longitude = 2.3522
|
||||
|
||||
val distance = DistanceCalculator.distance(latitude, longitude, latitude, longitude)
|
||||
|
||||
assertEquals(0.0, distance, 0.0)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun distanceMatchesExpectedValueForKnownCoordinates() {
|
||||
val parisLat = 48.8566
|
||||
val parisLon = 2.3522
|
||||
val londonLat = 51.5074
|
||||
val londonLon = -0.1278
|
||||
|
||||
val distance = DistanceCalculator.distance(parisLat, parisLon, londonLat, londonLon)
|
||||
|
||||
val expectedDistanceMeters = 343_556.0
|
||||
val toleranceMeters = 1_000.0
|
||||
|
||||
assertEquals(expectedDistanceMeters, distance, toleranceMeters)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user