Skip to content
Snippets Groups Projects
Commit 883a6b81 authored by Markus Willman's avatar Markus Willman
Browse files

update getTripShapes, see comments

parent f6ea22e4
No related branches found
No related tags found
No related merge requests found
...@@ -230,7 +230,8 @@ def apiBusInfo(version, busId = None, getShape = "false"): ...@@ -230,7 +230,8 @@ def apiBusInfo(version, busId = None, getShape = "false"):
# route_short_name = lineref from data # route_short_name = lineref from data
if (getShape == "true"): if (getShape == "true"):
# FIXME: in theory this can contain shape information for multiple trips, since route_short_name doesn't have to be and isn't unique to one trip in GTFS # FIXME: in theory this can contain shape information for multiple trips, since route_short_name doesn't have to be and isn't unique to one trip in GTFS
data["shapes"] = gtfs.getTripShapes(data["lineref"]) # blockref from SIRI VM is the trip_id in GTFS, this is clearly a Föli implementation detail and as such lineref remains as fallback
data["shapes"] = gtfs.getTripShapes(data["lineref"], data["blockref"])
if data: if data:
return jsonify(data) return jsonify(data)
......
...@@ -362,7 +362,13 @@ class GtfsHandler(object): ...@@ -362,7 +362,13 @@ class GtfsHandler(object):
return short_name == lineref and self._inactivePredicate(trip, now) return short_name == lineref and self._inactivePredicate(trip, now)
def getTripShapes(self, lineref): def getTripShapes(self, lineref, blockref = None):
# blockref from SIRI VM being trip_id is Föli implementation detail, which is why lineref is retained as fallback
if blockref:
trip = self.schedule.GetTrip(blockref)
if trip:
return [self.schedule.GetShape(trip.shape_id).points]
shapes = (self.schedule.GetShape(trip.shape_id) for trip in self.schedule.GetTripList() if self._namedInactivePredicate(trip, lineref)) shapes = (self.schedule.GetShape(trip.shape_id) for trip in self.schedule.GetTripList() if self._namedInactivePredicate(trip, lineref))
return {s.shape_id:s.points for s in shapes}.values() return {s.shape_id:s.points for s in shapes}.values()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment