#21 Convert route
All checks were successful
Amarillo/amarillo-gitea/amarillo-enhancer/pipeline/head This commit looks good
All checks were successful
Amarillo/amarillo-gitea/amarillo-enhancer/pipeline/head This commit looks good
This commit is contained in:
parent
6e996f6981
commit
652780b702
|
|
@ -115,13 +115,17 @@ class GtfsExport:
|
||||||
return geodesic_distance_in_m(stop1, stop2) <= MERGE_RANGE_M
|
return geodesic_distance_in_m(stop1, stop2) <= MERGE_RANGE_M
|
||||||
|
|
||||||
def convert_route(self, route_group):
|
def convert_route(self, route_group):
|
||||||
# TODO receives a group of trips and turns it into a route object,
|
agency = "multiple"
|
||||||
# handling cases where there are multiple agencies' routes grouped together
|
|
||||||
pass
|
#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):
|
def _convert_trip(self, trip):
|
||||||
self.trip_counter += 1
|
self.trip_counter += 1
|
||||||
self.routes.append(self._create_route(trip))
|
|
||||||
self.calendar.append(self._create_calendar(trip))
|
self.calendar.append(self._create_calendar(trip))
|
||||||
if not trip.runs_regularly:
|
if not trip.runs_regularly:
|
||||||
self.calendar_dates.append(self._create_calendar_date(trip))
|
self.calendar_dates.append(self._create_calendar_date(trip))
|
||||||
|
|
@ -152,8 +156,8 @@ class GtfsExport:
|
||||||
logger.exception(ex)
|
logger.exception(ex)
|
||||||
return destination
|
return destination
|
||||||
|
|
||||||
def _create_route(self, trip):
|
def _create_route(self, agency, route_id, long_name):
|
||||||
return GtfsRoute(trip.agency, trip.trip_id, trip.route_long_name(), RIDESHARING_ROUTE_TYPE, trip.url, "")
|
return GtfsRoute(agency, route_id, long_name, RIDESHARING_ROUTE_TYPE, "")
|
||||||
|
|
||||||
def _create_calendar(self, trip):
|
def _create_calendar(self, trip):
|
||||||
# TODO currently, calendar is not provided by Fahrgemeinschaft.de interface.
|
# 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)
|
return GtfsCalendarDate(trip.trip_id, self._convert_stop_date(trip.start), CALENDAR_DATES_EXCEPTION_TYPE_ADDED)
|
||||||
|
|
||||||
def _create_trip(self, trip, shape_id):
|
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):
|
def _convert_stop(self, stop):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue