se agrega hora llegada

master
Francisco Sandoval 2023-12-14 16:13:13 -03:00
parent a6c86a4753
commit bf82f2a0b5
1 changed files with 11 additions and 0 deletions

11
main.py
View File

@ -56,11 +56,15 @@ def read_file_proto_x_stop(content):
if entity.HasField('trip_update'):
trip_data = {
"id": str(entity.id),
"stop_id": None,
"stop_sequence": None,
"trip_id": entity.trip_update.trip.trip_id,
"route_id": entity.trip_update.trip.route_id,
"direction_id": entity.trip_update.trip.direction_id,
"start_time": entity.trip_update.trip.start_time,
"start_date": entity.trip_update.trip.start_date,
"arrival_time": None,
"hora_llegada": None,
"schedule_relationship": entity.trip_update.trip.schedule_relationship,
"vehicle_license_plate": entity.trip_update.vehicle.license_plate,
"latitude": entity.vehicle.position.latitude,
@ -71,11 +75,18 @@ def read_file_proto_x_stop(content):
}
for update in entity.trip_update.stop_time_update:
trip_data["stop_id"] = update.stop_id
trip_data["stop_sequence"] = update.stop_sequence
trip_data["arrival_time"] = update.arrival.time
trip_data["hora_llegada"] = datetime.fromtimestamp(update.arrival.time).strftime('%H:%M:%S')
key = f'stop_id:{update.stop_id}'
if update.stop_id in data_stop:
data_stop[key].append(trip_data)
else:
data_stop[key] = [ trip_data ]
# data_dict = trip_data.copy()
# data_dict["stop_sequence"] = update.stop_sequence
# data_dict["stop_id"] = update.stop_id