openlr_decoder
Advanced tools
Comparing version 0.4.1 to 0.5.0
import { formOfWay } from "./nodes"; | ||
export declare function checkFow(currentLinkFow: formOfWay, LRPFow: number): boolean | formOfWay.SingleCarriageway; | ||
export declare function checkFow(currentLinkFow: formOfWay, LRPFow: number): boolean; | ||
export declare function checkBearing(currentLinkBearing: number, LRPBearing: number, bearningError?: number): boolean; |
@@ -5,3 +5,2 @@ "use strict"; | ||
const nodes_1 = require("./nodes"); | ||
const OS_OPEN_ROADS = process.env["OS_OPEN_ROADS"] || false; | ||
// eslint-disable-next-line complexity | ||
@@ -14,3 +13,3 @@ function checkFow(currentLinkFow, LRPFow) { | ||
case 3: return currentLinkFow === nodes_1.formOfWay.SingleCarriageway; | ||
case 4: return OS_OPEN_ROADS ? currentLinkFow === nodes_1.formOfWay.Roundabout || nodes_1.formOfWay.SingleCarriageway : currentLinkFow === nodes_1.formOfWay.Roundabout; | ||
case 4: return currentLinkFow === nodes_1.formOfWay.Roundabout; | ||
case 5: return currentLinkFow === nodes_1.formOfWay.TrafficSquare; | ||
@@ -17,0 +16,0 @@ case 6: return currentLinkFow === nodes_1.formOfWay.SlipRoad; |
import Graph from "node-dijkstra"; | ||
import type { node, linkLookup, graphInput } from "./nodes"; | ||
export declare function buildLinkLookups(nodeCollection: Array<node>): { | ||
export declare function buildLinkLookups(nodeCollection: Array<node>, lfrc: number): { | ||
links: linkLookup; | ||
@@ -5,0 +5,0 @@ graphInput: graphInput; |
@@ -8,14 +8,14 @@ "use strict"; | ||
const node_dijkstra_1 = __importDefault(require("node-dijkstra")); | ||
function buildLinkLookups(nodeCollection) { | ||
function buildLinkLookups(nodeCollection, lfrc) { | ||
const linkLookup = {}; | ||
const graphInput = {}; | ||
nodeCollection.map(node => checkForEndpoints(node, linkLookup, graphInput)); | ||
nodeCollection.map(node => checkForEndpoints(node, linkLookup, graphInput, lfrc)); | ||
return { links: linkLookup, graphInput: graphInput }; | ||
} | ||
exports.buildLinkLookups = buildLinkLookups; | ||
function checkForEndpoints(node, linkLookup, graphInput) { | ||
function checkForEndpoints(node, linkLookup, graphInput, lfrc) { | ||
if (node.startLinks) | ||
node.startLinks.map(link => addLinkToGraph(link, linkLookup, graphInput)); | ||
node.startLinks.map(link => link.frc <= lfrc ? addLinkToGraph(link, linkLookup, graphInput) : null); | ||
else | ||
node.endLinks.map(link => addLinkToGraph(link, linkLookup, graphInput)); | ||
node.endLinks.map(link => link.frc <= lfrc ? addLinkToGraph(link, linkLookup, graphInput) : null); | ||
} | ||
@@ -22,0 +22,0 @@ function getGraph(input) { |
@@ -48,3 +48,4 @@ "use strict"; | ||
const nodesForGraph = yield (0, getCandidates_1.getNodesForGraph)(decodedOpenLR, collection); | ||
const lookups = (0, graph_1.buildLinkLookups)(nodesForGraph); | ||
const lfrc = decodedOpenLR.properties._points.properties.reduce((pre, lrp) => lrp.properties._lfrcnp > pre ? lrp.properties._lfrcnp : pre, 0); | ||
const lookups = (0, graph_1.buildLinkLookups)(nodesForGraph, lfrc); | ||
const graph = (0, graph_1.getGraph)(lookups.graphInput); | ||
@@ -51,0 +52,0 @@ return { graph: graph, linklookup: lookups.links }; |
{ | ||
"name": "openlr_decoder", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"description": "A general purpose road network OpenLR decoding solution", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
import {formOfWay} from "./nodes"; | ||
const OS_OPEN_ROADS = process.env["OS_OPEN_ROADS"] || false; | ||
// eslint-disable-next-line complexity | ||
@@ -12,3 +10,3 @@ export function checkFow(currentLinkFow: formOfWay, LRPFow: number){ | ||
case 3: return currentLinkFow === formOfWay.SingleCarriageway; | ||
case 4: return OS_OPEN_ROADS ? currentLinkFow === formOfWay.Roundabout || formOfWay.SingleCarriageway : currentLinkFow === formOfWay.Roundabout; | ||
case 4: return currentLinkFow === formOfWay.Roundabout; | ||
case 5: return currentLinkFow === formOfWay.TrafficSquare; | ||
@@ -15,0 +13,0 @@ case 6: return currentLinkFow === formOfWay.SlipRoad; |
import Graph from "node-dijkstra"; | ||
import type {node, linkLookup, nodeChildLink, graphInput} from "./nodes"; | ||
export function buildLinkLookups(nodeCollection: Array<node>) { | ||
export function buildLinkLookups(nodeCollection: Array<node>, lfrc: number) { | ||
const linkLookup = {}; | ||
const graphInput = {}; | ||
nodeCollection.map(node => checkForEndpoints(node, linkLookup, graphInput)); | ||
nodeCollection.map(node => checkForEndpoints(node, linkLookup, graphInput, lfrc)); | ||
return {links: linkLookup as linkLookup, graphInput: graphInput as graphInput}; | ||
} | ||
function checkForEndpoints(node: node, linkLookup: linkLookup, graphInput: graphInput){ | ||
function checkForEndpoints(node: node, linkLookup: linkLookup, graphInput: graphInput, lfrc: number){ | ||
if(node.startLinks) | ||
node.startLinks.map(link => addLinkToGraph(link, linkLookup, graphInput)); | ||
node.startLinks.map(link => link.frc <= lfrc ? addLinkToGraph(link, linkLookup, graphInput): null); | ||
else | ||
node.endLinks.map(link => addLinkToGraph(link, linkLookup, graphInput)); | ||
node.endLinks.map(link => link.frc <= lfrc ? addLinkToGraph(link, linkLookup, graphInput): null); | ||
} | ||
@@ -17,0 +17,0 @@ |
@@ -47,3 +47,4 @@ import { getLRP } from "./decodeLRP"; | ||
const nodesForGraph = await getNodesForGraph(decodedOpenLR, collection); | ||
const lookups = buildLinkLookups(nodesForGraph as unknown as node[]); | ||
const lfrc = decodedOpenLR.properties._points.properties.reduce((pre, lrp) => lrp.properties._lfrcnp > pre ? lrp.properties._lfrcnp: pre, 0); | ||
const lookups = buildLinkLookups(nodesForGraph as unknown as node[], lfrc); | ||
const graph = getGraph(lookups.graphInput); | ||
@@ -50,0 +51,0 @@ return { graph: graph, linklookup: lookups.links }; |
@@ -33,3 +33,3 @@ import {node} from "../src/nodes"; | ||
const nodeInput: node[] = nodesCollection as node[]; | ||
const result = buildLinkLookups(nodeInput); | ||
const result = buildLinkLookups(nodeInput, 7); | ||
assert.deepStrictEqual(result.links, linkLookup); | ||
@@ -45,3 +45,3 @@ assert.deepStrictEqual(result.graphInput, graphInput); | ||
const nodeInput: node[] = nodesCollection as node[]; | ||
const lookup = buildLinkLookups(nodeInput); | ||
const lookup = buildLinkLookups(nodeInput, 7); | ||
const graph = getGraph(lookup.graphInput); | ||
@@ -48,0 +48,0 @@ const path = graph.path("{E699D3DD-19C5-4705-BF19-C296FD2D429E}0", "{D61C07C8-5839-4EA1-A0A6-723A224B8BFA}0",{cost: true}); |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1276913
0