Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destination on one-way feature not possible #63

Open
andreasherzog opened this issue May 28, 2020 · 3 comments
Open

Destination on one-way feature not possible #63

andreasherzog opened this issue May 28, 2020 · 3 comments

Comments

@andreasherzog
Copy link

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.

@perliedman
Copy link
Owner

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?

@andreasherzog
Copy link
Author

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:

grafik

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:

grafik

Does this help to illustrate the issue?

@nemosmithasf
Copy link

nemosmithasf commented Dec 1, 2020

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.

  1. Its possible a regular calculation can return 0 without intending it
  2. The behaviour is inconsistent with returning a single value (vs an object of backward and forward)
  3. Its very difficult to debug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants