def __call__(self, edge1, vertex, edge2, context):
        
        osm_id = vertex.label.split("-")[1]
        
        # figure out which direction to turn
        osm_way_id1 = edge1.payload.name.split("-")[0]
        osm_way_id2 = edge2.payload.name.split("-")[0]
        
        osm_edge1 = self.osmdb.edge( edge1.payload.name )
        osm_edge2 = self.osmdb.edge( edge2.payload.name )
        
        osm_edge1_endnode = osm_edge1[3]
        osm_edge2_startnode = osm_edge2[2]
        
        osm_edge1_geom = osm_edge1[5]
        osm_edge2_geom = osm_edge2[5]
        
        if osm_id != osm_edge1_endnode:
            osm_edge1_geom.reverse()
             
        if osm_id != osm_edge2_startnode:
            osm_edge2_geom.reverse()
            
        endseg = osm_edge1_geom[-2:]
        startseg = osm_edge2_geom[:2]
        
        direction = turn_narrative( endseg[0], endseg[1], startseg[0], startseg[1] )
                
        street_name1 = self.osmdb.way( osm_way_id1 ).tags.get("name", "unnamed")
        street_name2 = self.osmdb.way( osm_way_id2 ).tags.get("name", "unnamed")
        
        osm_node_id, osm_node_tags, osm_node_lat, osm_node_lon, osm_node_refcount = self.osmdb.node( osm_id )
        
        average_speed = context['sumlength']/(vertex.state.time-context['lastturntime']) if vertex.state.time-context['lastturntime']>0 else 100000000
        what = "%s onto %s after %dm, %0.1fm rise, %0.1fm fall (%0.1fm/s)"%(direction, street_name2, context['sumlength'], context['sumrise'], context['sumfall'], average_speed)
        where = "%s & %s"%(street_name1, street_name2)
        when = "about %s"%str(TimeHelpers.unix_to_localtime( vertex.state.time, self.timezone_name ))
        geom = (osm_node_lon, osm_node_lat)
        
        context['sumlength'] = 0
        context['sumrise'] = 0
        context['sumfall'] = 0
        context['lastturntime'] = vertex.state.time
        return NarrativeEvent(what,where,when,geom)
dataset/ETHPy150Open bmander/graphserver/pygs/graphserver/ext/routeserver/events.py/StreetTurnEvent.__call__/original