-
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
Require valid polygons for AreaStop #5915
Require valid polygons for AreaStop #5915
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #5915 +/- ##
=============================================
- Coverage 69.46% 69.43% -0.03%
+ Complexity 17068 17059 -9
=============================================
Files 1928 1934 +6
Lines 73580 73620 +40
Branches 7550 7541 -9
=============================================
+ Hits 51109 51117 +8
- Misses 19847 19874 +27
- Partials 2624 2629 +5 ☔ View full report in Codecov by Sentry. |
0aeb220
to
3ba6c8c
Compare
what happens when the polygon is not closed? In this case a Polygon instance cannot even be created.
I assume this gets caught in the OneBusAway code. Does it get mapped to an issue as well? |
@vpaturet I've now added that adds an issue and returns null when the polygon is not a closed ring. That will probably fail with a confusing NPE elsewhere. |
Indeed that will fail with NPE here for instance: OpenTripPlanner/src/main/java/org/opentripplanner/transit/model/site/GroupStopBuilder.java Line 73 in c0ebcbe
and in other places. Trading an IllegalArgumentException for a NullPointerException does not really help. |
} catch (UnsupportedGeometryException e) { | ||
LOG.error("Unsupported geometry type for {}", gtfsLocation.getId()); | ||
var geometry = GeometryUtils.convertGeoJsonToJtsGeometry(gtfsLocation.getGeometry()); | ||
var isValidOp = new IsValidOp(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.
This class has weird naming but I guess that's not our fault.
if (!isValidOp.isValid()) { | ||
var error = isValidOp.getValidationError(); | ||
issueStore.add( | ||
Issue.issue( | ||
"InvalidFlexAreaGeometry", | ||
"GTFS flex location %s has an invalid geometry: %s at (lat: %s, lon: %s)", | ||
id, | ||
error.getMessage(), | ||
error.getCoordinate().y, | ||
error.getCoordinate().x | ||
) | ||
); | ||
} |
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.
So are there some geometries which don't throw an exception but are still considered invalid by the validator? Do these cause issues during runtime?
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.
The routing sometimes (mostly?) works anyway but the vector tiles library refuses to serialise these geometries.
} | ||
|
||
@Test | ||
void nonClosedPolygon() { |
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.
Can these be called open polygons? I tried quickly reading about this and maybe the open is a bit vague so lets stick with nonClosed.
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.
We talked about this last week and the handling of the incomplete polygons was removed from this PR.
ccbce81
to
3ba6c8c
Compare
Summary
For Netex it is required that the imported polygons for AreaStops are valid and not (for example) self-intersecting.
So far GTFS allowed you to import invalid polygons, which mostly worked, but sometimes didn't. As it was not spelled out in the GTFS spec, I am currently proposing a clarification in the spec to change this: google/transit#476
It contains also a good example why invalid polygons are problematic.
For this reason I'm proposing that all AreaStop geometries be valid and the check can happen in the constructor.
This PR also renames the GTFS mapper since the entity it is mapping to has been renamed quite a while ago. I'm also removing an old integration test that contained an invalid polygon.
Issue
#5457
Unit tests
Added.