예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
def stop_7():
    return Stop.from_json(json.loads(
        STOP_TEMPLATE.replace("STOP_ID", "stop_7").replace("STOP_NAME", "seventh stop")
    ))
예제 #4
0
def stop_5():
    return Stop.from_json(json.loads(
        STOP_TEMPLATE.replace("STOP_ID", "stop_5").replace("STOP_NAME", "fifth stop")
    ))
예제 #5
0
def stop_3():
    return Stop.from_json(json.loads(
        STOP_TEMPLATE.replace("STOP_ID", "stop_3").replace("STOP_NAME", "third stop")
    ))
예제 #6
0
def stop_2():
    return Stop.from_json(json.loads(
        STOP_TEMPLATE.replace("STOP_ID", "stop_2").replace("STOP_NAME", "second stop")
    ))
예제 #7
0
 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