kopia lustrzana https://github.com/glidernet/python-ogn-client
Merge pull request #11 from kerel-fs/fix/parser
Add aprs position enhancement before the sign adjustmentpull/12/head
commit
a20be37f9b
|
@ -3,6 +3,7 @@
|
||||||
## Unreleased
|
## Unreleased
|
||||||
- Added aprs destination callsign as `dstcall` to aprs beacon keys
|
- Added aprs destination callsign as `dstcall` to aprs beacon keys
|
||||||
- Changed aprs parser to allow other destination calls than `APRS`
|
- Changed aprs parser to allow other destination calls than `APRS`
|
||||||
|
- Fixed parsing of APRS precision and datum option (#7)
|
||||||
|
|
||||||
## 0.4.0 - 2016-03-29
|
## 0.4.0 - 2016-03-29
|
||||||
- aprs client: Added the possibility of a timed callback
|
- aprs client: Added the possibility of a timed callback
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from ogn.parser.utils import createTimestamp, dmsToDeg, kts2kmh, feet2m, fpm2ms
|
from ogn.parser.utils import createTimestamp, parseAngle, kts2kmh, feet2m, fpm2ms
|
||||||
from ogn.parser.pattern import PATTERN_APRS, PATTERN_RECEIVER_BEACON, PATTERN_AIRCRAFT_BEACON
|
from ogn.parser.pattern import PATTERN_APRS, PATTERN_RECEIVER_BEACON, PATTERN_AIRCRAFT_BEACON
|
||||||
from ogn.parser.exceptions import AprsParseError, OgnParseError
|
from ogn.parser.exceptions import AprsParseError, OgnParseError
|
||||||
|
|
||||||
|
@ -16,13 +16,11 @@ def parse_aprs(message, reference_date=None):
|
||||||
'receiver_name': match.group('receiver'),
|
'receiver_name': match.group('receiver'),
|
||||||
'dstcall': match.group('dstcall'),
|
'dstcall': match.group('dstcall'),
|
||||||
'timestamp': createTimestamp(match.group('time'), reference_date),
|
'timestamp': createTimestamp(match.group('time'), reference_date),
|
||||||
'latitude': dmsToDeg(float(match.group('latitude')) / 100) *
|
'latitude': parseAngle('0' + match.group('latitude') + (match.group('latitude_enhancement') or '0')) *
|
||||||
(-1 if match.group('latitude_sign') == 'S' else 1) +
|
(-1 if match.group('latitude_sign') == 'S' else 1),
|
||||||
(int(match.group('latitude_enhancement')) / 1000 / 60 if match.group('latitude_enhancement') else 0),
|
|
||||||
'symboltable': match.group('symbol_table'),
|
'symboltable': match.group('symbol_table'),
|
||||||
'longitude': dmsToDeg(float(match.group('longitude')) / 100) *
|
'longitude': parseAngle(match.group('longitude') + (match.group('longitude_enhancement') or '0')) *
|
||||||
(-1 if match.group('longitude_sign') == 'W' else 1) +
|
(-1 if match.group('longitude_sign') == 'W' else 1),
|
||||||
(int(match.group('longitude_enhancement')) / 1000 / 60 if match.group('longitude_enhancement') else 0),
|
|
||||||
'symbolcode': match.group('symbol'),
|
'symbolcode': match.group('symbol'),
|
||||||
'track': int(match.group('course')) if match.group('course_extension') else 0,
|
'track': int(match.group('course')) if match.group('course_extension') else 0,
|
||||||
'ground_speed': int(match.group('ground_speed')) * kts2kmh if match.group('ground_speed') else 0,
|
'ground_speed': int(match.group('ground_speed')) * kts2kmh if match.group('ground_speed') else 0,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import math
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from ogn.parser.exceptions import AmbigousTimeError
|
from ogn.parser.exceptions import AmbigousTimeError
|
||||||
|
@ -13,11 +12,8 @@ m2feet = 1 / feet2m
|
||||||
fpm2ms = 1 / ms2fpm
|
fpm2ms = 1 / ms2fpm
|
||||||
|
|
||||||
|
|
||||||
def dmsToDeg(dms):
|
def parseAngle(dddmmhht):
|
||||||
absDms = abs(dms)
|
return float(dddmmhht[:3]) + float(dddmmhht[3:]) / 60
|
||||||
d = math.floor(absDms)
|
|
||||||
m = (absDms - d) * 100 / 60
|
|
||||||
return d + m
|
|
||||||
|
|
||||||
|
|
||||||
def createTimestamp(hhmmss, reference):
|
def createTimestamp(hhmmss, reference):
|
||||||
|
|
|
@ -2,7 +2,7 @@ import unittest
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from ogn.parser.utils import dmsToDeg, kts2kmh, m2feet
|
from ogn.parser.utils import kts2kmh, m2feet
|
||||||
from ogn.parser.parse import parse_aprs
|
from ogn.parser.parse import parse_aprs
|
||||||
from ogn.parser.exceptions import AprsParseError
|
from ogn.parser.exceptions import AprsParseError
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ class TestStringMethods(unittest.TestCase):
|
||||||
self.assertEqual(message['name'], "FLRDDA5BA")
|
self.assertEqual(message['name'], "FLRDDA5BA")
|
||||||
self.assertEqual(message['receiver_name'], "LFMX")
|
self.assertEqual(message['receiver_name'], "LFMX")
|
||||||
self.assertEqual(message['timestamp'].strftime('%H:%M:%S'), "16:08:29")
|
self.assertEqual(message['timestamp'].strftime('%H:%M:%S'), "16:08:29")
|
||||||
self.assertAlmostEqual(message['latitude'], dmsToDeg(44.1541), 5)
|
self.assertAlmostEqual(message['latitude'], 44.25683, 5)
|
||||||
self.assertEqual(message['symboltable'], '/')
|
self.assertEqual(message['symboltable'], '/')
|
||||||
self.assertAlmostEqual(message['longitude'], dmsToDeg(6.0003), 5)
|
self.assertAlmostEqual(message['longitude'], 6.0005, 5)
|
||||||
self.assertEqual(message['symbolcode'], '\'')
|
self.assertEqual(message['symbolcode'], '\'')
|
||||||
self.assertEqual(message['track'], 342)
|
self.assertEqual(message['track'], 342)
|
||||||
self.assertEqual(message['ground_speed'], 49 * kts2kmh)
|
self.assertEqual(message['ground_speed'], 49 * kts2kmh)
|
||||||
|
@ -31,8 +31,8 @@ class TestStringMethods(unittest.TestCase):
|
||||||
raw_message = "FLRDDA5BA>APRS,qAS,LFMX:/160829h4415.41N/00600.03E'342/049/A=005524 !W26! id21400EA9 -2454fpm +0.9rot 19.5dB 0e -6.6kHz gps1x1 s6.02 h44 rDF0C56"
|
raw_message = "FLRDDA5BA>APRS,qAS,LFMX:/160829h4415.41N/00600.03E'342/049/A=005524 !W26! id21400EA9 -2454fpm +0.9rot 19.5dB 0e -6.6kHz gps1x1 s6.02 h44 rDF0C56"
|
||||||
message = parse_aprs(raw_message, reference_date=datetime(2015, 1, 1, 16, 8, 29))
|
message = parse_aprs(raw_message, reference_date=datetime(2015, 1, 1, 16, 8, 29))
|
||||||
|
|
||||||
self.assertAlmostEqual(message['latitude'] - dmsToDeg(44.1541), 2 / 1000 / 60, 10)
|
self.assertAlmostEqual(message['latitude'] - 44.2568 - 1 / 30000, 2 / 1000 / 60, 10)
|
||||||
self.assertAlmostEqual(message['longitude'] - dmsToDeg(6.0003), 6 / 1000 / 60, 10)
|
self.assertAlmostEqual(message['longitude'] - 6.0005, 6 / 1000 / 60, 10)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import unittest
|
import unittest
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from ogn.parser.utils import dmsToDeg, createTimestamp
|
from ogn.parser.utils import parseAngle, createTimestamp
|
||||||
from ogn.parser.exceptions import AmbigousTimeError
|
from ogn.parser.exceptions import AmbigousTimeError
|
||||||
|
|
||||||
|
|
||||||
class TestStringMethods(unittest.TestCase):
|
class TestStringMethods(unittest.TestCase):
|
||||||
def test_dmsToDeg(self):
|
def test_parseAngle(self):
|
||||||
dms = 50.4830
|
self.assertAlmostEqual(parseAngle('05048.30'), 50.805, 5)
|
||||||
self.assertAlmostEqual(dmsToDeg(dms), 50.805, 5)
|
|
||||||
|
|
||||||
def test_createTimestamp(self):
|
def test_createTimestamp(self):
|
||||||
test_data = [
|
test_data = [
|
||||||
|
|
Ładowanie…
Reference in New Issue