Repository navigation
Added tolerance adjustment in HeadingResolver - #2482
kylemikableh wants to merge 4 commits into
Conversation
easbar
left a comment
There was a problem hiding this comment.
Thanks a lot for contributing to GraphHopper and sending your first contribution. I think you did a good job here. You picked an open issue, and even one that has the good first issue label (Is this the reason you picked this specific issue?) You sent a PR that provides an isolated fix for this issue, without making changes to unrelated code. You also provided some tests for your new feature and explained what you did. 👍
However, quite unfortunately, things kept moving since we opened the corresponding issue #1646 three years ago. Therefore, we currently do not want to add the heading tolerance, mostly because we do not think it is of much use (contrary to what we thought back then). This is probably rather disappointing for you, maybe even more so, because it took us a while to respond. But I hope you can understand that this is how it goes sometimes in open source programming. I think it is mostly our fault to not have removed the 'good first issue' label for this issue. The only thing you could do better next time is asking if a certain feature is still of interest next time.
I tried my best giving you some feedback in the review comments below, I hope this will be of some help for you.
I'm closing here now, but if you still think this feature is important for some use-cases please feel free to explain and we can re-open then. I'm currently assuming you picked this issue, because it was there, not because you are using the feature yourself (?!)
| //Added constructor to allow configuration of the tolerance (issue #1646) | ||
| public HeadingResolver(Graph graph, int toleranceDec) { | ||
| this.edgeExplorer = graph.createEdgeExplorer(); | ||
| toleranceRad = Math.toRadians(toleranceDec); |
There was a problem hiding this comment.
Such comments, like "Added constructor..." are nice for a reviewer to understand what your attention was, but you can just add them here in github and they typically should not remain in the code directly. I mean stating your intention in comments can be a good thing, but for something simple like a new constructor it is not necessary, it is already clear when looking at the constructor parameters that this constructor allows setting the tolerance.
Another thing: It is usually a good idea to chain the constructors. Here the first one could just call the other like this(graph, 100) for example.
| throw new IllegalArgumentException("Alternative paths do not support the " + CURBSIDE + " parameter yet"); | ||
|
|
||
| ViaRouting.Result result = ViaRouting.calcPaths(request.getPoints(), queryGraph, snaps, solver.weighting, pathCalculator, request.getCurbsides(), forceCurbsides, request.getHeadings(), passThrough); | ||
| ViaRouting.Result result = ViaRouting.calcPaths(request.getPoints(), queryGraph, snaps, solver.weighting, pathCalculator, request.getCurbsides(), forceCurbsides, request.getHeadings(), passThrough, tolerance); |
There was a problem hiding this comment.
In this context it would be good to indicate the tolerance is related to the heading, I would just call it headingTolerance (here and in GHRequest).
| int tolerance = 80; | ||
| Router router = createRouter(graph); |
There was a problem hiding this comment.
In this test I would calculate two routes with two different values for the tolerance. This way we can be sure the tolerance actually makes a difference (now and in the future when some of the code changes).
| public class GHRequest { | ||
| private List<GHPoint> points; | ||
| private String profile = ""; | ||
| private final int DEFAULT_TOLERANCE = 100; //Default tolerance that can be changed |
There was a problem hiding this comment.
Typically such constants should be static. But since this one is not really used anywhere else you could also just write private int tolerance = 100 below.
This references issue #1646 which wanted to be able to adjust the tolerance of the heading. This is my first contribution I am sure I did something wrong!