|
@@ -39,18 +39,20 @@ class TripConverter:
|
|
def create_trip(markers: list[Marker]) -> Trip:
|
|
def create_trip(markers: list[Marker]) -> Trip:
|
|
print(len(markers), markers[0].timestamp, markers[-1].timestamp)
|
|
print(len(markers), markers[0].timestamp, markers[-1].timestamp)
|
|
trip = Trip.objects.filter(startTime__lte=markers[-1].timestamp, endTime__gte=markers[0].timestamp).first()
|
|
trip = Trip.objects.filter(startTime__lte=markers[-1].timestamp, endTime__gte=markers[0].timestamp).first()
|
|
|
|
+ center = markers[len(markers)//2].location
|
|
if not trip:
|
|
if not trip:
|
|
trip = Trip.objects.create(
|
|
trip = Trip.objects.create(
|
|
startTime = markers[0].timestamp,
|
|
startTime = markers[0].timestamp,
|
|
endTime = markers[-1].timestamp,
|
|
endTime = markers[-1].timestamp,
|
|
name = f"Trip {markers[0].timestamp}",
|
|
name = f"Trip {markers[0].timestamp}",
|
|
- color = get_path_color(markers[0].timestamp)
|
|
|
|
|
|
+ color = get_path_color(markers[0].timestamp),
|
|
|
|
+ center = Point(center.x, center.y)
|
|
)
|
|
)
|
|
elif trip.startTime == markers[0].timestamp and trip.endTime == markers[-1].timestamp:
|
|
elif trip.startTime == markers[0].timestamp and trip.endTime == markers[-1].timestamp:
|
|
print("Trip already exists")
|
|
print("Trip already exists")
|
|
return trip
|
|
return trip
|
|
|
|
|
|
- if not trip.name or "None" in trip.name:
|
|
|
|
|
|
+ if not trip.name or "None" in trip.name or trip.name.startswith("Trip "):
|
|
start = get_location_name(markers[0].location)
|
|
start = get_location_name(markers[0].location)
|
|
end = get_location_name(markers[-1].location)
|
|
end = get_location_name(markers[-1].location)
|
|
if start != end:
|
|
if start != end:
|
|
@@ -60,7 +62,6 @@ def create_trip(markers: list[Marker]) -> Trip:
|
|
trip.startTime = markers[0].timestamp
|
|
trip.startTime = markers[0].timestamp
|
|
trip.endTime = markers[-1].timestamp
|
|
trip.endTime = markers[-1].timestamp
|
|
trip.totalTime = trip.endTime - trip.startTime
|
|
trip.totalTime = trip.endTime - trip.startTime
|
|
- center = markers[len(markers)//2].location
|
|
|
|
trip.center = Point(center.x, center.y)
|
|
trip.center = Point(center.x, center.y)
|
|
|
|
|
|
total_distance = 0 # m
|
|
total_distance = 0 # m
|