starling_sim.basemodel.topology.osm_network
Module Contents
Classes
Open Street Map network topology |
- class starling_sim.basemodel.topology.osm_network.OSMNetwork(transport_mode, weight_class=None, store_paths=False, network_file=None, speed_file=None, graph=None)
Bases:
starling_sim.basemodel.topology.topology.Topology
Open Street Map network topology
- init_graph()
Initialise the network graph from any data source.
- add_time_and_length(u, v, d)
Set the edge time and length using the speeds dict and OSM length values.
Speeds are set according to OSM ‘highway’ attribute. If the attribute’s value doesn’t correspond to any key, use the ‘other’ key.
- Parameters:
u –
v –
d –
- position_localisation(position)
Return the localisation [lat, lon] of the position
- Parameters:
position – position in the topology
- Returns:
list [lat, lon]
- nearest_position(localisation)
Return the nearest position to given localisation (lat, lon)
- Parameters:
localisation – (lat, lon) tuple
- Returns:
position
- localisations_nearest_nodes(x_coordinates, y_coordinates, return_dist=False)
Return the graph nodes nearest to a list of points.
This method should allow a faster computation than multiple nearest_position calls.
- Parameters:
x_coordinates – list of X coordinates of the localisations (lon in GPS)
y_coordinates – list of Y coordinates of the localisations (lat in GPS)
return_dist – optionally also return distance between points and nearest nodes
- Returns:
list of nearest nodes