Skip to content

Generate documentation for OSM tag mappers#5929

Merged
leonardehrenfried merged 11 commits into
opentripplanner:dev-2.xfrom
leonardehrenfried:document-osm
Jul 11, 2024
Merged

Generate documentation for OSM tag mappers#5929
leonardehrenfried merged 11 commits into
opentripplanner:dev-2.xfrom
leonardehrenfried:document-osm

Conversation

@leonardehrenfried

@leonardehrenfried leonardehrenfried commented Jun 26, 2024

Copy link
Copy Markdown
Member

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:

image

A few small refactorings are also part of this PR:

  • A few mapping rules that are very specific to the Portland area are moved to PortlandMapper
  • The Condition EqualsAnyIn was renamed to OneOf
  • The old bicycle safety report was removed from the Report API

Issue

Closes #5556

Documentation

✔️

cc @tsobuskerudbyen

@leonardehrenfried leonardehrenfried added the !Documentation Improve documentation targeting users and/or developers. label Jun 26, 2024
@leonardehrenfried leonardehrenfried requested a review from a team as a code owner June 26, 2024 11:16
@codecov

codecov Bot commented Jun 26, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.62%. Comparing base (e1c02b2) to head (07bdb99).
Report is 137 commits behind head on dev-2.x.

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.
📢 Have feedback on the report? Share it here.

@leonardehrenfried

Copy link
Copy Markdown
Member Author

Sort menu items alphabetically

@leonardehrenfried

Copy link
Copy Markdown
Member Author

@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.

@JohanEntur

Copy link
Copy Markdown

@Bjoern-Rapp 👀

@JohanEntur

Copy link
Copy Markdown

It's a good overview to bypass reading the code. Still a complex set to grasp, but this is warmly welcomed.

@leonardehrenfried

Copy link
Copy Markdown
Member Author

@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?".

Comment on lines +76 to +103
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();
}

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.

Should we apply some sort of sorting on these tables? I don't know what is the most logical one.

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.

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.

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.

Yep lets just stick with the insertion order.

}

record EqualsAnyIn(String key, String... values) implements Condition {
record OneOf(String key, String... values) implements Condition {

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.

A bit of javadoc on these records wouldn't hurt as not all of these are instantly obvious.

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.

Added in 22d2123

@tsobuskerudbyen

tsobuskerudbyen commented Jul 1, 2024

Copy link
Copy Markdown

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 highway=bridleway line. Neutral? Not allowed?

@leonardehrenfried

Copy link
Copy Markdown
Member Author

And what does an empty cell under the "bike safety" column man? E.g. for the highway=bridleway line. Neutral? Not allowed?

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.


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.

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.

This is slightly difficult to read but I couldn't come up with a better way to formulate what this does.

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.

I've tried to improve it here: a9441a7

leonardehrenfried and others added 2 commits July 3, 2024 10:13
…ecifier/Condition.java

Co-authored-by: Joel Lappalainen <lappalj8@gmail.com>
@leonardehrenfried

Copy link
Copy Markdown
Member Author

@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

@tsobuskerudbyen

Copy link
Copy Markdown

Look good. Thanks!

optionsome
optionsome previously approved these changes Jul 4, 2024
@leonardehrenfried leonardehrenfried requested a review from t2gran July 4, 2024 14:29
@leonardehrenfried leonardehrenfried requested review from vpaturet and removed request for t2gran July 9, 2024 09:07

@vpaturet vpaturet left a comment

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.

Looks good, just one typo.

/**
* Does forward and back have the same value?
*/
public boolean isSymetric() {

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.

typo: symetric --> symmetric

@leonardehrenfried leonardehrenfried merged commit 8404481 into opentripplanner:dev-2.x Jul 11, 2024
t2gran pushed a commit that referenced this pull request Jul 11, 2024
@leonardehrenfried leonardehrenfried deleted the document-osm branch July 11, 2024 11:03
@leonardehrenfried

Copy link
Copy Markdown
Member Author

@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.

@t2gran t2gran added this to the 2.6 (next release) milestone Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

!Documentation Improve documentation targeting users and/or developers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document OSM and OTP integration

6 participants