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

Implemented forcing routes at start, via and end points into a certain direction #434

Merged
merged 1 commit into from Jun 9, 2015

Conversation

jansoe
Copy link
Contributor

@jansoe jansoe commented Jun 3, 2015

still to do

  • handle case of query graph request at tower nodes
  • tests

@karussell
Copy link
Member

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)
Copy link
Member

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

@devemux86
Copy link
Contributor

👍
Is this related to #225 ?

@jansoe
Copy link
Contributor Author

jansoe commented Jun 3, 2015

Yes (but will not work with CH')

/**
* set edgeId disprefered (in direction adjNodeId)
*/
public void setDispreferedEdge(int edgeId, int adjNodeId)
Copy link
Member

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?

Copy link
Contributor Author

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.

@jansoe
Copy link
Contributor Author

jansoe commented Jun 4, 2015

regarding the wording: i liked the dichotomy of preferredDirection vs. dispreferredEdge, so shall we do now superiorDirectionand inferiorEdge ? Or what do you think of favoredDirection and unfavoredEdge?

@karussell
Copy link
Member

this is good: 'favoredDirection and unfavoredEdge'

@karussell
Copy link
Member

setDispreferedEdge(int edgeId, int adjNodeId)
this method is requiered 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.

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 paths.get(placeIndex - 2).getFinalEdge()?

Also for me QueryGraph.setDispreferedEdge is misleading as it suggests one can set any edge but then throws exception for none-virtual edges.

Include instructions for UTurn at start

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

@jansoe
Copy link
Contributor Author

jansoe commented Jun 4, 2015

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

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.
Regarding your suggestion to use one method for both, its sounds like putting two things together which do not belong together (I exaggerate here a bit, but in the end it has to look similar like this)

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 setDispreferedEdge in setUnfavoredVirtualEdge should make the usage much more clear

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 :)

@jansoe
Copy link
Contributor Author

jansoe commented Jun 4, 2015

BTW: why -2 in paths.get(placeIndex - 2).getFinalEdge()

placeIndex is initialised by 1, that is for placeIndex==1 the first path is calculated and then stored in the list pathes at the first position (i.e. at 0 with a zero based index). This path is not affected by the requirement for straight via routing.
Then for the next path, i.e. placeIndex==2, we have to get the final edge of the previous path (which is the first path and stored at the 0th position in the pathes list). Therefore it is at position 2-2=0.

@jansoe
Copy link
Contributor Author

jansoe commented Jun 4, 2015

Include instructions for UTurn at start

Why only at start?

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

@jansoe jansoe mentioned this pull request Jun 4, 2015
@jansoe
Copy link
Contributor Author

jansoe commented Jun 5, 2015

open questions:

  • _default in EdgeIteratorState.getBoolean()? -> kept!
  • location of K_UNFAVORED_EDGE? -> kept in EdgeItaretorState!
  • 2 methods queryGraph.favorDirection and queryGraph.unfavorEdge? -> similar method enforceDirection and enforceDirectionByEdgeId

@jansoe
Copy link
Contributor Author

jansoe commented Jun 5, 2015

  • fix bug: direction parameters do not do not influence result for route? endpoint
    bug was in test :)

@jansoe
Copy link
Contributor Author

jansoe commented Jun 5, 2015

renamed direction parameter to heading

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"));
Copy link
Member

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 :)

@karussell
Copy link
Member

Looks now good to me!

@jansoe jansoe force-pushed the directions branch 2 times, most recently from 52a5cf8 to 9567a7e Compare June 8, 2015 16:00
@jansoe
Copy link
Contributor Author

jansoe commented Jun 8, 2015

On my behalf, I'm done

@karussell
Copy link
Member

Would you mind to squash once again :) and move MyTest into the normal (j)unit testing?

@jansoe
Copy link
Contributor Author

jansoe commented Jun 8, 2015

and move MyTest into the normal (j)unit testing

uups, this should not have been comited , will remove it

@devemux86
Copy link
Contributor

I'm wondering if it's worth it to have also elsewhere the angle in human friendly degrees (0, 360) e.g. like here

@karussell
Copy link
Member

Hmmh, yes this should also be changed but probably in another issue: #424

@jansoe the problem is now that turn_angle is in radian and already included in the json :(

@karussell
Copy link
Member

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 :) !

@devemux86
Copy link
Contributor

I generally vote for using SI units in engines, though degrees (0-360) is the common way for angles.
Users can always convert the returned values later to their liking.

Of course you are right about existing implementation, an established API is hard to change.

@karussell
Copy link
Member

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 ;))

@jansoe
Copy link
Contributor Author

jansoe commented Jun 9, 2015

I vote for using degrees in this PR, and sometime, with other major changes, also swap radians in roundabouts.

karussell added a commit that referenced this pull request Jun 9, 2015
Implemented a heading and pass_through parameter for all points
@karussell karussell merged commit edf9bec into graphhopper:master Jun 9, 2015
@karussell
Copy link
Member

Thanks a lot @jansoe ! Merged!

@karussell karussell added this to the 0.5 milestone Jun 9, 2015
@karussell
Copy link
Member

BTW: should we throw an UnsupportedException if someone wants to use it with CH?

@jansoe
Copy link
Contributor Author

jansoe commented Jun 9, 2015

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 ....

@devemux86
Copy link
Contributor

Great work @jansoe for a valuable feature!

@karussell
Copy link
Member

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?

@karussell karussell changed the title Directions Implemented forcing routes at start, via and end points into a certain direction Jul 13, 2015
@karussell karussell deleted the directions branch July 30, 2015 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants