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

Speed up path simplification with path details/instructions - fixed #1802

Merged
merged 21 commits into from
Nov 20, 2019

Conversation

easbar
Copy link
Member

@easbar easbar commented Nov 20, 2019

This is a revised version of the previously reverted #1782 and should fix #1764.
When trying to update the navigation sdk it turned out the point lists for via- and finish instructions were empty after #1782, which makes problems for both navigation and map matching. For via- and finish-instructions the pointlists must contain a single point even though their instruction.getLength() is zero. I have now fixed this and navigation and map-matching tests are green with this change.

Comment on lines +84 to +98
@Override
public void setInterval(int index, int start, int end) {
Instruction instruction = instructions.get(index);
if (instruction instanceof ViaInstruction || instruction instanceof FinishInstruction) {
if (start != end) {
throw new IllegalStateException("via- and finish-instructions are expected to have zero length");
}
// have to make sure that via instructions and finish instructions contain a single point
// even though their 'instruction length' is zero.
end++;
}
instruction.setPoints(pointList.shallowCopy(start, end, false));
}
});
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the fix compared to #1782. For via and finish instructions I increase the interval length, such that they contain a single point. Pretty ugly...

Copy link
Member

Choose a reason for hiding this comment

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

But isn't this similar to how point count and edge count behave? E.g. a path with 1 edge contains 2 points and so 0 edge has 1 point? Hmmh, but yes. A JSON line of 1 point is not allowed.

Copy link
Member Author

Choose a reason for hiding this comment

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

But isn't this similar to how point count and edge count behave? E.g. a path with 1 edge contains 2 points and so 0 edge has 1 point? Hmmh, but yes. A JSON line of 1 point is not allowed.

Ah you mean instruction length = number of edges of the interval ? Yes this works, but like you say for a single point its a bit unclear.

Copy link
Member

Choose a reason for hiding this comment

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

Yes. It is similar, so if you have a Via- or FinishInstruction it should still have a location (one point) but no extent or distance.

Comment on lines 1502 to 1503
assertEquals(expectedLength, instruction.getLength());
assertEquals(expectedPoints, instruction.getPoints().size());
Copy link
Member Author

Choose a reason for hiding this comment

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

Compared to #1782 here I am now testing the instruction length and instructions' point list size separately, because they are different for via and finish instructions.

@easbar
Copy link
Member Author

easbar commented Nov 20, 2019

I think this can be merged, but maybe its better to wait for graphhopper/map-matching#160 and release before merging this.

@karussell
Copy link
Member

karussell commented Nov 20, 2019

I think I'll just release 1.0-pre7.1 for the map matching bug fix. IMO no need to delay this here. Or do we need something from core?

@easbar
Copy link
Member Author

easbar commented Nov 20, 2019

No we can wait a bit until tagging 1.0-pre8

@easbar easbar merged commit 73c1790 into master Nov 20, 2019
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.

Path simplification is very slow compared to routing
2 participants