diff --git a/package-lock.json b/package-lock.json index d701ac49c5e9..3a2075541c61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "openlr_decoder", - "version": "0.2.0", + "version": "0.4.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5b70bfcd451a..96b29a750275 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openlr_decoder", - "version": "0.4.0", + "version": "0.4.1", "description": "A general purpose road network OpenLR decoding solution", "keywords": [ "openlr", diff --git a/src/graph.ts b/src/graph.ts index 8d874bab66e4..34741452c18e 100644 --- a/src/graph.ts +++ b/src/graph.ts @@ -4,10 +4,17 @@ import type {node, linkLookup, nodeChildLink, graphInput} from "./nodes"; export function buildLinkLookups(nodeCollection: Array) { const linkLookup = {}; const graphInput = {}; - nodeCollection.map(node => node.startLinks.map(link => addLinkToGraph(link, linkLookup, graphInput))); + nodeCollection.map(node => checkForEndpoints(node, linkLookup, graphInput)); return {links: linkLookup as linkLookup, graphInput: graphInput as graphInput}; } +function checkForEndpoints(node: node, linkLookup: linkLookup, graphInput: graphInput){ + if(node.startLinks) + node.startLinks.map(link => addLinkToGraph(link, linkLookup, graphInput)); + else + node.endLinks.map(link => addLinkToGraph(link, linkLookup, graphInput)); +} + export function getGraph(input: graphInput){ return new Graph(input); }