-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Uber ride hailing #4979
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
Merged
leonardehrenfried
merged 88 commits into
opentripplanner:dev-2.x
from
ibi-group:car-hailing-uber
Apr 17, 2023
Merged
Uber ride hailing #4979
Changes from 80 commits
Commits
Show all changes
88 commits
Select commit
Hold shift + click to select a range
41bb836
Skeletal implementation of car hailing
leonardehrenfried 42b7727
Update mapping
leonardehrenfried da5de34
Add car hailing to API surface
leonardehrenfried 4a238fd
Initial port of OTP1 car hailing code
leonardehrenfried b212de2
Make prototypical integration with Uber
leonardehrenfried 55ac9e6
Prettify request building
leonardehrenfried c6ae98e
Refactor OAuth
leonardehrenfried ce51a43
Move oauth into separate service
leonardehrenfried 6586e95
Add ServicesConfiguration
leonardehrenfried 3d64e0c
Improve car hailing configuration
leonardehrenfried 36f8e05
Rename street mode
leonardehrenfried 3c6e2d0
Improve package structure
leonardehrenfried 371c252
Improve error handling of OAuth http calls
leonardehrenfried eb78cef
Round coordinates in arrival times cache
leonardehrenfried a5aad19
Add CarHailingLeg
leonardehrenfried 6da168c
Improve OAuth handling
leonardehrenfried a60f89e
Add filter for fetching car hailing info
leonardehrenfried 951c9e1
Add car hailing services to filter chain
leonardehrenfried 905b07f
Improve Uber costs
leonardehrenfried 1e68a25
Remove car hailing information from street leg
leonardehrenfried e0629ee
Add entities to GraphQL schema, rename to ride hailing
leonardehrenfried 966dda3
Complete GraphQL API
leonardehrenfried 11f26a5
More renamings to 'ride hailing'
leonardehrenfried b7f9e44
Implement ride hailing for access/egress
leonardehrenfried 9972a26
Add estimated arrival time to the API response
leonardehrenfried 12da130
Improve Lyft code
leonardehrenfried 3d6843c
Remove Lyft integration
leonardehrenfried 7e1222a
Update documentation
leonardehrenfried 71a36ec
Remove itineraries that don't have any arrivals
leonardehrenfried e931ba6
Extract interface for RideHailingService
leonardehrenfried b82a27f
Remove unused car hailing router
leonardehrenfried e2618b0
Reorganise code
leonardehrenfried 638f20b
Extract interfaces to make code more testable
leonardehrenfried e1365ed
Add tests
leonardehrenfried df739fe
Add documentation
leonardehrenfried ac3a249
Finishing touches to API
leonardehrenfried 2ea8183
Extract method
leonardehrenfried 4037d1b
Add test for filter
leonardehrenfried e9e85b4
Add tests and rename config classes
leonardehrenfried 44204a5
Add more tests
leonardehrenfried efb1407
Merge remote-tracking branch 'upstream/dev-2.x' into car-hailing-uber
leonardehrenfried cebe339
Rename more identifiers from 'car hailing' to 'ride hailing'
leonardehrenfried d4998e9
Rename property to rideHailingEstimate
leonardehrenfried 7bd7dec
Apply review feedback
leonardehrenfried 81dba17
Rename rounding method
leonardehrenfried 0365c24
Update graphql schema
leonardehrenfried 688557e
Add example for Uber ride hailing
leonardehrenfried e1c6c68
Merge remote-tracking branch 'upstream/dev-2.x' into car-hailing-uber
leonardehrenfried 3e09904
Add otp-config.json example for Portland
leonardehrenfried d0d813b
Shift time to earliest pickup time
leonardehrenfried b952777
Hook up shifting
leonardehrenfried 5840701
Merge remote-tracking branch 'upstream/dev-2.x' into car-hailing-uber
leonardehrenfried 4962725
Fix formatting
leonardehrenfried 0949f79
Apply review feedback
leonardehrenfried 5d296aa
Apply suggestions from code review
leonardehrenfried 86d7976
Merge remote-tracking branch 'upstream/dev-2.x' into car-hailing-uber
leonardehrenfried 0229ec1
Resolve merge conflicts
leonardehrenfried 154b026
Apply suggestions from code review
leonardehrenfried ef6ef76
Apply review comments
leonardehrenfried bce5f76
Remove documentation from main config document
leonardehrenfried 16e312a
Remove superfluous code
leonardehrenfried de42793
Merge remote-tracking branch 'upstream/dev-2.x' into car-hailing-uber
leonardehrenfried 39cac65
Use correct provider
leonardehrenfried 887377a
Expose the name of the ride, like UberX
leonardehrenfried 83bc182
Incorporate review feedback
leonardehrenfried 72e8aae
Instantiate ride hailing filter in mapper class
leonardehrenfried 80c9def
Wire up request modifier
leonardehrenfried 35c3b06
Add documentation for annotation
leonardehrenfried f99a397
Merge remote-tracking branch 'upstream/dev-2.x' into car-hailing-uber
leonardehrenfried 52d62c3
Move instatiation into sandbox
leonardehrenfried 0940da4
Move method
leonardehrenfried 977c359
Merge remote-tracking branch 'upstream/dev-2.x' into car-hailing-uber
leonardehrenfried 4d7e207
Apply suggestions from code review
leonardehrenfried bc7c7ff
Merge remote-tracking branch 'upstream/dev-2.x' into car-hailing-uber
leonardehrenfried 3d23013
Update docs
leonardehrenfried 6dccbb8
Reuse existing scalar for Duration
leonardehrenfried a54b42f
Extract a separate RideHailingProvider in the API
leonardehrenfried af5dd5e
Convert class to record
leonardehrenfried 0dc9910
Format comment
leonardehrenfried 1624f39
Add more deeply nested currency type
leonardehrenfried 338655e
Rename to 'value'
leonardehrenfried f07d153
Rename from name to productName
leonardehrenfried 029389d
Update src/ext/java/org/opentripplanner/ext/ridehailing/RideHailingDe…
leonardehrenfried 84ceac7
Incorporate review feedback
leonardehrenfried 02e09a6
Remove interface for ride hailing service config
leonardehrenfried 88015f2
Update GraphQL schema for Money
leonardehrenfried 60e43dd
Remove timeshifting feature
leonardehrenfried b534346
Rename cents to amount in Money class
leonardehrenfried File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Ride hailing services | ||
|
|
||
| This sandbox feature allows you to use ride hailing services like Uber. | ||
|
|
||
| ## Contact Info | ||
|
|
||
| - Leonard Ehrenfried, [[email protected]](mailto:[email protected]) | ||
|
|
||
| ## Configuration | ||
|
|
||
| In order enable this feature, add a new section `rideHailingServices` in `router-config.json`. | ||
|
|
||
| The supported ride-hailing providers are listed below. | ||
|
|
||
| ### Uber | ||
|
|
||
| <!-- INSERT: uber-car-hailing --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "otpFeatures" : { | ||
| "SandboxAPILegacyGraphQLApi": true, | ||
| "VehicleToStopHeuristics": true | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Ride hailing services | ||
|
|
||
| This sandbox feature allows you to use ride hailing services like Uber. | ||
|
|
||
| ## Contact Info | ||
|
|
||
| - Leonard Ehrenfried, [[email protected]](mailto:[email protected]) | ||
|
|
||
| ## Configuration | ||
|
|
||
| In order enable this feature, add a new section `rideHailingServices` in `router-config.json`. | ||
|
|
||
| The supported ride-hailing providers are listed below. | ||
|
|
||
| ### Uber | ||
|
|
||
| <!-- uber-car-hailing BEGIN --> | ||
| <!-- NOTE! This section is auto-generated. Do not change, change doc in code instead. --> | ||
|
|
||
| | Config Parameter | Type | Summary | Req./Opt. | Default Value | Since | | ||
| |------------------------------|:--------:|----------------------------------------------------------|:----------:|---------------|:-----:| | ||
| | type = "uber-car-hailing" | `enum` | The type of the service. | *Required* | | 2.3 | | ||
| | clientId | `string` | OAuth client id to access the API. | *Required* | | 2.3 | | ||
| | clientSecret | `string` | OAuth client secret to access the API. | *Required* | | 2.3 | | ||
| | wheelchairAccessibleRideType | `string` | The id of the requested wheelchair accessible ride type. | *Required* | | 2.3 | | ||
|
|
||
|
|
||
| ##### Example configuration | ||
|
|
||
| ```JSON | ||
| // router-config.json | ||
| { | ||
| "rideHailingServices" : [ | ||
| { | ||
| "type" : "uber-car-hailing", | ||
leonardehrenfried marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "clientId" : "secret-id", | ||
| "clientSecret" : "very-secret", | ||
| "wheelchairAccessibleRideType" : "car" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| <!-- uber-car-hailing END --> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/ext-test/java/org/opentripplanner/ext/legacygraphqlapi/LegacyGraphQLScalarsTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package org.opentripplanner.ext.legacygraphqlapi; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||
| import graphql.schema.CoercingSerializeException; | ||
| import java.time.Duration; | ||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.locationtech.jts.geom.Coordinate; | ||
| import org.locationtech.jts.geom.GeometryFactory; | ||
| import org.opentripplanner.framework.json.ObjectMappers; | ||
|
|
||
| class LegacyGraphQLScalarsTest { | ||
|
|
||
| @Test | ||
| void duration() { | ||
| var string = LegacyGraphQLScalars.durationScalar | ||
| .getCoercing() | ||
| .serialize(Duration.ofMinutes(30)); | ||
| assertEquals("PT30M", string); | ||
| } | ||
|
|
||
| @Test | ||
| void nonDuration() { | ||
| Assertions.assertThrows( | ||
| CoercingSerializeException.class, | ||
| () -> LegacyGraphQLScalars.durationScalar.getCoercing().serialize(new Object()) | ||
| ); | ||
| } | ||
|
|
||
| @Test | ||
| void geoJson() throws JsonProcessingException { | ||
| var gm = new GeometryFactory(); | ||
| var polygon = gm.createPolygon( | ||
| new Coordinate[] { | ||
| new Coordinate(0, 0), | ||
| new Coordinate(1, 1), | ||
| new Coordinate(2, 2), | ||
| new Coordinate(0, 0), | ||
| } | ||
| ); | ||
| var geoJson = LegacyGraphQLScalars.geoJsonScalar.getCoercing().serialize(polygon); | ||
|
|
||
| var jsonNode = ObjectMappers | ||
| .ignoringExtraFields() | ||
| .readTree( | ||
| "{\"type\":\"Polygon\",\"coordinates\":[[[0.0,0.0],[1.0,1.0],[2.0,2.0],[0.0,0.0]]]}" | ||
| ); | ||
| assertEquals(jsonNode, geoJson); | ||
| } | ||
| } |
61 changes: 61 additions & 0 deletions
61
...xt-test/java/org/opentripplanner/ext/ridehailing/RideHailingDepartureTimeShifterTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| package org.opentripplanner.ext.ridehailing; | ||
|
|
||
| import static graphql.Assert.assertTrue; | ||
| import static java.time.Duration.ofMinutes; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| import java.time.Instant; | ||
| import java.time.OffsetDateTime; | ||
| import java.util.List; | ||
| import java.util.stream.Stream; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.Arguments; | ||
| import org.opentripplanner._support.time.ZoneIds; | ||
| import org.opentripplanner.model.GenericLocation; | ||
| import org.opentripplanner.routing.api.request.RequestModes; | ||
| import org.opentripplanner.routing.api.request.RouteRequest; | ||
| import org.opentripplanner.routing.api.request.StreetMode; | ||
| import org.opentripplanner.test.support.VariableSource; | ||
|
|
||
| class RideHailingDepartureTimeShifterTest { | ||
|
|
||
| static Instant instant = OffsetDateTime.parse("2023-03-23T17:13:46+01:00").toInstant(); | ||
|
|
||
| RideHailingService service = new TestRideHailingService( | ||
| TestRideHailingService.DEFAULT_ARRIVAL_TIMES, | ||
| List.of() | ||
| ); | ||
|
|
||
| static Stream<Arguments> testCases = Stream.of( | ||
| // leave now, so shift by 10 minutes | ||
| Arguments.of(instant, instant.plus(TestRideHailingService.DEFAULT_ARRIVAL_DURATION)), | ||
| Arguments.of(instant.plus(ofMinutes(15)), instant.plus(ofMinutes(15))), | ||
| // no shifting because it's in the future | ||
| Arguments.of(instant.plus(ofMinutes(30)), instant.plus(ofMinutes(30))), | ||
| Arguments.of(instant.plus(ofMinutes(40)), instant.plus(ofMinutes(40))), | ||
| // only shift by 9 minutes because we are wanting to leave in one minute | ||
| Arguments.of(instant.plus(ofMinutes(1)), instant.plus(ofMinutes(10))) | ||
| ); | ||
|
|
||
| @ParameterizedTest | ||
| @VariableSource("testCases") | ||
| void shift(Instant searchTime, Instant expectedTimeAfterShifting) { | ||
| var req = new RouteRequest(); | ||
| req.setTo(new GenericLocation(0d, 0d)); | ||
| req.setFrom(new GenericLocation(0d, 0d)); | ||
| req.setDateTime(searchTime); | ||
| req.journey().setModes(RequestModes.of().withAccessMode(StreetMode.CAR_HAILING).build()); | ||
|
|
||
| var result = RideHailingDepartureTimeShifter.shiftDepartureTime(req, List.of(service), instant); | ||
|
|
||
| assertTrue(result.isSuccess()); | ||
| var shifted = result.successValue(); | ||
|
|
||
| var time = OffsetDateTime.ofInstant(shifted.dateTime(), ZoneIds.BERLIN); | ||
|
|
||
| var expectedTime = OffsetDateTime.ofInstant(expectedTimeAfterShifting, ZoneIds.BERLIN); | ||
|
|
||
| // start time should be shifted by 10 minutes | ||
| assertEquals(expectedTime.toString(), time.toString()); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.