openlr_dereferencer.maps package¶
Subpackages¶
Submodules¶
openlr_dereferencer.maps.abstract module¶
Contains an abstract MapReader base class, which must be implemented for each map format to decode location references on.
A MapReader is an interface with which the decoder can traverse the map. An implementation may consist of a database connection or something similar. Its purpose is to let the decoder read map objects.
In order to implement a reader for a new map, the following interfaces have to be implemented:
The map model¶
Nodes¶
A node is an object with an ID and a WGS84 longitude/latitude position.
Lines¶
A line interconnects exactly two nodes in exactly one direction. As additional attributes, it has a shape, a functional road class and a form of way.
Note that the map you want to implement may have a different line concept. For example, it is common that roads are not necessarily directed. Also, roads may connect more than two nodes.
Let’s consider an example map format that defines ways like this:
Roads in the map are modeled as multi-directional ways.
If we write a MapReader adapter for this format, we could consider every directed link between nodes being a line, yielding multiple lines per way.
As lines and ways are now different things, our line IDs have to include more than just the way ID. It can be, for example, a tuple of the way ID and both node IDs.
Line IDs are required to be hashable. Since tuples of numbers are hashable, they can be used to implement line IDs.
-
class
openlr_dereferencer.maps.abstract.GeometricObject[source]¶ Bases:
abc.ABC-
geometry¶ Returns the geometry of this object
-
-
class
openlr_dereferencer.maps.abstract.Line[source]¶ Bases:
openlr_dereferencer.maps.abstract.GeometricObjectAbstract Line class, modelling a line coming from a map reader
-
coordinates() → Sequence[openlr.locations.Coordinates][source]¶ Returns the shape of the line as list of Coordinates
-
end_node¶ Returns the node on which this line ends
-
fow¶ Returns the form of way of this line
-
frc¶ Returns the functional road class of this line
-
geometry¶ Returns the geometric shape as a linestring
-
length¶ Return the line length in meters
-
line_id¶ Returns the id of the line.
A type is not specified here, but the ID has to be usable as key of a dictionary.
-
start_node¶ Returns the node from which this line starts
-
-
class
openlr_dereferencer.maps.abstract.MapReader[source]¶ Bases:
abc.ABCAbstract base class for map readers.
This is an adapter class that fulfills the map requirements of OpenLR.
-
find_lines_close_to(coord: openlr.locations.Coordinates, dist: float) → Iterable[openlr_dereferencer.maps.abstract.Line][source]¶ Iterates over all lines within dist meters around coord.
No order specified here.
-
find_nodes_close_to(coord: openlr.locations.Coordinates, dist: float) → Iterable[openlr_dereferencer.maps.abstract.Node][source]¶ Iterates over all nodes within dist meters around coord.
No order specified here.
-
get_line(line_id: Hashable) → openlr_dereferencer.maps.abstract.Line[source]¶ Returns a line by its id
-
get_lines() → Iterable[openlr_dereferencer.maps.abstract.Line][source]¶ Yields all lines in the map.
-
-
class
openlr_dereferencer.maps.abstract.Node[source]¶ Bases:
openlr_dereferencer.maps.abstract.GeometricObjectAbstract class modelling a node returned by a map reader
-
connected_lines() → Iterable[openlr_dereferencer.maps.abstract.Line][source]¶ Returns lines which touch this node
-
coordinates¶ Returns the lon, lat coordinates of this node
-
geometry¶ Returns the position of this node as shapely point
-
incoming_lines() → Iterable[openlr_dereferencer.maps.abstract.Line][source]¶ Yields all lines coming directly to this node.
-
node_id¶ Returns the id of this node.
-
openlr_dereferencer.maps.wgs84 module¶
Some geo coordinates related tools
-
openlr_dereferencer.maps.wgs84.bearing(point_a: openlr.locations.Coordinates, point_b: openlr.locations.Coordinates) → float[source]¶ Returns the angle between self and other relative to true north
The result of this function is between -pi, pi, including them
-
openlr_dereferencer.maps.wgs84.distance(point_a: openlr.locations.Coordinates, point_b: openlr.locations.Coordinates) → float[source]¶ Returns the distance of two WGS84 coordinates on our planet, in meters
-
openlr_dereferencer.maps.wgs84.extrapolate(point: openlr.locations.Coordinates, dist: float, angle: float) → openlr.locations.Coordinates[source]¶ Creates a new point that is dist meters away in direction angle
-
openlr_dereferencer.maps.wgs84.interpolate(path: Sequence[openlr.locations.Coordinates], distance_meters: float) → openlr.locations.Coordinates[source]¶ Go distance meters along the path and return the resulting point
When the length of the path is too short, returns its last coordinate
-
openlr_dereferencer.maps.wgs84.join_lines(lines: Sequence[shapely.geometry.linestring.LineString]) → shapely.geometry.linestring.LineString[source]¶
-
openlr_dereferencer.maps.wgs84.line_string_length(line_string: shapely.geometry.linestring.LineString) → float[source]¶ Returns the length of a line string in meters
-
openlr_dereferencer.maps.wgs84.split_line(line: shapely.geometry.linestring.LineString, meters_into: float) → Tuple[Optional[shapely.geometry.linestring.LineString], Optional[shapely.geometry.linestring.LineString]][source]¶ Splits a line at meters_into meters and returns the two parts. A part is None if it would be a Point
Module contents¶
This module describes the handling of maps. It provides an interface through which the decoder accesses the map.