Generate documentation for OSM tag mappers#5929
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #5929 +/- ##
=============================================
+ Coverage 69.43% 69.62% +0.19%
- Complexity 17067 17128 +61
=============================================
Files 1935 1937 +2
Lines 73612 73740 +128
Branches 7540 7547 +7
=============================================
+ Hits 51115 51345 +230
+ Misses 19873 19757 -116
- Partials 2624 2638 +14 ☔ View full report in Codecov by Sentry. |
|
Sort menu items alphabetically |
|
@JohanEntur @tsobuskerudbyen Since you're going to be one of the main readers of this new documentation, can you take a look https://github.com/opentripplanner/OpenTripPlanner/blob/669da728640d42923220743277f7c4b78a3a8ed5/docs/osm/Norway.md and check this is helpful for you? Once this PR is merged, it will become part of the main OTP documentation and use the regular styling, rather than the Github one. |
|
It's a good overview to bypass reading the code. Still a complex set to grasp, but this is warmly welcomed. |
|
@JohanEntur Yes, it will not replace a programmer having to answer complicated questions but it will help casual users to figure out the answer to "Does OTP use tag X?". |
| private static Table propTable(WayPropertySet wps) { | ||
| var propTable = new TableBuilder(); | ||
| propTable.withHeaders("specifier", "permission", "bike safety", "walk safety"); | ||
|
|
||
| for (var prop : wps.getWayProperties()) { | ||
| propTable.addRow( | ||
| "`%s`".formatted(prop.specifier().toDocString()), | ||
| "`%s`".formatted(prop.properties().getPermission()), | ||
| tableValues(prop.properties().bicycleSafety()), | ||
| tableValues(prop.properties().walkSafety()) | ||
| ); | ||
| } | ||
| return propTable.build(); | ||
| } | ||
|
|
||
| private static Table mixinTable(WayPropertySet wps) { | ||
| var propTable = new TableBuilder(); | ||
| propTable.withHeaders("matcher", "bicycle safety", "walk safety"); | ||
|
|
||
| for (var prop : wps.getMixins()) { | ||
| propTable.addRow( | ||
| "`%s`".formatted(prop.specifier().toDocString()), | ||
| tableValues(prop.bicycleSafety()), | ||
| tableValues(prop.walkSafety()) | ||
| ); | ||
| } | ||
| return propTable.build(); | ||
| } |
There was a problem hiding this comment.
Should we apply some sort of sorting on these tables? I don't know what is the most logical one.
There was a problem hiding this comment.
Do you have a suggestion? Nothing comes to mind that could define a natural order.
We could make it visually pleasing by ordering them by whether they define bike safety, walk safety or both and then use alphabetic order as a tie breaker.
Personally, I would keep the insertion order but not opposed to another one.
There was a problem hiding this comment.
Yep lets just stick with the insertion order.
| } | ||
|
|
||
| record EqualsAnyIn(String key, String... values) implements Condition { | ||
| record OneOf(String key, String... values) implements Condition { |
There was a problem hiding this comment.
A bit of javadoc on these records wouldn't hurt as not all of these are instantly obvious.
|
Looks good, but the comment above is in a way good and should be written out in the top. Suggestion: "If a OpenStreetMap (OSM) tag is not part of the documentation under it is not used by OpenTripPlanner (OTP)." And what does an empty cell under the "bike safety" column man? E.g. for the |
This means that the bike safety is unaffected by this selector. I could have written "1" but that clutters up the table quite a bit. |
0772903 to
93a132a
Compare
|
|
||
| record EqualsAnyInOrAbsent(String key, String... values) implements Condition { | ||
| /** | ||
| * Selects a tag which has one of a set of given values or the tag is absent. |
There was a problem hiding this comment.
This is slightly difficult to read but I couldn't come up with a better way to formulate what this does.
…ecifier/Condition.java Co-authored-by: Joel Lappalainen <lappalj8@gmail.com>
5fe4c9c to
a9441a7
Compare
|
@tsobuskerudbyen I have added a bit more information to the document. Check out the current version here: https://github.com/opentripplanner/OpenTripPlanner/blob/93a132ad9d1ca2a8bddc642b4f917437a4ed73ed/docs/osm/Norway.md |
|
Look good. Thanks! |
vpaturet
left a comment
There was a problem hiding this comment.
Looks good, just one typo.
| /** | ||
| * Does forward and back have the same value? | ||
| */ | ||
| public boolean isSymetric() { |
There was a problem hiding this comment.
typo: symetric --> symmetric
|
@JohanEntur @tsobuskerudbyen The deployed version of the Norwegian documentation is here: https://docs.opentripplanner.org/en/dev-2.x/osm/Norway/ From now on it will always be up to date. |
Summary
This adds a doc generator for the OSM tag mappers. This documentation is useful for non-developers to look up which OSM tags influence the routing in what way.
It looks like this:
A few small refactorings are also part of this PR:
PortlandMapperEqualsAnyInwas renamed toOneOfIssue
Closes #5556
Documentation
✔️
cc @tsobuskerudbyen