def decode_msg_19(bit_arr: bitarray) -> dict: """ Extended Class B CS Position Report Src: https://gpsd.gitlab.io/gpsd/AIVDM.html#_type_19_extended_class_b_cs_position_report """ get_int_from_data = partial(get_int, bit_arr) return { 'type': get_int_from_data(0, 6), 'repeat': get_int_from_data(8, 8), 'mmsi': get_int_from_data(8, 38), 'speed': get_int_from_data(46, 56) * 0.1, 'accuracy': bit_arr[56], 'lon': get_int_from_data(57, 85, signed=True) / 600000.0, 'lat': get_int_from_data(85, 112, signed=True) / 600000.0, 'course': get_int_from_data(112, 124) * 0.1, 'heading': get_int_from_data(124, 133), 'second': get_int_from_data(133, 139), 'regional': get_int_from_data(139, 143), 'shipname': encode_bin_as_ascii6(bit_arr[143:263]), 'shiptype': ShipType(get_int_from_data(263, 271)), 'to_bow': get_int_from_data(271, 280), 'to_stern': get_int_from_data(280, 289), 'to_port': get_int_from_data(289, 295), 'to_starboard': get_int_from_data(295, 301), 'epfd': EpfdType(get_int_from_data(301, 305)), 'raim': bit_arr[305], 'dte': bit_arr[306], 'assigned': bit_arr[307], }
def decode_msg_21(bit_arr: bitarray) -> dict: """ Aid-to-Navigation Report Src: https://gpsd.gitlab.io/gpsd/AIVDM.html#_type_21_aid_to_navigation_report """ get_int_from_data = partial(get_int, bit_arr) return { 'type': get_int_from_data(0, 6), 'repeat': get_int_from_data(8, 8), 'mmsi': get_int_from_data(8, 38), 'aid_type': NavAid(get_int_from_data(38, 43)), 'name': encode_bin_as_ascii6(bit_arr[43:163]), 'accuracy': bit_arr[163], 'lon': get_int_from_data(164, 192, signed=True) / 600000.0, 'lat': get_int_from_data(192, 219, signed=True) / 600000.0, 'to_bow': get_int_from_data(219, 228), 'to_stern': get_int_from_data(228, 237), 'to_port': get_int_from_data(237, 243), 'to_starboard': get_int_from_data(243, 249), 'epfd': EpfdType(get_int_from_data(249, 253)), 'second': get_int_from_data(253, 259), 'off_position': bit_arr[259], 'regional': get_int_from_data(260, 268), 'raim': bit_arr[268], 'virtual_aid': bit_arr[269], 'assigned': bit_arr[270], 'name_extension': encode_bin_as_ascii6(bit_arr[272:]), }
def decode_msg_5(bit_arr: bitarray.bitarray) -> Dict[str, Any]: """ Static and Voyage Related Data Src: https://gpsd.gitlab.io/gpsd/AIVDM.html#_type_5_static_and_voyage_related_data """ get_int_from_data = partial(get_int, bit_arr) return { 'type': get_int_from_data(0, 6), 'repeat': get_int_from_data(6, 8), 'mmsi': get_int_from_data(8, 38), 'ais_version': get_int_from_data(38, 40), 'imo': get_int_from_data(40, 70), 'callsign': encode_bin_as_ascii6(bit_arr[70:112]), 'shipname': encode_bin_as_ascii6(bit_arr[112:232]), 'shiptype': ShipType(get_int_from_data(232, 240)), 'to_bow': get_int_from_data(240, 249), 'to_stern': get_int_from_data(249, 258), 'to_port': get_int_from_data(258, 264), 'to_starboard': get_int_from_data(264, 270), 'epfd': EpfdType(get_int_from_data(270, 274)), 'month': get_int_from_data(274, 278), 'day': get_int_from_data(278, 283), 'hour': get_int_from_data(283, 288), 'minute': get_int_from_data(288, 294), 'draught': get_int_from_data(294, 302) / 10.0, 'destination': encode_bin_as_ascii6(bit_arr[302:422]), 'dte': bit_arr[-2] }
def decode_msg_4(bit_arr: bitarray) -> dict: """ AIS Vessel position report using SOTDMA (Self-Organizing Time Division Multiple Access) Src: https://gpsd.gitlab.io/gpsd/AIVDM.html#_type_4_base_station_report """ get_int_from_data = partial(get_int, bit_arr) return { 'type': get_int_from_data(0, 6), 'repeat': get_int_from_data(6, 8), 'mmsi': get_int_from_data(3, 38), 'year': get_int_from_data(38, 52), 'month': get_int_from_data(52, 56), 'day': get_int_from_data(56, 61), 'hour': get_int_from_data(61, 66), 'minute': get_int_from_data(66, 72), 'second': get_int_from_data(72, 78), 'accuracy': bit_arr[78], 'lon': get_int_from_data(79, 107, signed=True) / 600000.0, 'lat': get_int_from_data(107, 134, signed=True) / 600000.0, 'epfd': EpfdType(get_int_from_data(134, 138)), 'raim': bit_arr[148], 'radio': get_int_from_data(148, len(bit_arr)), }
def decode_msg_5(bit_arr: bitarray) -> dict: get_int_from_data = partial(get_int, bit_arr) return { 'type': get_int_from_data(0, 6), 'repeat': get_int_from_data(6, 8), 'mmsi': get_int_from_data(8, 38), 'ais_version': get_int_from_data(38, 40), 'imo': get_int_from_data(40, 70), 'callsign': encode_bin_as_ascii6(bit_arr[70:112]), 'shipname': encode_bin_as_ascii6(bit_arr[112:232]), 'shiptype': ShipType(get_int_from_data(232, 240)), 'to_bow': get_int_from_data(240, 249), 'to_stern': get_int_from_data(249, 258), 'to_port': get_int_from_data(258, 264), 'to_starboard': get_int_from_data(264, 270), 'epfd': EpfdType(get_int_from_data(270, 274)), 'month': get_int_from_data(274, 278), 'day': get_int_from_data(278, 283), 'hour': get_int_from_data(283, 288), 'minute': get_int_from_data(288, 294), 'draught': get_int_from_data(294, 302) / 10.0, 'destination': encode_bin_as_ascii6(bit_arr[302:422]), 'dte': bit_arr[-2] }