New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

openlr_decoder

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openlr_decoder

A general purpose road network OpenLR decoding solution

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-71.05%
Maintainers
1
Weekly downloads
 
Created
Source

openlr_decoder

Coverage Status CodeQL Analysis Build and test

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:

// Further info on each property are provided in the documentation
{
    "_id": "xyz", // A unique ID for the node
    "startLinks": [
        //array of links
        "linkid":"abcd", // unique links id
        "fow": "SC", // Link form of way
        "startnode":"xyz", // the link's start node
        "endnode":"abc", // the link's end node
        "frc": 2, // the functional road class
        "cost": 312, // The length of the link in any unit
        "bearing": 49.78040927384026 // the bearing
    ],
    "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].

Keywords

FAQs

Package last updated on 27 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc