finish measure.py
This commit is contained in:
parent
8bb9bf5209
commit
bcaee932bd
@ -1,22 +1,22 @@
|
||||
from decimal import Decimal
|
||||
from decimal import Decimal as D
|
||||
|
||||
class Deg:
|
||||
def __str__(self):
|
||||
return "%03d-%02d-%04.2f" % (self.deg, self.mm, self.ss)
|
||||
|
||||
def __init__(self, deg, mm, ss):
|
||||
self.deg = Decimal(deg)
|
||||
self.mm = Decimal(mm)
|
||||
self.ss = Decimal(ss)
|
||||
self.deg = D(deg)
|
||||
self.mm = D(mm)
|
||||
self.ss = D(ss)
|
||||
|
||||
@classmethod
|
||||
def from_1(cls, deg):
|
||||
assert isinstance(deg, Decimal)
|
||||
assert isinstance(deg, D)
|
||||
|
||||
pdeg, pmm = divmod(deg, 1)
|
||||
pmm = pmm * Decimal(60)
|
||||
pmm = pmm * D(60)
|
||||
pmm, pss = divmod(pmm, 1)
|
||||
pss = pss * Decimal(60)
|
||||
pss = pss * D(60)
|
||||
return cls(pdeg, pmm, pss)
|
||||
|
||||
@classmethod
|
||||
@ -24,22 +24,31 @@ class Deg:
|
||||
if '-' in instr:
|
||||
deg, mm, ss = instr.split('-')
|
||||
return Deg(deg, mm, ss)
|
||||
return cls.from_1(Decimal(instr))
|
||||
return cls.from_1(D(instr))
|
||||
|
||||
@property
|
||||
def frac(self):
|
||||
return (
|
||||
self.deg +
|
||||
self.mm / Decimal(60) +
|
||||
self.ss / Decimal(3600)).normalize()
|
||||
self.mm / D(60) +
|
||||
self.ss / D(3600)).normalize()
|
||||
|
||||
|
||||
import unittest
|
||||
class TestDeg(unittest.TestCase):
|
||||
def test_deg(self):
|
||||
w = Deg.guess('125.5')
|
||||
w = Deg.guess('125.505')
|
||||
self.assertEqual(125, w.deg)
|
||||
self.assertEqual(30, w.mm)
|
||||
self.assertEqual(0, w.ss)
|
||||
self.assertEqual(18, w.ss)
|
||||
|
||||
def test_guess(self):
|
||||
w = Deg.guess('112-58-25.4')
|
||||
self.assertEqual(112, w.deg)
|
||||
self.assertEqual(58, w.mm)
|
||||
self.assertEqual(D('25.4'), w.ss)
|
||||
frac = "%3.7f" % w.frac
|
||||
self.assertEqual('112.9737222', frac)
|
||||
|
||||
def test_str_lower(self):
|
||||
w = Deg(120, 1, 42.541)
|
||||
|
@ -60,33 +60,27 @@ Atkarpos:
|
||||
2L-9 = 79.210 + D = %.3f""" % (Decimal('79.210') + D) + """
|
||||
|
||||
Kampai:
|
||||
1K-1(L-M-S) = 84-03-08.3 + P
|
||||
1K-2(L-M-S) = 112-58-25.4 + S
|
||||
1K-3(L) = 54.3107235 + L
|
||||
1K-4(L-M-S) = 84-33-44.2 + S
|
||||
1K-5(L) = 7.8383177 + P
|
||||
1K-6(L-M-S) = 23-15-32.7 + P
|
||||
1K-7(L) = 126.2540802 + K
|
||||
1K-8(L-M-S) = 205-29-57.8 + K
|
||||
1K-9(L) = 101.7366025 + S
|
||||
1K-10(L-M-S) = 160-23-45.2 + T
|
||||
1K-11(L) = 79.8680017 + K
|
||||
1K-12(L-M-S) = 52-28-42.4 + R
|
||||
1K-13(L-M-S) = 109-01-49.8 + T
|
||||
1K-1(L-M-S) = 84-03-08.3 + P = %3.7f""" % (Deg.guess('84-03-08.3').frac + P) + """
|
||||
1K-2(L-M-S) = 112-58-25.4 + S = %3.7f""" % (Deg.guess('112-58-25.4').frac + S) + """
|
||||
1K-3(L) = 54.3107235 + L = %3.7f""" % (Deg.guess('54.3107235').frac + L) + """
|
||||
1K-4(L-M-S) = 84-33-44.2 + S = %3.7f""" % (Deg.guess('84-33-44.2').frac + S) + """
|
||||
1K-5(L) = 7.8383177 + P = %3.7f""" % (Deg.guess('7.8383177').frac + P) + """
|
||||
1K-6(L-M-S) = 23-15-32.7 + P = %3.7f""" % (Deg.guess('23-15-32.7').frac + P) + """
|
||||
1K-7(L) = 126.2540802 + K = %3.7f""" % (Deg.guess('126.2540802').frac + K) + """
|
||||
1K-8(L-M-S) = 205-29-57.8 + K = %3.7f""" % (Deg.guess('205-29-57.8').frac + K) + """
|
||||
1K-9(L) = 101.7366025 + S = %3.7f""" % (Deg.guess('101.7366025').frac + S) + """
|
||||
1K-10(L-M-S) = 160-23-45.2 + T = %3.7f""" % (Deg.guess('160-23-45.2').frac + T) + """
|
||||
1K-11(L) = 79.8680017 + K = %3.7f""" % (Deg.guess('79.8680017').frac + K) + """
|
||||
1K-12(L-M-S) = 52-28-42.4 + R = %3.7f""" % (Deg.guess('52-28-42.4').frac + R) + """
|
||||
1K-13(L-M-S) = 109-01-49.8 + T = %3.7f""" % (Deg.guess('109-01-49.8').frac + T) + """
|
||||
|
||||
2K-1(L-M-S) = 84-00-34.4 + L
|
||||
2K-2(L) = 76.1245808 + N
|
||||
2K-3(L-M-S) = 54-13-28.3 + P
|
||||
2K-4(L) = 182.7394778 + S
|
||||
2K-5(L-M-S) = 162-45-25.7 + L
|
||||
2K-6(L-M-S) = 60-41-55.2 + S
|
||||
2K-7(L) = 69.4792556 + R
|
||||
2K-8(L-M-S) = 130-50-06.1 + L
|
||||
2K-9(L-M-S) = 84-08-54.3 + K
|
||||
|
||||
# Iskasu parametrai:
|
||||
Iskasos Nr.1 gylis H1 = 4.82(m)
|
||||
Iskasos Nr.1 slaito polinkio kampas SK1 = 41.08(laipsniai)
|
||||
Iskasos Nr.2 gylis H2 = 20.38(m)
|
||||
Iskasos Nr.2 slaito polinkio kampas SK2 = 17.69(laipsniai)
|
||||
2K-1(L-M-S) = 84-00-34.4 + L = %3.7f""" % (Deg.guess('84-00-34.4').frac + L) + """
|
||||
2K-2(L) = 76.1245808 + N = %3.7f""" % (Deg.guess('76.1245808').frac + N) + """
|
||||
2K-3(L-M-S) = 54-13-28.3 + P = %3.7f""" % (Deg.guess('54-13-28.3').frac + P) + """
|
||||
2K-4(L) = 182.7394778 + S = %3.7f""" % (Deg.guess('182.7394778').frac + S) + """
|
||||
2K-5(L-M-S) = 162-45-25.7 + L = %3.7f""" % (Deg.guess('162-45-25.7').frac + L) + """
|
||||
2K-6(L-M-S) = 60-41-55.2 + S = %3.7f""" % (Deg.guess('60-41-55.2').frac + S) + """
|
||||
2K-7(L) = 69.4792556 + R = %3.7f""" % (Deg.guess('69.4792556').frac + R) + """
|
||||
2K-8(L-M-S) = 130-50-06.1 + L = %3.7f""" % (Deg.guess('130-50-06.1').frac + L) + """
|
||||
2K-9(L-M-S) = 84-08-54.3 + K = %3.7f""" % (Deg.guess('84-08-54.3').frac + K) + """
|
||||
""")
|
||||
|
Loading…
Reference in New Issue
Block a user