コード例 #1
0
ファイル: events.py プロジェクト: tonny2v/graphserver
class DescribeCrossingAtAlightEvent:
    def __init__(self, gtfsdb_filename, timezone_name="America/Los_Angeles"):
        self.gtfsdb = GTFSDatabase(gtfsdb_filename)
        self.timezone_name = timezone_name

    @staticmethod
    def applies_to(vertex1, edge, vertex2):
        # if the stop_sequence is the same before and after the TripAlight was crossed, it means the algorithm crossed in the forward
        # direction - because the stop_sequence doesn't get set on a forward alight. If this is true then this is the appropriate time
        # to describe the transit trip that led to this alighting
        return edge is not None \
               and isinstance(edge.payload, graphserver.core.TripAlight) \
               and vertex1.state.stop_sequence == vertex2.state.stop_sequence

    def __call__(self, vertex1, edge, vertex2, context):

        stop_sequence_of_boarding = vertex1.state.stop_sequence
        trip_id = vertex1.state.trip_id
        alighting_trip_id, alighting_time, alighting_stop_sequences = edge.payload.get_alighting_by_trip_id(
            trip_id)

        what = "Ride trip %s from stop_seq %s to stop_seq %s" % (
            trip_id, vertex1.state.stop_sequence, alighting_stop_sequences)
        where = None
        when = None
        geom = self.gtfsdb.shape_between(trip_id, vertex1.state.stop_sequence,
                                         alighting_stop_sequences)
        return NarrativeEvent(what, where, when, geom)
コード例 #2
0
ファイル: events.py プロジェクト: bcavagnolo/Bikesy-Backend
class DescribeCrossingAtAlightEvent:
    def __init__(self, gtfsdb_filename, timezone_name="America/Los_Angeles"):
        self.gtfsdb = GTFSDatabase( gtfsdb_filename )
        self.timezone_name = timezone_name
        
    @staticmethod
    def applies_to(vertex1, edge, vertex2):
        # if the stop_sequence is the same before and after the TripAlight was crossed, it means the algorithm crossed in the forward
        # direction - because the stop_sequence doesn't get set on a forward alight. If this is true then this is the appropriate time
        # to describe the transit trip that led to this alighting
        return edge is not None \
               and isinstance(edge.payload, graphserver.core.TripAlight) \
               and vertex1.state.stop_sequence == vertex2.state.stop_sequence
        
    def __call__(self, vertex1, edge, vertex2, context):
        
        stop_sequence_of_boarding = vertex1.state.stop_sequence
        trip_id = vertex1.state.trip_id
        alighting_trip_id, alighting_time, alighting_stop_sequences = edge.payload.get_alighting_by_trip_id( trip_id )
        
        what = "Ride trip %s from stop_seq %s to stop_seq %s"%(trip_id, vertex1.state.stop_sequence, alighting_stop_sequences)
        where = None
        when = None
        geom = self.gtfsdb.shape_between( trip_id, vertex1.state.stop_sequence, alighting_stop_sequences )
        return NarrativeEvent(what, where, when, geom)