Ejemplo n.º 1
0
from example_import import load_or_import_example_gtfs
from gtfspy import networks
from gtfspy import route_types

g = load_or_import_example_gtfs()
day_start_ut = g.get_weekly_extract_start_date(ut=True)

start_ut = day_start_ut + 7 * 3600
end_ut = day_start_ut + 8 * 3600

# get elementary bus events (connections) taking place within a given time interval:
all_events = networks.temporal_network(g,
                                       start_time_ut=start_ut,
                                       end_time_ut=end_ut)
print("Number of elementary PT events during rush hour in Kuopio: ",
      len(all_events))

# get  elementary bus events (connections) taking place within a given time interval:
tram_events = networks.temporal_network(g,
                                        start_time_ut=start_ut,
                                        end_time_ut=end_ut,
                                        route_type=route_types.TRAM)
assert (len(tram_events) == 0
        )  # there should be no trams in our example city (Kuopio, Finland)

# construct a networkx graph
print("\nConstructing a combined stop_to_stop_network")

graph = networks.combined_stop_to_stop_transit_network(g,
                                                       start_time_ut=start_ut,
                                                       end_time_ut=end_ut)
Ejemplo n.º 2
0
from gtfspy.routing.node_profile_analyzer_time_and_veh_legs import NodeProfileAnalyzerTimeAndVehLegs
from gtfspy.routing.helpers import get_transit_connections, get_walk_network
from gtfspy.routing.multi_objective_pseudo_connection_scan_profiler import MultiObjectivePseudoCSAProfiler
from matplotlib import pyplot as plt
from matplotlib import rc
import example_import

G = example_import.load_or_import_example_gtfs()

from_stop_name = "Ahkiotie 2 E"
to_stop_name = "Kauppahalli P"
from_stop_I = None
to_stop_I = None
stop_dict = G.stops().to_dict("index")
for stop_I, data in stop_dict.items():
    if data['name'] == from_stop_name:
        from_stop_I = stop_I
    if data['name'] == to_stop_name:
        to_stop_I = stop_I
assert(from_stop_I is not None)
assert(to_stop_I is not None)




ROUTING_START_TIME_UT = G.get_suitable_date_for_daily_extract(ut=True) + 10 * 3600
ROUTING_END_TIME_UT = G.get_suitable_date_for_daily_extract(ut=True) + 14 * 3600

connections = get_transit_connections(G, ROUTING_START_TIME_UT, ROUTING_END_TIME_UT)
walk_network = get_walk_network(G)