Skip to content

Fix constant path details like leg_distance for very short routes with duplicate points - #3007

Merged
easbar merged 8 commits into
masterfrom
leg_distance_duplicate_point
May 16, 2024
Merged

easbar merged 8 commits into
masterfrom
leg_distance_duplicate_point

Conversation

@easbar

@easbar easbar commented May 14, 2024

Copy link
Copy Markdown
Member

We get this error:

throw new IllegalStateException("PathDetail list " + pdEntry.getKey() + " is inconsistent due to entries " + prevPD + " vs. " + list.get(i));
for routes with three points where the last two are identical. But only if the points are so close to each other that the resulting path has <=2 points. The root cause is that we do not set the interval boundaries for empty paths in ConstantDetailsBuilder correctly, but this bug is 'fixed' by the path simplification unless the simplification is disabled and if the route has more than two points (otherwise we return early here:
if (pointList.size() <= 2) {
pointList.makeImmutable();
return;
so the 'fix' does not happen).

Here I fixed this by correctly setting the interval boundaries in ConstantDetailsBuilder for empty paths. c.f. the special handling we introduced for empty paths here: #2924

@easbar easbar added the bug label May 14, 2024
@easbar easbar added this to the 10.0 milestone May 14, 2024

public Map.Entry<String, List<PathDetail>> build() {
return new MapEntry(getName(), pathDetails);
return new MapEntry<>(getName(), pathDetails);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We might also switch to using Map.entry(getName(), pathDetails) if we don't need mutability.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok, can you explain why? Btw I only added the diamond here and this is unrelated to the PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's using a value-based class behind the scenes with all the advantages that come with it: https://www.baeldung.com/java-value-based-classes

this is unrelated to the PR.

Yep. I have a bit of a bad habit of pointing at Java 9+ goodies when I see them.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok I meant my own change (adding the diamond) was already unrelated. Thanks for pointing out the Java 9+ option. But in this case I'll leave it as it is for now.

@karussell karussell 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! LGTM.
(there is some code commented out which should be removed)

@easbar

easbar commented May 16, 2024

Copy link
Copy Markdown
Member Author

there is some code commented out which should be removed

Yes, these were some consistency checks, but they still fail, because the behavior is still not consistent :) For path details other than leg_distance/weight/time we do not get an empty interval when there are duplicate points (#2924), but I'll fix this in another PR.

@easbar
easbar merged commit 5518a7c into master May 16, 2024
@easbar
easbar deleted the leg_distance_duplicate_point branch May 16, 2024 07:13

This branch was previously deployed

1 inactive deployment
benchmarks — 43aebaa6 Deployed May 16, 2024 by easbar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants