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

Fix #23708 Only check restrictions with subtypes #68

Merged
merged 4 commits into from
Jun 5, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1120,16 +1120,17 @@ boolean isRestricted(Way currentWay, Way previousWay, Node commonNode) {
else if (rel.hasTag("type", "restriction") && rel.hasKey("restriction"))
return false;
else {
boolean remove = true;
String routeValue = relation.get("route");
for (String s : restrictions) {
if (s.length() <= 12)
continue;
String sub = s.substring(12);
if (routeValue.equals(sub) && rel.hasTag("type", s))
Copy link
Member

@floscher floscher Jun 4, 2024

Choose a reason for hiding this comment

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

@michaelabon Sure, I was a bit in a rush earlier. This would be how it could be written:

Suggested change
String routeValue = relation.get("route");
for (String s : restrictions) {
if (s.length() <= 12)
continue;
String sub = s.substring(12);
if (routeValue.equals(sub) && rel.hasTag("type", s))
final String routeValue = Optional.ofNullable(relation.get("route")).map(it -> "restriction:" + it).orElse("");
for (String s : restrictions) {
if (routeValue.equals(s) && rel.hasTag("type", s))

So previously the prefix restriction: was removed from s and then compared with routeValue.

But now we prepend the prefix restriction: to routeValue and then compare it with s.

remove = false;
return false;
else if (routeValue.equals(sub) && rel.hasKey("restriction:" + sub))
floscher marked this conversation as resolved.
Show resolved Hide resolved
remove = false;
return false;
}
return remove;
return true;
}
});

Expand Down
Loading