kopia lustrzana https://github.com/glidernet/python-ogn-client
Skylines parser, fixes #38
rodzic
48d0faf374
commit
7ca937a17d
|
@ -1,6 +1,17 @@
|
|||
import re
|
||||
|
||||
from ogn.parser.utils import fpm2ms
|
||||
from ogn.parser.pattern import PATTERN_SKYLINES_BEACON
|
||||
|
||||
from .base import BaseParser
|
||||
|
||||
|
||||
class SkylinesParser(BaseParser):
|
||||
def __init__(self):
|
||||
self.beacon_type = 'skylines'
|
||||
|
||||
@staticmethod
|
||||
def parse_position(aprs_comment):
|
||||
ac_match = re.search(PATTERN_SKYLINES_BEACON, aprs_comment)
|
||||
return {'id': ac_match.group('id'),
|
||||
'climb_rate': int(ac_match.group('climb_rate')) * fpm2ms if ac_match.group('climb_rate') else None}
|
||||
|
|
|
@ -16,6 +16,11 @@ PATTERN_NAVITER_BEACON = re.compile("""
|
|||
(?P<turn_rate>[+-][\d.]+)rot
|
||||
""", re.VERBOSE | re.MULTILINE)
|
||||
|
||||
PATTERN_SKYLINES_BEACON = re.compile("""
|
||||
id(?P<id>\d+)\s
|
||||
(?P<climb_rate>[+-]\d+)fpm
|
||||
""", re.VERBOSE | re.MULTILINE)
|
||||
|
||||
PATTERN_SPIDER_BEACON = re.compile("""
|
||||
id(?P<id>[\d-]+)\s
|
||||
(?P<signal_strength>[+-]\d+)dB\s
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import unittest
|
||||
|
||||
from ogn.parser.utils import ms2fpm
|
||||
from ogn.parser.aprs_comment.skylines_parser import SkylinesParser
|
||||
|
||||
|
||||
class TestStringMethods(unittest.TestCase):
|
||||
def test(self):
|
||||
message = SkylinesParser.parse_position("id2816 -015fpm")
|
||||
|
||||
self.assertEqual(message['id'], "2816")
|
||||
self.assertAlmostEqual(message['climb_rate'] * ms2fpm, -15, 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Ładowanie…
Reference in New Issue