Destination on one-way feature not possible
andreasherzog opened this issue · 3 comments
First off, I really like this library, it works well and fast. Thanks for maintaining.
I am using it to calculate paths in a self-recorded network. After some adjustments to the network, it does what we need.
However, when I add one-way features, I cannot get a path if the destination is on that one-way feature. The start can be placed on it and it works. Also, the one-way feature is included for "through" paths that have a working destination.
I am using this weightFunction:
weightFunction = (a, b, props) => {
const distance = turf.distance(turf.point(a), turf.point(b)) * 1000;
let forward = distance;
let backward = distance;
if (props.oneway && props.oneway === true) {
backward = 0;
} else if (props.oneway && props.oneway === 'backward') {
forward = 0;
}
return {
forward: forward,
backward: backward,
};
};
My features can have a "oneway" property that is set to true if the feature should be one-way. I do not use the "backward" value at the moment. If I remove the "oneway" property, I can place the destination on the feature with no issue.
Any guidance would be dearly appreciated.
Hi, sorry about a late reply, but is there any chance you could publish an example, or at least a network, that exhibits this problem?
Hi, sorry for replying late.
Actually, you can try this out on your example page by putting the destination "B" on Road "Oscarsleden" - which is a road with separated lanes for each direction:
However, this road is part of the network and can be used for "passing-through" if you put your destination on a two-way road:
Does this help to illustrate the issue?
Ran into a similar problem; check if there are any line segments that unintentionally return "0" in your calculation.
On a side note, I think from a design perspective; its a mistake to have "0" mean impassible.
- Its possible a regular calculation can return 0 without intending it
- The behaviour is inconsistent with returning a single value (vs an object of backward and forward)
- Its very difficult to debug