changeset 9:a56d3d3b5efd

Reject out of range latitide and longitide values.
author David Barts <n5jrn@me.com>
date Wed, 25 Aug 2021 08:45:36 -0700
parents 290b0b2a584b
children 1944acce0e6f
files MakeWaypoints.kt
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MakeWaypoints.kt	Wed Aug 25 08:33:59 2021 -0700
+++ b/MakeWaypoints.kt	Wed Aug 25 08:45:36 2021 -0700
@@ -8,6 +8,7 @@
 import java.text.SimpleDateFormat
 import java.util.Date
 import java.util.TimeZone
+import kotlin.math.abs
 
 private const val MYNAME = "MakeWaypoints"
 private const val CHARSET = "UTF-8"
@@ -72,7 +73,9 @@
                     Pair(parts[0].trim(), parts[1].trim())
                 else
                     Pair(parts[1].trim(), parts[0].trim())
-                if (lat.toDoubleOrNull() == null || long.toDoubleOrNull() == null) {
+                val dLat = lat.toDoubleOrNull()
+                val dLong = long.toDoubleOrNull()
+                if (dLat == null || abs(dLat) > 90.0 || dLong == null || abs(dLong) > 180.0) {
                     System.err.println(invalid)
                     continue
                 }