Address comments from b89164c14e
(#2346)
This commit is contained in:
parent
64307ea882
commit
346146d834
@ -3,11 +3,11 @@ Feature: Traffic - turn penalties
|
|||||||
|
|
||||||
Background: Evenly spaced grid with multiple intersections
|
Background: Evenly spaced grid with multiple intersections
|
||||||
Given the node map
|
Given the node map
|
||||||
| | a | | b | |
|
| | a:1 | | b:2 | |
|
||||||
| c | d | e | f | g |
|
| c:3 | d:4 | e:5 | f:6 | g:7 |
|
||||||
| | h | | i | |
|
| | h:8 | | i:9 | |
|
||||||
| j | k | l | m | n |
|
| j:10 | k:11 | l:12 | m:13 | n:14 |
|
||||||
| | o | | p | |
|
| | o:15 | | p:16 | |
|
||||||
And the ways
|
And the ways
|
||||||
| nodes | highway |
|
| nodes | highway |
|
||||||
| ad | primary |
|
| ad | primary |
|
||||||
|
@ -47,18 +47,27 @@ module.exports = function () {
|
|||||||
|
|
||||||
var addNode = (name, ri, ci, cb) => {
|
var addNode = (name, ri, ci, cb) => {
|
||||||
if (name) {
|
if (name) {
|
||||||
if (name.length !== 1) throw new Error(util.format('*** node invalid name %s, must be single characters', name));
|
var nodeWithID = name.match(/([a-z])\:([0-9]*)/);
|
||||||
if (!name.match(/[a-z0-9]/)) throw new Error(util.format('*** invalid node name %s, must me alphanumeric', name));
|
if (nodeWithID) {
|
||||||
|
var nodeName = nodeWithID[1],
|
||||||
var lonLat;
|
nodeID = nodeWithID[2];
|
||||||
if (name.match(/[a-z]/)) {
|
if (this.nameNodeHash[nodeName]) throw new Error(util.format('*** duplicate node %s', name));
|
||||||
if (this.nameNodeHash[name]) throw new Error(util.format('*** duplicate node %s', name));
|
|
||||||
lonLat = this.tableCoordToLonLat(ci, ri);
|
lonLat = this.tableCoordToLonLat(ci, ri);
|
||||||
this.addOSMNode(name, lonLat[0], lonLat[1], null);
|
this.addOSMNode(nodeName, lonLat[0], lonLat[1], nodeID);
|
||||||
} else {
|
} else {
|
||||||
if (this.locationHash[name]) throw new Error(util.format('*** duplicate node %s'), name);
|
if (name.length !== 1) throw new Error(util.format('*** node invalid name %s, must be single characters', name));
|
||||||
lonLat = this.tableCoordToLonLat(ci, ri);
|
if (!name.match(/[a-z0-9]/)) throw new Error(util.format('*** invalid node name %s, must me alphanumeric', name));
|
||||||
this.addLocation(name, lonLat[0], lonLat[1], null);
|
|
||||||
|
var lonLat;
|
||||||
|
if (name.match(/[a-z]/)) {
|
||||||
|
if (this.nameNodeHash[name]) throw new Error(util.format('*** duplicate node %s', name));
|
||||||
|
lonLat = this.tableCoordToLonLat(ci, ri);
|
||||||
|
this.addOSMNode(name, lonLat[0], lonLat[1], null);
|
||||||
|
} else {
|
||||||
|
if (this.locationHash[name]) throw new Error(util.format('*** duplicate node %s'), name);
|
||||||
|
lonLat = this.tableCoordToLonLat(ci, ri);
|
||||||
|
this.addLocation(name, lonLat[0], lonLat[1], null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cb();
|
cb();
|
||||||
|
@ -3,10 +3,10 @@ Feature: Traffic - turn penalties applied to turn onto which a phantom node snap
|
|||||||
|
|
||||||
Background: Simple map with phantom nodes
|
Background: Simple map with phantom nodes
|
||||||
Given the node map
|
Given the node map
|
||||||
| | 1 | | 2 | | 3 | |
|
| | 1 | | 2 | | 3 | |
|
||||||
| a | | b | | c | | d |
|
| a:1 | | b:2 | | c:3 | | d:4 |
|
||||||
| | | | | | | |
|
| | | | | | | |
|
||||||
| | | e | | f | | g |
|
| | | e:5 | | f:6 | | g:7 |
|
||||||
And the ways
|
And the ways
|
||||||
| nodes | highway |
|
| nodes | highway |
|
||||||
| ab | primary |
|
| ab | primary |
|
||||||
|
@ -398,7 +398,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
|||||||
|
|
||||||
// Since it's possible duration_until_turn can be less than source_weight here if
|
// Since it's possible duration_until_turn can be less than source_weight here if
|
||||||
// a negative enough turn penalty is used to modify this edge weight during
|
// a negative enough turn penalty is used to modify this edge weight during
|
||||||
// osrm-contract, we clamp to 1 here so as not to return a negative duration
|
// osrm-contract, we clamp to 0 here so as not to return a negative duration
|
||||||
// for this segment.
|
// for this segment.
|
||||||
|
|
||||||
// TODO this creates a scenario where it's possible the duration from a phantom
|
// TODO this creates a scenario where it's possible the duration from a phantom
|
||||||
|
Loading…
Reference in New Issue
Block a user