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

feat: Too fast trip travel speed #710

Merged
merged 46 commits into from
Feb 25, 2021
Merged

feat: Too fast trip travel speed #710

merged 46 commits into from
Feb 25, 2021

Conversation

lionel-nj
Copy link
Contributor

@lionel-nj lionel-nj commented Feb 1, 2021

closes #517

Please review after #708

Summary:

This PR implements a new validation rule: check trip travel is reasonable.

Expected behavior:

  • a notice should be generated if at some point the mean speed of a trip (or part or it) exceed 150 km/h

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with gradle test to make sure you didn't break anything
  • Format the title like "feat: -new feature short description-" (PR title must follow the conventional commit specification)
  • Linked all relevant issues
  • [ ] Include screenshot(s) showing how this pull request works and fixes the issue(s)

lionel-nj added 6 commits February 1, 2021 10:12
- implement new validation rule
- implement GeoUtil class
- draft unit tests
- create new notice
- update RULES.md
- write new logic rule
- additional unit tests
- update RULES.md
@lionel-nj lionel-nj self-assigned this Feb 1, 2021
@lionel-nj lionel-nj marked this pull request as draft February 3, 2021 19:26
@lionel-nj
Copy link
Contributor Author

This PR relies on a dependency that is not supported by Google, as a result, the implementation of this new rule is postponed until @aababilov evaluates possibilities #708 (comment)

#708

barbeau and others added 20 commits February 15, 2021 17:15
* Only process each trip once
* Refactor forEach to simple loop to clarify behavior
* Refactor distance variables and method to use double instead of float and int
* Refactor utility method signature to remove need for trip object
* Cleanup docs - remove references to "error"
* Add docs for method of distance calculation
* Fix existing tests
# Conflicts:
#	RULES.md
#	main/src/main/java/org/mobilitydata/gtfsvalidator/util/GeospatialUtil.java
#	main/src/main/java/org/mobilitydata/gtfsvalidator/validator/StopTooFarFromTripShapeValidator.java
#	main/src/test/java/org/mobilitydata/gtfsvalidator/util/GeospatialUtilTest.java
#	main/src/test/java/org/mobilitydata/gtfsvalidator/validator/StopTooFarFromTripShapeValidatorTest.java
…/gtfs-validator into fix-stop-too-far-from-shape
- draft one more unit test to verify the number of method invocations
- make checkStopsWithinTripShape package private
- draft one more unit test to verify the number of method invocations
- make checkStopsWithinTripShape package private
Mockito captures parameters by reference and not value, so we get the final state of the cache, not the state after each method invocation
stop_times.txt should only have stops location_types 0 and 4, so validation for that can be done elsewhere.
stop_times.txt should only have stops location_types 0 and 4, so validation for that can be done elsewhere.
This also has the effect of using Euclidean instead of Geodetic buffers, which saves execution time and likely memory, and doesn't seem to result in a level of error that causes problems. So the tradeoff of performance vs. accuracy seems acceptable. See #750 (comment) for details.
@lionel-nj lionel-nj marked this pull request as ready for review February 22, 2021 19:00
Copy link
Member

@barbeau barbeau left a comment

Choose a reason for hiding this comment

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

Thanks @lionel-nj! Some comments in-line.

lionel-nj added 4 commits February 23, 2021 10:53
# Conflicts:
#	main/src/main/java/org/mobilitydata/gtfsvalidator/validator/StopTooFarFromTripShapeValidator.java
#	main/src/test/java/org/mobilitydata/gtfsvalidator/validator/StopTooFarFromTripShapeValidatorTest.java
@barbeau barbeau mentioned this pull request Feb 24, 2021
4 tasks
lionel-nj added 3 commits February 24, 2021 11:34
- check algorithm on non-timepoints stop times
- check algorithm on  StopTimeWithArrivalBeforePreviousDepartureTimeNotice case
- handle non-timepoints stop times
- handle StopTimeWithArrivalBeforePreviousDepartureTimeNotice situation
- rework checkSpeedAlongTrip to take tripId and tripStopTimes as a list - as two parameters
- update javadocs
Copy link
Member

@barbeau barbeau left a comment

Choose a reason for hiding this comment

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

Thanks @lionel-nj, looks pretty good! A few more items in-line.

Copy link
Contributor

@maximearmstrong maximearmstrong left a comment

Choose a reason for hiding this comment

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

LGTM

- refactor for consistency
- beginStopSequence: rework rule logic to no longer maintain a list on integer
- rework tests for clarity
- additional unit test
- improve documentation

TODO: finish test refactor + additional unit test for non time points fast and non fast travel
@lionel-nj
Copy link
Contributor Author

@barbeau reading #765 (comment): it seems like I implemented the solution 2 you suggested.

Add checks within separate TripTravelSpeedValidator for valid times (but don't generate notice for invalid times) - Pros are that this ensures the output of FastTravelBetweenStopsNotice is valid and it doesn't add complexity to a single validator class for this and other notices. Cons are duplicating some code for the time checks and another loop through stop_times.txt for this separate validator.

@lionel-nj
Copy link
Contributor Author

We need another two tests where both arrival and departure time aren't provided in between stop times that have arrival and departure times, both for the case where there is and is not too fast travel

Done. I also reworked the tests to ease clarity and reading. @barbeau

Copy link
Member

@barbeau barbeau left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @lionel-nj

@Test
public void fastTravelFarStopsShouldGenerateNotice() {
// sample table descriptions available at:
// https://gist.github.com/lionel-nj/d21cc8b1519d4f44f9ebd53858cda78d
Copy link
Member

Choose a reason for hiding this comment

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

💯 On the Gist with the table

@barbeau barbeau merged commit 429eb4c into master Feb 25, 2021
@barbeau barbeau deleted the too-fast-travel branch February 25, 2021 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fast travel between stops in stop_times.txt
3 participants