diff --git a/misc/deg.py b/misc/deg.py index 8012f1d..d678a7b 100644 --- a/misc/deg.py +++ b/misc/deg.py @@ -1,6 +1,10 @@ +from collections import namedtuple + from decimal import Decimal as Dec -Deg = namedtuple('Deg', ['hh', 'mm', 'ss']) +class Deg(namedtuple('Deg', ['deg', 'mm', 'ss'])): + def __str__(self): + return "%03d-%02d-%.1f" % (self.deg, self.mm, self.ss) def guess(inp): if isinstance(inp, Dec): diff --git a/misc/tools.py b/misc/tools.py deleted file mode 100644 index 4a82d81..0000000 --- a/misc/tools.py +++ /dev/null @@ -1,26 +0,0 @@ -from decimal import Decimal - -class Deg: - def __str__(self): - return "%03d - %02d - %02d" % (self.deg, self.mm, self.ss) - - def __init__(self, deg, mm, ss): - self.deg = Decimal(deg) - self.mm = Decimal(mm) - self.ss = Decimal(ss) - - @staticmethod - def from_1(deg): - assert isinstance(deg, Decimal) - - pdeg, pmm = divmod(deg, 1) - pmm = pmm * Decimal(60) - pmm, pss = divmod(pmm, 1) - pss = pss * Decimal(60) - return Deg(pdeg, pmm, pss) - - def frac(self): - return ( - self.deg + - self.mm / Decimal(60) + - self.ss / Decimal(3600)).normalize()