Ejemplo n.º 1
0
  def testRectangleEncode(self):
    year = datetime.datetime.utcnow().year
    when = datetime.datetime(year, 9, 4, 15, 25)

    duration = 360
    scale_factor = 10
    lon = -71.91
    lat = 41.1416666667
    precision = 4
    e_dim = 400
    n_dim = 200
    orientation_deg = 42
    an = AreaNotice(area_type=97, when=when, duration_min=duration,
                    link_id=102, mmsi=366123456)
    rect = AreaNoticeRectangle(lon, lat, e_dim, n_dim, orientation_deg,
                               precision, scale_factor)
    an.add_subarea(rect)
    self.checkAreaNoticeHeader(an, link_id=102, area_type=97,
                               timestamp=(9, 4, 15, 25), duration=360)
    lines = an.get_aivdm(sequence_num=0, channel='A')
    self.assertEqual(len(lines), 1)

    expected_msg = '!AIVDM,1,1,0,A,85M:Ih1KmPAVhjAs80e0;cKBN1N:W8Q@:2`0,0*0C'
    expected_an = AreaNotice(nmea_strings=[expected_msg])
    expected_bits = expected_an.get_bits()
    bits = an.get_bits()
    self.assertEqual(expected_bits, bits)
    self.assertEqual(lines[0], expected_msg)
Ejemplo n.º 2
0
  def testCircleEncode(self):
    # Test against 'Sample AN Data RTCMv1.xlsx' circle
    year = datetime.datetime.utcnow().year
    when = datetime.datetime(year, 9, 4, 15, 25)

    # Match the USCG sample
    duration = 2880
    an = AreaNotice(area_type=13, when=when, duration_min=duration,
                    link_id=101, mmsi=366123456)
    circle = AreaNoticeCircle(lon=-71.935, lat=41.236666667, radius=1800,
                              precision=4, scale_factor=10)
    an.add_subarea(circle)
    lines = an.get_aivdm(sequence_num=0, channel='A')
    self.assertEqual(len(lines), 1)

    expected_msg = '!AIVDM,1,1,0,A,85M:Ih1KmPAU6jAs85`03cJm;1NHQhPFP000,0*19'
    expected_an = AreaNotice(nmea_strings=[expected_msg])

    expected_bits = expected_an.get_bits()
    bits = an.get_bits()
    self.assertEqual(expected_bits, bits)

    self.assertEqual(lines[0], expected_msg)