diff options
| author | Yuval Adam <_@yuv.al> | 2020-09-28 19:24:47 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2020-09-28 19:24:47 +0300 |
| commit | beec864ac8a790edeb8df2df68442d0aafdcc77b (patch) | |
| tree | 7edc0d27469d03e6e6997e91f73ddb7857b7ffda /iss/utils.py | |
| parent | aa685f4a2b7743ced2ceafc65538eb5457f5ee97 (diff) | |
Implement normalize_lat_lng()
Diffstat (limited to 'iss/utils.py')
| -rw-r--r-- | iss/utils.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/iss/utils.py b/iss/utils.py index 326d835..656d4e3 100644 --- a/iss/utils.py +++ b/iss/utils.py @@ -7,6 +7,14 @@ def seconds_to_minutes(secs): return f"{secs // 60}:{secs % 60:02}" +def normalize_lat_lng(lat, lng): + if lat[0] not in "NS" or lng[0] not in "EW": + raise Exception("Lat/lng must be formatted as N12.345 and E67.890") + nlat = float(lat[1:]) * (-1 if lat[0] == "S" else 1) + nlng = float(lng[1:]) * (-1 if lng[0] == "W" else 1) + return nlat, nlng + + def deg_to_cardinal(deg): cardinals = [ "N", |
