def smart_round_angle_decimal(x, latitude=False): divisors_360 = math_util.divisors(360) divisors_10 = math_util.divisors(10) if x >= 1: d = math_util.closest(divisors_360, x) else: t = 1. while True: t = t * 10. x = x * 10. if x >= 1: d = math_util.closest(divisors_10, x) / t break a = Angle(degrees=d, latitude=latitude) return a
def smart_round_angle_sexagesimal(x, latitude=False, hours=False): d, m, s = 0, 0, 0. divisors_360 = math_util.divisors(360) divisors_10 = math_util.divisors(10) divisors_60 = math_util.divisors(60) if hours: x /= 15. if x >= 1: d = math_util.closest(divisors_360, x) else: x = x * 60. if x >= 1: m = math_util.closest(divisors_60, x) else: x = x * 60. if x >= 1: s = math_util.closest(divisors_60, x) else: t = 1. while True: t = t * 10. x = x * 10. if x >= 1: s = math_util.closest(divisors_10, x) / t break a = Angle(sexagesimal=(d, m, s), latitude=latitude) if hours: a *= 15 return a