Skip to content

Commit e92fbd3

Browse files
authored
Merge pull request github#18 from warerebel/github#7-Use-LFRC
github#7 use lfrc
2 parents 08e1f23 + 885e390 commit e92fbd3

File tree

7 files changed

+20
-14
lines changed

7 files changed

+20
-14
lines changed

Changelog

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased] - 2022-05-17
88
### Added
9-
- Initial module to decode openLR route
9+
- Initial module to decode openLR route
10+
11+
## [0.5.0] - 2022-08-30
12+
### Added
13+
- Restrict navigation to lowest frc in the LRP points
14+
15+
### Removed
16+
- Removed OS open roads specific workarounds, no support provided for OS open roads

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.1",
3+
"version": "0.5.0",
44
"description": "A general purpose road network OpenLR decoding solution",
55
"keywords": [
66
"openlr",

src/checkLinkProperties.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import {formOfWay} from "./nodes";
22

3-
const OS_OPEN_ROADS = process.env["OS_OPEN_ROADS"] || false;
4-
53
// eslint-disable-next-line complexity
64
export function checkFow(currentLinkFow: formOfWay, LRPFow: number){
75
switch(LRPFow){
86
case 0: return true;
97
case 1: return currentLinkFow === formOfWay.DualCarriageway || currentLinkFow === formOfWay.Motorway;
108
case 2: return currentLinkFow === formOfWay.DualCarriageway || currentLinkFow === formOfWay.Motorway;
119
case 3: return currentLinkFow === formOfWay.SingleCarriageway;
12-
case 4: return OS_OPEN_ROADS ? currentLinkFow === formOfWay.Roundabout || formOfWay.SingleCarriageway : currentLinkFow === formOfWay.Roundabout;
10+
case 4: return currentLinkFow === formOfWay.Roundabout;
1311
case 5: return currentLinkFow === formOfWay.TrafficSquare;
1412
case 6: return currentLinkFow === formOfWay.SlipRoad;
1513
case 7: return currentLinkFow === formOfWay.Other;

src/graph.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import Graph from "node-dijkstra";
22
import type {node, linkLookup, nodeChildLink, graphInput} from "./nodes";
33

4-
export function buildLinkLookups(nodeCollection: Array<node>) {
4+
export function buildLinkLookups(nodeCollection: Array<node>, lfrc: number) {
55
const linkLookup = {};
66
const graphInput = {};
7-
nodeCollection.map(node => checkForEndpoints(node, linkLookup, graphInput));
7+
nodeCollection.map(node => checkForEndpoints(node, linkLookup, graphInput, lfrc));
88
return {links: linkLookup as linkLookup, graphInput: graphInput as graphInput};
99
}
1010

11-
function checkForEndpoints(node: node, linkLookup: linkLookup, graphInput: graphInput){
11+
function checkForEndpoints(node: node, linkLookup: linkLookup, graphInput: graphInput, lfrc: number){
1212
if(node.startLinks)
13-
node.startLinks.map(link => addLinkToGraph(link, linkLookup, graphInput));
13+
node.startLinks.map(link => link.frc <= lfrc ? addLinkToGraph(link, linkLookup, graphInput): null);
1414
else
15-
node.endLinks.map(link => addLinkToGraph(link, linkLookup, graphInput));
15+
node.endLinks.map(link => link.frc <= lfrc ? addLinkToGraph(link, linkLookup, graphInput): null);
1616
}
1717

1818
export function getGraph(input: graphInput){

src/openLRDecode.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ async function getWinningNodes(decodedOpenLR: LRPObject, collectionName: string,
4444
async function buildGraph(decodedOpenLR: LRPObject, collectionName: string) {
4545
const collection = Mongo.getCollection(collectionName);
4646
const nodesForGraph = await getNodesForGraph(decodedOpenLR, collection);
47-
const lookups = buildLinkLookups(nodesForGraph as unknown as node[]);
47+
const lfrc = decodedOpenLR.properties._points.properties.reduce((pre, lrp) => lrp.properties._lfrcnp > pre ? lrp.properties._lfrcnp: pre, 0);
48+
const lookups = buildLinkLookups(nodesForGraph as unknown as node[], lfrc);
4849
const graph = getGraph(lookups.graphInput);
4950
return { graph: graph, linklookup: lookups.links };
5051
}

test/graph.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe("graph", function(){
3030

3131
it("returns graph lookup and link lookup", function(){
3232
const nodeInput: node[] = nodesCollection as node[];
33-
const result = buildLinkLookups(nodeInput);
33+
const result = buildLinkLookups(nodeInput, 7);
3434
assert.deepStrictEqual(result.links, linkLookup);
3535
assert.deepStrictEqual(result.graphInput, graphInput);
3636
});
@@ -41,7 +41,7 @@ describe("graph", function(){
4141

4242
it("Creates a navigable map object", function(){
4343
const nodeInput: node[] = nodesCollection as node[];
44-
const lookup = buildLinkLookups(nodeInput);
44+
const lookup = buildLinkLookups(nodeInput, 7);
4545
const graph = getGraph(lookup.graphInput);
4646
const path = graph.path("{E699D3DD-19C5-4705-BF19-C296FD2D429E}0", "{D61C07C8-5839-4EA1-A0A6-723A224B8BFA}0",{cost: true});
4747
assert.deepStrictEqual(path, {cost: 32, path: ["{E699D3DD-19C5-4705-BF19-C296FD2D429E}0", "{D61C07C8-5839-4EA1-A0A6-723A224B8BFA}0"]});

0 commit comments

Comments
 (0)