Skip to content

Commit 9c86a4d

Browse files
committed
github#16 - Ensure map gets built with end nodes
1 parent 83060b7 commit 9c86a4d

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openlr_decoder",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "A general purpose road network OpenLR decoding solution",
55
"keywords": [
66
"openlr",

src/graph.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ import type {node, linkLookup, nodeChildLink, graphInput} from "./nodes";
44
export function buildLinkLookups(nodeCollection: Array<node>) {
55
const linkLookup = {};
66
const graphInput = {};
7-
nodeCollection.map(node => node.startLinks.map(link => addLinkToGraph(link, linkLookup, graphInput)));
7+
nodeCollection.map(node => checkForEndpoints(node, linkLookup, graphInput));
88
return {links: linkLookup as linkLookup, graphInput: graphInput as graphInput};
99
}
1010

11+
function checkForEndpoints(node: node, linkLookup: linkLookup, graphInput: graphInput){
12+
if(node.startLinks)
13+
node.startLinks.map(link => addLinkToGraph(link, linkLookup, graphInput));
14+
else
15+
node.endLinks.map(link => addLinkToGraph(link, linkLookup, graphInput));
16+
}
17+
1118
export function getGraph(input: graphInput){
1219
return new Graph(input);
1320
}

0 commit comments

Comments
 (0)