Crate openlr

Crate openlr 

Source
Expand description

§OpenLR Rust implementation

Binary (and Base64) ser/deserialization of OpenLR Location References (version 3) with basic support for line encoder and decoder capabilities.

White Paper

Reference Implementation (Java)

§License

Licensed under either of

  • MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
  • Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)

§Examples

§Serialization
use openlr::{Coordinate, LocationReference, deserialize_base64_openlr, serialize_base64_openlr};

let location = LocationReference::GeoCoordinate(Coordinate {
    lon: 13.090918,
    lat: 52.466884,
});

let encoded: String = serialize_base64_openlr(&location).unwrap();
let decoded: LocationReference = deserialize_base64_openlr(&encoded).unwrap();
§Decoding and Encoding
use openlr::{
    DecoderConfig, DirectedGraph, EncoderConfig, Location, decode_base64_openlr, encode_base64_openlr
};

struct RoadNetworkGraph;

type VertexId = i64;
type EdgeId = i64;

impl DirectedGraph for RoadNetworkGraph {
    type VertexId = VertexId;
    type EdgeId = EdgeId;

    // TODO: implement DirectedGraph methods
}

let graph = RoadNetworkGraph;

let location: Location<EdgeId> =
    decode_base64_openlr(&DecoderConfig::default(), &graph, "CwmShiVYczPJBgCs/y0zAQ==").unwrap();

let location: String =
    encode_base64_openlr(&EncoderConfig::default(), &graph, location).unwrap();

Structs§

Bearing
The bearing describes the angle between the true North and the road. The physical data format defines the bearing field as an integer value between 0 and 360 whereby “0” is included and “360” is excluded from that range.
Circle
A circle location is given by the position of the center and the radius. The center position is a geo-coordinate pair of longitude and latitude coordinate values that can be everywhere on the surface. The radius is integer-valued and given in meters.
ClosedLine
A closed line location references the area defined by a closed path (i.e. a circuit) in the road network. The boundary always consists of road segments.
Coordinate
Coordinate pair stands for a pair of WGS84 longitude (lon) and latitude (lat) values. This coordinate pair specifies a geometric point in a digital map. The lon and lat values are stored in decamicrodegree resolution (five decimals).
DecoderConfig
EncoderConfig
Grid
A grid location is a special instance of a rectangle location. It is given by a base rectangular shape. This base rectangle is the lower left cell of the grid and can be multiplied to the North (by defining the number of rows) and to the East (by defining the number of columns).
GridSize
Length
Line
A line location reference describes a path within a map and consists of location reference point(s), a last location reference point and offset data. There must be at least one location reference point and exactly one last location reference point. The offset field is optional.
LineAttributes
Line attributes are part of a location reference point and consist of functional road class (FRC), form of way (FOW) and bearing (BEAR) data.
LineLocation
Location (in a map) that represents a Line Location Reference.
Offset
Offsets are used to locate the start and end of a location more precisely than bounding to the nodes in a network. The logical format defines two offsets, one at the start of the location and one at the end of the location. Both offsets operate along the lines of the location and are measured in meters. The offset values are optional and a missing offset value means an offset of 0 meters.
Offsets
A positive offset (POFF) is used to locate the precise start of a location. The POFF defines the distance between the start of the location reference path and the start of the location. The negative offset (NOFF) is used to locate the precise end of the location and it defines the distance between the end of the location and the end of the location reference path.
PathAttributes
The path attributes are part of a location reference point (except for the last location reference point) and consists of lowest functional road class to next point (LFRCNP) and distance to next point (DNP) data.
Poi
Point along line with access is a point location which is defined by a line, an offset value and a coordinate. The line will be referenced by two location reference points and the concrete position of the access point on that line is referenced using the positive offset. The point of interest is identified by the coordinate pair. Additionally information about the side of the road where the point is located and the orientation with respect to the direction of the line can be added.
Point
The basis of a location reference is a sequence of location reference points (LRPs). A single LRP may be bound to the road network. In such a case all values of the LRP refer to a node or line within the road network. The coordinates refer to a node of a line or a point on a line and the additional attributes refer to attributes of a line.
PointAlongLine
Point along line is a point location which is defined by a line and an offset value. The line will be referenced by two location reference points and the concrete position on that line is referenced using the positive offset. Additionally information about the side of the road where the point is located and the orientation with respect to the direction of the line can be added.
Polygon
A polygon location is a non-intersecting shape defined by a sequence of geo-coordinate pairs. The coordinate pairs can be everywhere on the surface. They define the corners of the underlying geometrical polygon. The boundary of this polygon is constituted by straight lines between every pair of consecutive corners in the sequence, plus the straight line between the last and the first corner. The minimum number of coordinate pairs is three and there exists no maximum number.
RatingScore
Rectangle
A rectangle location reference consists of the lower left corner point as a pair of WGS84 coordinates in absolute format and the upper right corner point, given in absolute format (large rectangle) or relative format (standard rectangle).

Enums§

DecodeError
DeserializeError
EncoderError
Fow
Form of Way. The form of way (FOW) describes the physical road type of a line.
Frc
Functional Road Class. The functional road class (FRC) of a line is a road classification based on the importance of the road represented by the line.
Location
Defines a location (in a map) that can be encoded using the OpenLR encoder and is also the result of the decoding process.
LocationError
LocationReference
Locations are objects in a digital map, like points, paths and areas. OpenLR standard can handle line locations (e.g. paths), point locations (e.g. POIs) and area locations (e.g. regions) in a digital map. OpenLR can handle locations which are bound to the road network but also locations which can be everywhere on earth (not bound to the road network). A line location is an example for a location which is bound to the road network and a simple geo-coordinate is an example for a location which is not bound to the road network. The main idea for locations which are bound to the road network is covering the location with a concatenation of (several) shortest-paths. The concatenation of such shortest-paths shall cover the location completely. Each shortest-path is specified by information about its start line and its end line. This information is combined in the location reference points (LRPs). The LRPs are ordered from the start of the location to the end of the location and the shortest-path between two subsequent LRPs covers a part of the location. The concatenation of all these shortest-paths covers the location completely and this path is called the location reference path. The location reference path may be longer than the original location and offsets trim this path down to the size of the location path. Offsets are also used to define a location on a line more precisely (e.g. point locations along a line) than using the start and end node of that line.
LocationType
Orientation
The orientation information (ORI) describes the relationship between the point of interest and the direction of a referenced line.
Rating
SerializeError
SideOfRoad
The side of road information (SOR) describes the relationship between the point of interest and a referenced line.

Traits§

DirectedGraph
Directed graph. Exposes the behavior of a Geospatial Index and of a Road Network Graph. Should be implemented by the graph the represents the map the decoder and encoder run on.

Functions§

decode_base64_openlr
Decodes an OpenLR Location Reference encoded in Base64.
decode_binary_openlr
Decodes an OpenLR Location Reference encoded in binary.
deserialize_base64_openlr
Deserializes an OpenLR Location Reference encoded in Base64.
deserialize_binary_openlr
Deserializes a binary representation of an OpenLR Location Reference.
encode_base64_openlr
Encodes an OpenLR Location Reference into Base64.
encode_binary_openlr
Encodes an OpenLR Location Reference into binary.
serialize_base64_openlr
Serializes an OpenLR Location Reference into Base64.
serialize_binary_openlr
Serializes an OpenLR Location Reference into binary.