SqliteMap
- class leuvenmapmatching.map.sqlite.SqliteMap(name, use_latlon=True, crs_lonlat=None, crs_xy=None, dir=None, deserializing=False)[source]
Store a map as a SQLite instance.
This class supports:
Indexing using rtrees to allow for fast searching of points on the map. When using the rtree index, only integer numbers are allowed as node labels.
Serializing to write and read from files.
Projecting points to a different frame (e.g. GPS to Lambert)
- Parameters:
name – Name of database file
use_latlon – The locations represent latitude-longitude pairs, otherwise y-x coordinates are assumed.
crs_lonlat – Coordinate reference system for the latitude-longitude coordinates.
crs_xy – Coordiante reference system for the y-x coordinates.
dir – Directory where to serialize to. If not given, a temporary location will be used.
deserializing – Internal variable to indicate that the object is being build from a file.
- add_edge(node_a, node_b, loc_a=None, loc_b=None, speed=None, edge_type=None, path=None, pathnum=None, no_index=False, no_commit=False)[source]
Add new edge to the map.
- Parameters:
node_a – Label for the node that is the start of the edge
node_b – Label for the node that is the end of the edge
no_commit – Do not commit to database (remember to commit later)
- add_edges(edges, no_index=False)[source]
Add list of nodes to database.
- Parameters:
edges – List[Tuple[node_key, node_key]] or List[Tuple[node_key, node_key, path_key, int]]
- add_node(node, loc, ignore_doubles=False, no_index=False, no_commit=False)[source]
Add new node to the map.
- Parameters:
node – label
loc – (lat, lon) or (y, x)
ignore_doubles – When trying to add the same node, ignore it
no_commit – Do not commit to database (remember to commit later)
- add_nodes(nodes)[source]
Add list of nodes to database.
- Parameters:
nodes – List[Tuple[node_key, Tuple[lat, lon]]]
- all_edges(bb=None)[source]
Return all edges.
- Parameters:
bb – Bounding box
- Returns:
(key_a, loc_a, nbr, loc_b)
- all_nodes(bb=None)[source]
Return all nodes.
- Parameters:
bb – Bounding box (minY, minX, maxY, maxX)
- Returns:
- bb()[source]
Bounding box.
- Returns:
(lat_min, lon_min, lat_max, lon_max) or (y_min, x_min, y_max, x_max)
- edges_closeto(loc, max_dist=None, max_elmt=None)[source]
Return all nodes that are on an edge that is close to the given location.
- Parameters:
loc – Location
max_dist – Maximal distance from the location
max_elmt – Return only the most nearby nodes
- edges_nbrto(edge)[source]
Return all edges that are linked to
edge
.Defaults to
nodes_nbrto
.- Parameters:
edge – Edge identifier
- Returns:
list[tuple[label1, label2, loc1, loc2]]
- node_coordinates(node_key)[source]
Get the coordinates of the given node.
- Parameters:
node_key – Node label/key
- Returns:
(lat, lon)
- nodes_closeto(loc, max_dist=None, max_elmt=None)[source]
Return all nodes close to the given location.
- Parameters:
loc – Location
max_dist – Maximal distance from the location
max_elmt – Return only the most nearby nodes