-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Namer for applying street names to nearby sidewalks #5774
Namer for applying street names to nearby sidewalks #5774
Conversation
b355016
to
4893609
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #5774 +/- ##
=============================================
+ Coverage 67.90% 67.93% +0.02%
- Complexity 16556 16590 +34
=============================================
Files 1910 1912 +2
Lines 72436 72601 +165
Branches 7447 7449 +2
=============================================
+ Hits 49190 49323 +133
- Misses 20724 20750 +26
- Partials 2522 2528 +6 ☔ View full report in Codecov by Sentry. |
da83c94
to
d2102b7
Compare
d2102b7
to
a312d2a
Compare
After today's meeting discussion, I looked through SphericalDistanceLibrary in more detail. I see the equirectangularProject and fastDistance methods use the same approach I described, but are expressed differently: they leave all the coordinates in radians (basically, on a globe with a radius of 1 unit) and then the various methods all have to multiply their final results by the radius of the Earth as a final step to get usable results in meters. I can see why this would be confusing to approach, and this also complicates the reusability of the projected geometries with straightforward JTS methods. I don't think there's any loss of efficiency to just project everything straight into meters. In fact it should be both slightly more efficient and easier to read. I will propose a refactored version of these library functions that I expect will be much easier to work with, adapting the sidewalk namer to use the refactored library functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the revisions.
Unfortunately during yesterday's meeting I hadn't yet seen certain changes, particularly the removal of DistanceOp. I was thinking of the state I saw at the time of this comment: #5774 (comment)
I see that DistanceOp is no longer being used, and that was the one place I thought distances were still being calculated on lon-lat coordinates. The current approach looks sound: buffering is performed in UTM projected coordinates with cached transforms; intersection operations are in WGS84 but between areas and linestrings so not projection-sensitive; subsequent relative length calculations are performed in WGS84 but using great-circle distances, which are more precise than needed but certainly correct.
The mix of coordinate systems and distance calculation approaches remains a little unusual, but it looks correct and well-documented, and you measured it to be reasonably performant.
For the future, if I want to emphasize certain ideas for consistency and long-term maintainability, the ball is in my court to write documentation and maybe new utility methods. I realize none of the historically accumulated geographic/geometric calculation ideas have been summarized for reuse, that was basically undocumented institutional knowledge at Conveyal.
I drafted some ideas for this, but seeing that DistanceOp is no longer used the changes are not necessary for this PR and are more a matter of style/taste than correctness. So I won't be proposing changes to this PR, but possible a separate documentation/refactor PR on SphericalDistanceLibrary. |
Having a reusable component that converts WGS84 geometries to "equirectangular" ones would indeed be great. I think in such a case we should be converting to a type that is a facade to the actual JTS geometry (credit to @t2gran) and therefore documents what kind of coordinate system we are dealing with. For example, the result of the distanceTo() method could be of type |
Would it be possible to use the spatial index with such an equirectangular geometry? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor formatting things, but otherwise it is pretty solid!
src/main/java/org/opentripplanner/openstreetmap/model/OSMWithTags.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/openstreetmap/model/OSMWithTags.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/graph_builder/module/osm/OsmModule.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/graph_builder/module/osm/naming/SidewalkNamer.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/graph_builder/module/osm/naming/SidewalkNamer.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/graph_builder/module/osm/naming/SidewalkNamer.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/graph_builder/module/osm/naming/SidewalkNamer.java
Outdated
Show resolved
Hide resolved
private static Stream<CandidateGroup> groupEdgesByName(List<EdgeOnLevel> candidates) { | ||
return candidates | ||
.stream() | ||
.collect(Collectors.groupingBy(e -> e.edge.getName())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future work in a subsequent PR: This would not accommodate unnamed slip lanes (see screenshot and OSM link), and the adjacent sidewalk would keep its default name.
See https://www.openstreetmap.org/way/1201583893 vs. https://www.openstreetmap.org/way/784160579
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we already filter out nameless edges before adding candidates to the index. Is the sidewalk in question nameless?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final changes look good. We agreed in the development meeting that although it would be nice to have our own concise, fast, typesafe geometry code that's beyond the scope of this PR. This is certainly clean and correct enough to merge as-is.
Summary
Introduces a new implementation of
EdgeNamer
that applies the names of nearby streets to sidewalks. The actual algorithm is described in the Javadoc.What does it look like?
Before
After
I've also included smaller clean ups and improvements to the (new) debug UI.
Unit tests
Added.
Documentation
Lots of Javadoc.
Bumping the serialization version id
The graph itself is not changed but the build config is. I'm not sure if this requires a bump.
cc @binh-dam-ibigroup