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
Implemented forcing routes at start, via and end points into a certain direction #434
Conversation
Thanks! The U-turn instruction should be made also for via points, but we should move this out of this issue: #289 Will comment inline... |
} | ||
|
||
public GHRequest addPoint( GHPoint point ) | ||
public GHRequest addPoint( GHPoint point , Double preferredDirection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the comment regarding the unit of preferredDirection should go here
👍 |
Yes (but will not work with CH') |
/** | ||
* set edgeId disprefered (in direction adjNodeId) | ||
*/ | ||
public void setDispreferedEdge(int edgeId, int adjNodeId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to find a better name (also preferred) or maybe setInferiorEdge? And the sout statements should be removed. And do we really need to make this low level method public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method is required to disprefer the incoming edge at via points.
one could achieve this also by calculating the incoming azimuth, and then use the above method. But in my feeling this would be a quite indirect.
The other way would to directly modify the edge. But here the method assures that both incoming and outgoing virtual Edge are affected.
regarding the wording: i liked the dichotomy of |
this is good: 'favoredDirection and unfavoredEdge' |
Hmmh, not sure what you mean here. I would prefer to have just two simple methods in QueryGraph: enforceDirection and dropDirectionEnforcement without any ifs before but probably with more required parameters. Even if we pass the endEdge if it is not necessary. BTW: why -2 in Also for me
Why only at start? E.g. if costs are low u-turn can happen also elsewhere. But again: we should move this out of this issue and into: #289 |
I mean, the two methods are applied in two different scenarios. In the one scenario I know only the direction I want to prefer, in the other scenario I have no clue which direction I want to prefer but already know the edge to disprefer. One could use the information in the second scenario, extract from the edge an direction, and then use this direction to feed it into the first scenario. But I dislike this, as it is unnecessary computational overhead. favorDirectionOrUnfavorVirtualEdge(double favoredDirection, QueryResult queryPoint, boolean incoming, EdgeIteratorState unfavoredEdge)
{ if (unfavoredEdge == EdgeIteratorState.NO_EDGE)
{
favor direction
}
else
{
unvafor edge
} To be more constructive, (1) in the GraphHopper Class I can remove a lot of ifs by doing all the validity checking within the QueryGraph and (2) a rename of This are my two cents, but if I still could not convince you, I will implement it like this, since you have the bigger picture in mind :) |
|
Here my reasoning was, that u-turns at via points are old behaviour. But with this code u-turns also can occur at start, which did not existed before. Therefore I regarded it as part of this issue, whereas the other u-turns seemed not directly related to this code. But now I removed also the start u-turns to issue #289 |
open questions:
|
|
renamed |
ghRsp.addError(new IllegalArgumentException("Elevation not supported!")); | ||
} else if (favoredHeadings.size()>1 && favoredHeadings.size() != infoPoints.size()) | ||
{ | ||
ghRsp.addError(new IllegalArgumentException("#heading must be <=1 or equal #points")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I slightly prefer number of
over #xy
:)
Looks now good to me! |
52a5cf8
to
9567a7e
Compare
On my behalf, I'm done |
Would you mind to squash once again :) and move MyTest into the normal (j)unit testing? |
uups, this should not have been comited , will remove it |
I'm wondering if it's worth it to have also elsewhere the angle in human friendly degrees (0, 360) e.g. like here |
I would prefer consistent angles, and we can't revert turn_angle using degree without breaking several clients OR introducing two versions of the API for the switchover (see new #437). And as we already have an 'inconsistent state' (GPX export is using degree for gh:azimuth) I vote to keep using degree here and fix turn_angle via #437 later. Please vote for or against this :) ! |
I generally vote for using SI units in engines, though degrees (0-360) is the common way for angles. Of course you are right about existing implementation, an established API is hard to change. |
thanks. and yes, I would not have a problem with breaking the Java API (maybe we should do this even earlier) because this is relative easy to detect and fix for consuming developers, but the JSON API can't be changed as easily (this is what we now feel ourself with running the GH Directions API ;)) |
I vote for using degrees in this PR, and sometime, with other major changes, also swap radians in roundabouts. |
Implemented a heading and pass_through parameter for all points
Thanks a lot @jansoe ! Merged! |
BTW: should we throw an UnsupportedException if someone wants to use it with CH? |
I'm undecided. On the one hand it will also work with CH in many cases, on the other hand, you sometimes get this artefacts .... |
Great work @jansoe for a valuable feature! |
Yeah, me too. Still the problem is that CH is the default and people will report this as bug although this is 'known'. Maybe we throw an exception but allow via parameter in the GraphHopper class to make it still working? |
still to do