openlr_decoder
A general purpose OpenLR decoding solution for any suitable road network.
Introduction
OpenLR is a dynamic location reference standard to enable systems to exchange location information in a map-agnostic manner. For further info see OpenLR association.
This module provides a simple and performant solution to decode an openLR reference.
Dependencies
This module requires a mongodb database instance or an Azure Cosmos instance with support for mongodb api enabled.
Native support for Azure Cosmos will be provided in a future release.
Installation
Install the module with npm:
npm install openlr_decoder
Import the module
For commonjs:
const {decodeOpenLR, initMongo} = require("openlr_decoder");
For typescript:
import {decodeOpenLR, initMongo} from "openlr_decoder";
Example Usage
Initialise the mongodb connection with the mongodb url and database name.
Decode an OpenLR string providing the string, the mongodb collection name to use for the nodes, and options.
async main(){
await initMongo("mongodb://localhost:27017", "openlrdatabase");
const result = decodeOpenLr("C/+/+yY40CuxDAA6/WgrHw==", "nodescollection", {targetBearing: 25, searchRadius: 100});
}
Mongo Collection Design
The module expects the mongodb database to have a collection which contains only node documents. Each node should contain two arrays named startLinks and endLinks. The startLinks array contains links which start from this node and the endLinks array contains links which end at this node. An example of a single node is provided below:
{
"_id": "xyz",
"startLinks": [
"linkid":"abcd",
"fow": "SC",
"startnode":"xyz",
"endnode":"abc",
"frc": 2,
"cost": 312,
"bearing": 49.78040927384026
],
"endLinks": [
"linkid": "efgh",
"fow": "SC",
"startnode": "def",
"endnode": "xyz",
"frc": 2,
"cost": 312,
"bearing": 162.64822335654924
]
}
A complete ready to use set of OS open roads data in this format, extracted from a MongoDB collection, is provided for download here [TODO].
A fully worked example of getting an OpenLR service up and running is provided here [TODO].