Skip to content

Commit

Permalink
Fix coordinates when there is no seconds decimals
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Chagas <[email protected]>
  • Loading branch information
rtchagas committed Mar 2, 2020
1 parent 15f42d9 commit f5ad315
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,18 @@ internal class PlaceFromCoordinates(private val latitude: Double, private val lo
}

private fun replaceDelimiters(original: String): String {
val parts = original.split(":")
val idx = parts[2].indexOfAny(arrayOf(',','.').toCharArray())
val seconds = parts[2].subSequence(0, idx)
return "${parts[0]}° ${parts[1]}' $seconds\""

val parts: List<String> = original.split(":")

val degrees: String = parts[0]
val minutes: String = parts[1]
var seconds: String = parts[2]

val idx = seconds.indexOfAny(charArrayOf(',', '.'))
if (idx >= 0) {
seconds = seconds.substring(0, idx)
}

return "${degrees}° ${minutes}' ${seconds}\""
}
}
}

0 comments on commit f5ad315

Please sign in to comment.