Skip to content

Commit

Permalink
Merge pull request github#17 from warerebel/github#16---Bugfix
Browse files Browse the repository at this point in the history
github#16 - Ensure map gets built with end nodes
  • Loading branch information
warerebel authored Aug 26, 2022
2 parents 83060b7 + 9c86a4d commit 08e1f23
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 8 additions & 1 deletion src/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ import type {node, linkLookup, nodeChildLink, graphInput} from "./nodes";
export function buildLinkLookups(nodeCollection: Array<node>) {
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);
}
Expand Down

0 comments on commit 08e1f23

Please sign in to comment.