Skip to content

Added tolerance adjustment in HeadingResolver - #2482

Closed
kylemikableh wants to merge 4 commits into
graphhopper:masterfrom
kylemikableh:dev
Closed

kylemikableh wants to merge 4 commits into
graphhopper:masterfrom
kylemikableh:dev

Conversation

@kylemikableh

Copy link
Copy Markdown

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!

@easbar easbar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (?!)

Comment on lines +36 to +39
//Added constructor to allow configuration of the tolerance (issue #1646)
public HeadingResolver(Graph graph, int toleranceDec) {
this.edgeExplorer = graph.createEdgeExplorer();
toleranceRad = Math.toRadians(toleranceDec);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +173 to +174
int tolerance = 80;
Router router = createRouter(graph);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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

Successfully merging this pull request may close these issues.

2 participants