#21 Convert route
All checks were successful
Amarillo/amarillo-gitea/amarillo-enhancer/pipeline/head This commit looks good

This commit is contained in:
Csaba 2024-01-08 15:23:18 +01:00
parent 6e996f6981
commit 652780b702

View file

@ -115,13 +115,17 @@ class GtfsExport:
return geodesic_distance_in_m(stop1, stop2) <= MERGE_RANGE_M
def convert_route(self, route_group):
# TODO receives a group of trips and turns it into a route object,
# handling cases where there are multiple agencies' routes grouped together
pass
agency = "multiple"
#if there is only one agency, use that
agencies = set(trip.agency for id, trip in route_group.items())
if len(agencies) == 1: agency = agencies.pop()
trip = next(iter(route_group.values())) # grab any trip, relevant values should be the same
self.routes.append(self._create_route(agency, trip.route_id, trip.route_name))
def _convert_trip(self, trip):
self.trip_counter += 1
self.routes.append(self._create_route(trip))
self.calendar.append(self._create_calendar(trip))
if not trip.runs_regularly:
self.calendar_dates.append(self._create_calendar_date(trip))
@ -152,8 +156,8 @@ class GtfsExport:
logger.exception(ex)
return destination
def _create_route(self, trip):
return GtfsRoute(trip.agency, trip.trip_id, trip.route_long_name(), RIDESHARING_ROUTE_TYPE, trip.url, "")
def _create_route(self, agency, route_id, long_name):
return GtfsRoute(agency, route_id, long_name, RIDESHARING_ROUTE_TYPE, "")
def _create_calendar(self, trip):
# TODO currently, calendar is not provided by Fahrgemeinschaft.de interface.
@ -174,7 +178,7 @@ class GtfsExport:
return GtfsCalendarDate(trip.trip_id, self._convert_stop_date(trip.start), CALENDAR_DATES_EXCEPTION_TYPE_ADDED)
def _create_trip(self, trip, shape_id):
return GtfsTrip(trip.route_id, trip.trip_id, trip.trip_id, shape_id, trip.trip_headsign, NO_BIKES_ALLOWED)
return GtfsTrip(trip.route_id, trip.trip_id, trip.trip_id, shape_id, trip.trip_headsign, NO_BIKES_ALLOWED, trip.url)
def _convert_stop(self, stop):
"""