forked from opentripplanner/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to create special transfer requests for cars and bikes wi…
…th the 'carsAllowedStopMaxTransferDurationsForMode' build config parameter.
- Loading branch information
1 parent
53a2132
commit f6adb13
Showing
10 changed files
with
634 additions
and
132 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
55 changes: 55 additions & 0 deletions
55
...tripplanner/standalone/config/buildconfig/CarsAllowedStopMaxTransferDurationsForMode.java
This file contains 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,55 @@ | ||
package org.opentripplanner.standalone.config.buildconfig; | ||
|
||
import static org.opentripplanner.standalone.config.framework.json.OtpVersion.V2_7; | ||
|
||
import java.time.Duration; | ||
import java.util.Map; | ||
import org.opentripplanner.routing.api.request.StreetMode; | ||
import org.opentripplanner.routing.api.request.framework.DurationForEnum; | ||
import org.opentripplanner.standalone.config.framework.json.NodeAdapter; | ||
|
||
public class CarsAllowedStopMaxTransferDurationsForMode { | ||
|
||
public static DurationForEnum<StreetMode> map( | ||
NodeAdapter root, | ||
String parameterName, | ||
Duration maxTransferDuration | ||
) { | ||
Map<StreetMode, Duration> values = root | ||
.of(parameterName) | ||
.since(V2_7) | ||
.summary( | ||
"This is used for specifying a `maxTransferDuration` value for bikes and cars to use with transfers between stops that have trips with cars." | ||
) | ||
.description( | ||
""" | ||
This is a special parameter that only works on transfers between stops that have trips that allow cars. | ||
The duration can be set for either 'BIKE' or 'CAR'. | ||
For cars, transfers are only calculated between stops that have trips that allow cars. | ||
For cars, this overrides the default `maxTransferDuration`. | ||
For bicycles, this indicates that additional transfers should be calculated with the specified duration between stops that have trips that allow cars. | ||
**Example** | ||
```JSON | ||
// build-config.json | ||
{ | ||
"carsAllowedStopMaxTransferDurationsForMode": { | ||
"CAR": "2h", | ||
"BIKE": "3h" | ||
} | ||
} | ||
``` | ||
""" | ||
) | ||
.asEnumMap(StreetMode.class, Duration.class); | ||
for (StreetMode mode : values.keySet()) { | ||
if (mode != StreetMode.BIKE && mode != StreetMode.CAR) { | ||
throw new IllegalArgumentException( | ||
"Only the CAR and BIKE modes are allowed in the carsAllowedStopMaxTransferDurationsForMode parameter." | ||
); | ||
} | ||
} | ||
return DurationForEnum.of(StreetMode.class).withValues(values).build(); | ||
} | ||
} |
Oops, something went wrong.