From 14fbcd7c123aa76c40f966b34cf757fed80c0a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Gru=CC=88ndger?= Date: Fri, 22 May 2020 10:43:41 +0200 Subject: [PATCH] Incompatible IDs from lt24, skylines, spider spot renamed to separate IDs, fixes #64 --- ogn/parser/aprs_comment/lt24_parser.py | 2 +- ogn/parser/aprs_comment/skylines_parser.py | 2 +- ogn/parser/aprs_comment/spider_parser.py | 4 ++-- ogn/parser/aprs_comment/spot_parser.py | 2 +- ogn/parser/pattern.py | 17 ++++++++++++----- tests/parser/test_parse_lt24.py | 2 +- tests/parser/test_parse_skylines.py | 2 +- tests/parser/test_parse_spider.py | 4 ++-- tests/parser/test_parse_spot.py | 2 +- 9 files changed, 22 insertions(+), 15 deletions(-) diff --git a/ogn/parser/aprs_comment/lt24_parser.py b/ogn/parser/aprs_comment/lt24_parser.py index 6ef45e5..b7aec66 100644 --- a/ogn/parser/aprs_comment/lt24_parser.py +++ b/ogn/parser/aprs_comment/lt24_parser.py @@ -11,6 +11,6 @@ class LT24Parser(BaseParser): def parse_position(self, aprs_comment): match = self.position_pattern.match(aprs_comment) - return {'address': match.group('id'), + return {'lt24_id': match.group('lt24_id'), 'climb_rate': int(match.group('climb_rate')) * FPM_TO_MS if match.group('climb_rate') else None, 'source': match.group('source') if match.group('source') else None} diff --git a/ogn/parser/aprs_comment/skylines_parser.py b/ogn/parser/aprs_comment/skylines_parser.py index a5c10e8..043c29c 100644 --- a/ogn/parser/aprs_comment/skylines_parser.py +++ b/ogn/parser/aprs_comment/skylines_parser.py @@ -11,5 +11,5 @@ class SkylinesParser(BaseParser): def parse_position(self, aprs_comment): match = self.position_pattern.match(aprs_comment) - return {'address': match.group('id'), + return {'skylines_id': match.group('skylines_id'), 'climb_rate': int(match.group('climb_rate')) * FPM_TO_MS if match.group('climb_rate') else None} diff --git a/ogn/parser/aprs_comment/spider_parser.py b/ogn/parser/aprs_comment/spider_parser.py index 6966560..9adb084 100644 --- a/ogn/parser/aprs_comment/spider_parser.py +++ b/ogn/parser/aprs_comment/spider_parser.py @@ -10,7 +10,7 @@ class SpiderParser(BaseParser): def parse_position(self, aprs_comment): ac_match = self.position_pattern.match(aprs_comment) - return {'address': ac_match.group('id'), + return {'spider_id': ac_match.group('spider_id'), 'signal_power': int(ac_match.group('signal_power')) if ac_match.group('signal_power') else None, - 'spider_id': ac_match.group('spider_id') if ac_match.group('spider_id') else None, + 'spider_registration': ac_match.group('spider_registration') if ac_match.group('spider_registration') else None, 'gps_quality': ac_match.group('gps_quality') if ac_match.group('gps_quality') else None} diff --git a/ogn/parser/aprs_comment/spot_parser.py b/ogn/parser/aprs_comment/spot_parser.py index a1e3e61..65fb65a 100644 --- a/ogn/parser/aprs_comment/spot_parser.py +++ b/ogn/parser/aprs_comment/spot_parser.py @@ -10,6 +10,6 @@ class SpotParser(BaseParser): def parse_position(self, aprs_comment): match = self.position_pattern.match(aprs_comment) - return {'address': match.group('id'), + return {'spot_id': match.group('spot_id'), 'model': match.group('model') if match.group('model') else None, 'status': match.group('status') if match.group('status') else None} diff --git a/ogn/parser/pattern.py b/ogn/parser/pattern.py index 6467a5f..30fc67e 100644 --- a/ogn/parser/pattern.py +++ b/ogn/parser/pattern.py @@ -11,6 +11,13 @@ PATTERN_FANET_POSITION_COMMENT = re.compile(r""" (?:(?P[+-]\d+)fpm)? """, re.VERBOSE | re.MULTILINE) +PATTERN_FANET_STATUS_COMMENT = re.compile(r""" + (?:(Name=\"(?P[^\"]*)\")\s?)? + (?:(?P[\d.]+?)dB\s?)? + (?:(?P[+-][\d.]+?)kHz\s?)? + (?:(?P\d+)e\s?)? +""", re.VERBOSE | re.MULTILINE) + PATTERN_FLARM_POSITION_COMMENT = re.compile(r""" id(?P
[\dA-F]{2})(?P
[\dA-F]{6}?)\s? (?:(?P[+-]\d+?)fpm\s)? @@ -26,7 +33,7 @@ PATTERN_FLARM_POSITION_COMMENT = re.compile(r""" """, re.VERBOSE | re.MULTILINE) PATTERN_LT24_POSITION_COMMENT = re.compile(r""" - id(?P\d+)\s + id(?P\d+)\s (?P[+-]\d+)fpm\s (?P.+) """, re.VERBOSE | re.MULTILINE) @@ -38,19 +45,19 @@ PATTERN_NAVITER_POSITION_COMMENT = re.compile(r""" """, re.VERBOSE | re.MULTILINE) PATTERN_SKYLINES_POSITION_COMMENT = re.compile(r""" - id(?P\d+)\s + id(?P\d+)\s (?P[+-]\d+)fpm """, re.VERBOSE | re.MULTILINE) PATTERN_SPIDER_POSITION_COMMENT = re.compile(r""" - id(?P[\d-]+)\s + id(?P[\d-]+)\s (?P[+-]\d+)dB\s - (?P[A-Z0-9]+)\s + (?P[A-Z0-9]+)\s (?P.+) """, re.VERBOSE | re.MULTILINE) PATTERN_SPOT_POSITION_COMMENT = re.compile(r""" - id(?P[\d-]+)\s + id(?P[\d-]+)\s (?PSPOT[A-Z\d]+)\s (?P[A-Z]+) """, re.VERBOSE | re.MULTILINE) diff --git a/tests/parser/test_parse_lt24.py b/tests/parser/test_parse_lt24.py index 5731b5e..663dd5f 100644 --- a/tests/parser/test_parse_lt24.py +++ b/tests/parser/test_parse_lt24.py @@ -8,7 +8,7 @@ class TestStringMethods(unittest.TestCase): def test_position_comment(self): message = LT24Parser().parse_position("id25387 +123fpm GPS") - self.assertEqual(message['address'], "25387") + self.assertEqual(message['lt24_id'], "25387") self.assertAlmostEqual(message['climb_rate'], 123 * FPM_TO_MS, 2) self.assertEqual(message['source'], 'GPS') diff --git a/tests/parser/test_parse_skylines.py b/tests/parser/test_parse_skylines.py index 0b82122..55d4628 100644 --- a/tests/parser/test_parse_skylines.py +++ b/tests/parser/test_parse_skylines.py @@ -8,7 +8,7 @@ class TestStringMethods(unittest.TestCase): def test_position_comment(self): message = SkylinesParser().parse_position("id2816 -015fpm") - self.assertEqual(message['address'], "2816") + self.assertEqual(message['skylines_id'], "2816") self.assertAlmostEqual(message['climb_rate'], -15 * FPM_TO_MS, 2) diff --git a/tests/parser/test_parse_spider.py b/tests/parser/test_parse_spider.py index c0d65c2..27bb338 100644 --- a/tests/parser/test_parse_spider.py +++ b/tests/parser/test_parse_spider.py @@ -7,9 +7,9 @@ class TestStringMethods(unittest.TestCase): def test_position_comment(self): message = SpiderParser().parse_position("id300234060668560 +30dB K23W 3D") - self.assertEqual(message['address'], "300234060668560") + self.assertEqual(message['spider_id'], "300234060668560") self.assertEqual(message['signal_power'], 30) - self.assertEqual(message['spider_id'], "K23W") + self.assertEqual(message['spider_registration'], "K23W") self.assertEqual(message['gps_quality'], "3D") diff --git a/tests/parser/test_parse_spot.py b/tests/parser/test_parse_spot.py index dac0371..76fe669 100644 --- a/tests/parser/test_parse_spot.py +++ b/tests/parser/test_parse_spot.py @@ -7,7 +7,7 @@ class TestStringMethods(unittest.TestCase): def test_position_comment(self): message = SpotParser().parse_position("id0-2860357 SPOT3 GOOD") - self.assertEqual(message['address'], "0-2860357") + self.assertEqual(message['spot_id'], "0-2860357") self.assertEqual(message['model'], 'SPOT3') self.assertEqual(message['status'], "GOOD")