diff --git a/ogn/parser/aprs_comment/safesky_parser.py b/ogn/parser/aprs_comment/safesky_parser.py index f56c7ca..5c6c05b 100644 --- a/ogn/parser/aprs_comment/safesky_parser.py +++ b/ogn/parser/aprs_comment/safesky_parser.py @@ -12,9 +12,16 @@ class SafeskyParser(BaseParser): def parse_position(self, aprs_comment): match = self.position_pattern.match(aprs_comment) result = dict() + if match.group('details'): + result.update({ + 'address_type': int(match.group('details'), 16) & 0b00000011, + 'aircraft_type': (int(match.group('details'), 16) & 0b00111100) >> 2, + 'no-tracking': (int(match.group('details'), 16) & 0b01000000) >> 6 == 1, + 'stealth': (int(match.group('details'), 16) & 0b10000000) >> 7 == 1, + 'address': match.group('address'), + }) result.update( - {'safesky_id': match.group('safesky_id'), - 'climb_rate': int(match.group('climb_rate')) * FPM_TO_MS if match.group('climb_rate') else None}) + {'climb_rate': int(match.group('climb_rate')) * FPM_TO_MS if match.group('climb_rate') else None}) if match.group('gps_quality'): result.update({ 'gps_quality': { diff --git a/ogn/parser/pattern.py b/ogn/parser/pattern.py index 1b65459..151a5d5 100644 --- a/ogn/parser/pattern.py +++ b/ogn/parser/pattern.py @@ -83,7 +83,7 @@ PATTERN_TRACKER_POSITION_COMMENT = re.compile(r""" """, re.VERBOSE | re.MULTILINE) PATTERN_SAFESKY_POSITION_COMMENT = re.compile(r""" - id(?P[A-F0-9]{8})\s + id(?P
[\dA-F]{2})(?P
[\dA-F]{6}?)\s? (?:(?P[+-]\d+?)fpm\s)? (?:gps(?P(?P(\d+))x(?P(\d+)))?)? """, re.VERBOSE | re.MULTILINE) diff --git a/tests/parser/test_parse_safesky.py b/tests/parser/test_parse_safesky.py index 8ce0368..b3f1abb 100644 --- a/tests/parser/test_parse_safesky.py +++ b/tests/parser/test_parse_safesky.py @@ -8,7 +8,9 @@ class TestStringMethods(unittest.TestCase): def test_position_comment(self): # "SKY3E5906>OGNSKY,qAS,SafeSky:/072555h5103.47N/00524.81E'065/031/A=001250 !W05! id1C3E5906 +010fpm gps6x1" message = SafeskyParser().parse_position("id1C3E5906 +010fpm gps6x1") - self.assertEqual(message['safesky_id'], '1C3E5906') + self.assertEqual(message['address'], '3E5906') + self.assertEqual(message['address_type'], 0) + self.assertEqual(message['aircraft_type'], 7) self.assertAlmostEqual(message['climb_rate'], 10 * FPM_TO_MS, 2) self.assertEqual(message['gps_quality'], {'horizontal': 6, 'vertical': 1})