def __routes(self): if self._routes is None: data = self.__get_json_attr('routes', agencies=self.id) self._routes = { obj['id']: Route.from_json(obj, self.__route_stops.get(obj['id'], [])) for obj in data } return self._routes
def from_json(cls, data): """Load Operator from GeoJSON.""" agency = cls(**data) # Add stops stops = {} for feature in data['features']: if feature['onestopId'].startswith('s'): stop = Stop.from_json(feature) stops[stop.onestop()] = stop # Add routes for feature in data['features']: if feature['onestopId'].startswith('r'): route = Route.from_json(feature) # Get stop by id, add as child. for stop in feature['serves']: route.pclink(route, stops[stop]) agency.pclink(agency, route) return agency
def route_c(stop_4, stop_5, stop_6, stop_7): r = Route.from_json(json.loads( ROUTE_TEMPLATE.replace("ROUTE_ID", "route_3").replace("ROUTE_LONG_NAME", "risky route") )) r._cached_stops = [stop_4, stop_5, stop_6, stop_7] return r
def route_b(stop_2, stop_3, stop_4): r = Route.from_json(json.loads( ROUTE_TEMPLATE.replace("ROUTE_ID", "route_2").replace("ROUTE_LONG_NAME", "worst route") )) r._cached_stops = [stop_2, stop_3, stop_4] return r
def route_a(stop_1, stop_2): r = Route.from_json(json.loads( ROUTE_TEMPLATE.replace("ROUTE_ID", "route_1").replace("ROUTE_LONG_NAME", "best route") )) r._cached_stops = [stop_1, stop_2] return r