def __init__(self, mmsi, imo, vessel_name, vessel_type, length, width, country, longitude, latitude, draft, speed, str_time, mark=0): self.mmsi = mmsi self.mark = mark self.imo = imo if vessel_name is not None: self.vessel_name = vessel_name.rstrip() else: self.vessel_name = None self.vessel_type = vessel_type self.length = length self.width = width self.country = country self.longitude = longitude self.latitude = latitude self.draft = draft self.speed = speed self.date = Utils.convert_utc_to_str_time(str(str_time)) self.utc = Utils.convert_str_time_to_utc(str(str_time))
def final_deal(ship_info, trajectory_info, port_service, csv_writer): arrive_time = Utils.convert_utc_to_str_time(int(ship_info[12])) trajectory_info[10] = arrive_time # input_or_output = trajectory_info[-1] target_country = port_service.get_port_by_name(ship_info[14]).country input_or_output = get_input_or_output_state(trajectory_info[-1], target_country, False) trajectory_info[-1] = input_or_output # print(trajectory_info) csv_writer.writerow(trajectory_info)
def start_init(ship_info, ships_deadweight, port_service): # ["line_index", "mmsi", "mark", "imo", "vessel_name", "vessel_type", "length", "width", "longitude", "latitude", # "draft", "speed", "date", "utc", "source_port", "target_port", "load_state", ] deadweight_of_mmsi = ships_deadweight.get_deadweight_by_mmsi(ship_info[1]) start_time = Utils.convert_utc_to_str_time(int(ship_info[12])) source_country = port_service.get_port_by_name(ship_info[13]).country input_or_output = get_input_or_output_state(None, source_country, True) trajectory_info = ship_info[:8] + [ deadweight_of_mmsi, start_time, None, ] + ship_info[13:] + [input_or_output] # print(trajectory_info) return trajectory_info