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

OSM area processing obeys tag mapping #6164

Merged
merged 17 commits into from
Nov 8, 2024

Conversation

vesameskanen
Copy link
Contributor

@vesameskanen vesameskanen commented Oct 16, 2024

Summary

OSM parsing and graph building code always applied hard coded bicycle and pedestrian permissions to areas. Now the code uses the configured wayPropertySet and national tag mapping to define the permissions.

Secondly, detailed propertly rule for highway=footway;bicycle=yes;area=yes tag combination overruled simpler rules like plain highway=footway because the former rule often has more matching tags. This is a bit surprising because absence of bicycle=yes tag does not reduce scores. This problem is fixed by using ExactMatchSpecifier.

Thirdly, OSM tag mapping is a typical example of a situation where OOP works very well. Class hierarchy is now refactored to use very simple inheritance with a base class and national sub classes.

Issue

Closes #5354

Unit tests

Area permission tests for Finland and Germany tag mappers added.

Documentation

Updated.

Walkable area builder used hardcoded bike+pedestrial default permissions for area edges.
Now default permissions take tag mapping into account.
Rule whicgh assigns pedestrian permissions to transit platforms is
not enough, because another rule which contains more tags overrules it.
OSM tag mappers now use normal OOP inheritance. It is usually a bad idea to implement
classes directly from an inteface.
@vesameskanen vesameskanen requested a review from a team as a code owner October 16, 2024 07:38
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 99.48320% with 2 lines in your changes missing coverage. Please review.

Project coverage is 69.75%. Comparing base (ce9118c) to head (e6d383b).
Report is 133 commits behind head on dev-2.x.

Files with missing lines Patch % Lines
.../graph_builder/module/osm/WalkableAreaBuilder.java 90.90% 1 Missing ⚠️
...ripplanner/osm/tagmapping/ConstantSpeedMapper.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #6164      +/-   ##
=============================================
- Coverage      69.95%   69.75%   -0.20%     
+ Complexity     17756    17658      -98     
=============================================
  Files           1999     2006       +7     
  Lines          75500    75571      +71     
  Branches        7728     7734       +6     
=============================================
- Hits           52813    52718      -95     
- Misses         20013    20140     +127     
- Partials        2674     2713      +39     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leonardehrenfried
Copy link
Member

leonardehrenfried commented Oct 16, 2024

About your second point, this kind of fuzzy matching has caused me problems before, so I added

/**
* This specifier allows you to specify a very precise match. It will only result in a positive when
* _all_ key/value pairs match exactly.
* <p>
* It's useful when you want to have a long, very specific specifier that should only match a very
* limited number of ways.
* <p>
* If you'd use a {@link BestMatchSpecifier} then the likelihood of the long spec matching unwanted
* ways would be high.
*
* @see org.opentripplanner.osm.tagmapping.HoustonMapper
*/
public class ExactMatchSpecifier implements OsmSpecifier {

It think it could be helpful here.

There was talk about making it the default but we were scared of the unintended consequences.

@vesameskanen
Copy link
Contributor Author

I wonder if absence of a tag in BestMatchSpecifier should actually reduce match scores? Less than conflicting value but something at least.

@leonardehrenfried
Copy link
Member

I find BestMatchSpecifier quite confusing (for a while it was the only one we had) and would love to see it go away entirely. That said, there are probably improvements we can make to it.

Instead of adding competing best match rules, start using the well designed
exact match specifier. This may cause some unexpected changes but as the change
concerns only one specific rule, we should be able to deal with them,
@leonardehrenfried
Copy link
Member

And you need to resolve the conflicts.

.getOsmProvider()
.getWayPropertySet()
.getDataForWay(areaEntity);
wayData = areaEntity.getOsmProvider().getWayPropertySet().getDataForWay(areaEntity);
Copy link
Member

Choose a reason for hiding this comment

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

This way vs area thing here is slightly confusing, but I think it's a common problem that we use these way properties for areas as well so if we were to rename things, we would need to rename a lot of things.

Copy link
Member

Choose a reason for hiding this comment

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

It's a bit unfortunate that we now lose all history on this file but since we are combining two files, I think it's impossible to avoid some history being lost.

@vesameskanen vesameskanen merged commit f5466e8 into opentripplanner:dev-2.x Nov 8, 2024
5 checks passed
@vesameskanen vesameskanen deleted the area-permissions branch November 8, 2024 11:59
t2gran pushed a commit that referenced this pull request Nov 8, 2024
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.

Area processing ignores OSM tag mapping
4 participants