2015-10-27 19:17:11 +00:00
|
|
|
from datetime import datetime, timedelta
|
2015-10-24 21:13:21 +00:00
|
|
|
import math
|
|
|
|
|
2015-12-10 16:28:29 +00:00
|
|
|
from ogn.exceptions import AmbigousTimeError
|
|
|
|
|
2015-10-24 21:13:21 +00:00
|
|
|
|
|
|
|
kmh2kts = 0.539957
|
|
|
|
feet2m = 0.3048
|
|
|
|
ms2fpm = 196.85
|
|
|
|
|
2015-11-15 18:31:58 +00:00
|
|
|
kts2kmh = 1 / kmh2kts
|
|
|
|
m2feet = 1 / feet2m
|
|
|
|
fpm2ms = 1 / ms2fpm
|
2015-10-24 21:13:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
def dmsToDeg(dms):
|
|
|
|
absDms = abs(dms)
|
|
|
|
d = math.floor(absDms)
|
|
|
|
m = (absDms - d) * 100 / 60
|
2015-11-15 18:31:58 +00:00
|
|
|
return d + m
|
2015-10-24 21:13:21 +00:00
|
|
|
|
|
|
|
|
2015-12-10 16:28:29 +00:00
|
|
|
def createTimestamp(hhmmss, reference):
|
|
|
|
packet_time = datetime.strptime(hhmmss, '%H%M%S').time()
|
|
|
|
timestamp = datetime.combine(reference, packet_time)
|
|
|
|
|
|
|
|
if reference.hour == 23 and timestamp.hour == 0:
|
|
|
|
timestamp = timestamp + timedelta(days=1)
|
|
|
|
elif reference.hour == 0 and timestamp.hour == 23:
|
|
|
|
timestamp = timestamp - timedelta(days=1)
|
|
|
|
|
|
|
|
if reference - timestamp > timedelta(hours=1):
|
|
|
|
raise AmbigousTimeError(reference, packet_time)
|
2015-10-24 21:13:21 +00:00
|
|
|
|
2015-12-10 16:28:29 +00:00
|
|
|
return timestamp
|
2015-11-23 19:40:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
def create_aprs_login(user_name, pass_code, app_name, app_version, aprs_filter=None):
|
|
|
|
if not aprs_filter:
|
|
|
|
return "user %s pass %s vers %s %s\n" % (user_name, pass_code, app_name, app_version)
|
|
|
|
else:
|
|
|
|
return "user %s pass %s vers %s %s filter %s\n" % (user_name, pass_code, app_name, app_version, aprs_filter)
|