def __stops(self): if self._stops is None: data = self.__get_json_attr('stops', agencies=self.id) self._stops = { obj['id']: Stop.from_json(self, obj) for obj in data } return self._stops
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 stop_7(): return Stop.from_json(json.loads( STOP_TEMPLATE.replace("STOP_ID", "stop_7").replace("STOP_NAME", "seventh stop") ))
def stop_5(): return Stop.from_json(json.loads( STOP_TEMPLATE.replace("STOP_ID", "stop_5").replace("STOP_NAME", "fifth stop") ))
def stop_3(): return Stop.from_json(json.loads( STOP_TEMPLATE.replace("STOP_ID", "stop_3").replace("STOP_NAME", "third stop") ))
def stop_2(): return Stop.from_json(json.loads( STOP_TEMPLATE.replace("STOP_ID", "stop_2").replace("STOP_NAME", "second stop") ))
def __stops(self): if self._stops is None: data = self.__get_json_attr('stops', agencies=self.id) self._stops = { obj['id']: Stop.from_json(self, obj) for obj in data } return self._stops