From c7c47b112bcc96d5d1076fd92993b384937b6b09 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Sun, 27 Sep 2020 23:30:41 +0300 Subject: Implement deg_to_cardinal() --- iss/utils.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'iss/utils.py') diff --git a/iss/utils.py b/iss/utils.py index f1a75c0..0bf9d04 100644 --- a/iss/utils.py +++ b/iss/utils.py @@ -1,3 +1,25 @@ def chunks(l, n): for i in range(0, len(l), n): yield l[i : i + n] + + +def deg_to_cardinal(deg): + cardinals = [ + "N", + "NNE", + "NE", + "ENE", + "E", + "ESE", + "SE", + "SSE", + "S", + "SSW", + "SW", + "WSW", + "W", + "WNW", + "NW", + "NNW", + ] + return cardinals[round((deg % 360) / 22.5) % 16] -- cgit v1.3.1