'eta',
'draught',
]
+
+ '''
+ Maps the csv header name to matching function to call to get the data.
+ '''
+ csv_name_to_function = {
+ 'mmsi': lambda nmea: nmea.mmsi,
+ 'flag': get_flag,
+ 'name': Nmea5.get_name,
+ 'imo': lambda nmea: str(nmea.imo),
+ 'callsign': Nmea5.get_callsign,
+ 'type': lambda nmea: str(nmea.type) + '-' + get_shiptype(nmea),
+ 'length':lambda nmea: str(nmea.get_length(nmea)),
+ 'width': lambda nmea: str(nmea.get_width(nmea)),
+ 'datetime': lambda nmea: datetime.utcfromtimestamp(nmea.get_last_timestamp()).strftime('%Y-%m-%dT%H:%M:%SZ'),
+ 'status': Nmea1.get_status,
+ 'sog': Nmea1.get_sog_str,
+ 'latitude': Nmea1.get_latitude_str,
+ 'longitude': Nmea1.get_longitude_str,
+ 'cog': Nmea1.get_cog_str,
+ 'heading': Nmea1.get_heading_str,
+ 'destination': Nmea5.get_destination,
+ 'eta': Nmea5.get_eta_str,
+ 'draught': Nmea5.get_draught_str,
+ }
def get_dump_row(self):
result = []
if txt is None:
return ''
return txt.replace('\0','').replace('@', '').strip()
+ f = csv_name_to_function['mmsi']
result.append(self.strmmsi)
- country_mid = int(self.strmmsi[:3])
- country_name = COUNTRIES_MID.get(country_mid, u'unknown')
- result.append(country_name.encode('utf-8'))
- result.append(_clean(self.name))
+ result.append(self.get_flag().encode('utf-8'))
+ result.append(self.get_name())
result.append(str(self.imo))
result.append(_clean(self.callsign))
result.append(str(self.type) + '-' + SHIP_TYPES.get(self.type, 'unknown'))