Add 'transferParametersForMode' build config field#6215
Conversation
…th the 'carsAllowedStopMaxTransferDurationsForMode' build config parameter.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #6215 +/- ##
=============================================
+ Coverage 69.72% 69.76% +0.04%
- Complexity 18016 18045 +29
=============================================
Files 2057 2060 +3
Lines 76967 77097 +130
Branches 7844 7854 +10
=============================================
+ Hits 53666 53788 +122
- Misses 20550 20556 +6
- Partials 2751 2753 +2 ☔ View full report in Codecov by Sentry. |
|
There are some conflicts |
…into car-transferrequest-filtering
optionsome
left a comment
There was a problem hiding this comment.
I've had too many reviews today already so I didn't go properly through this. However, inspired by some concerns from @t2gran, I think to avoid issues we should do a couple of things:
- Introduce
carsAllowedStopMaxAccessEgressDurationsForMode. This is to prevent weird back-and-forth transfers to avoid access and egress duration limitations. - Prevent these transfers from being used by other street modes. I don't know if this is already done or not but I think at least previously all the transfers were in the same collection. This could again lead to weird back and forth travel by walking for example to escape some other restrictions.
| mBuilder.withEgressMode(StreetMode.WALK); | ||
| mBuilder.withDirectMode(StreetMode.CAR); | ||
| // This is used in transfer cache request calculations. | ||
| mBuilder.withAllStreetModes(StreetMode.CAR); |
There was a problem hiding this comment.
I know this builder method wasn't introduced in this pr but this name is really confusing. Idk what we call Access+Transfer+Egress+Direct. It's difficult to come up with a name that doesn't confuse you into thinking that all modes are enabled. Just making this singular would maybe make it less confusing.
There was a problem hiding this comment.
I changed it to set each mode separately for more clarity
| this.issueStore = issueStore; | ||
| this.radiusByDuration = radiusByDuration; | ||
| this.transferRequests = transferRequests; | ||
| this.carsAllowedStopMaxTransferDurationsForMode = DurationForEnum.of(StreetMode.class).build(); |
There was a problem hiding this comment.
Maybe we should always include this with some default value that is the same as the normal transfer duration limit.
There was a problem hiding this comment.
This has changed quite a lot, but you can look at how I handle an empty parameter
| .stream() | ||
| .map(StopLocation::getId) | ||
| .map(graph::getStopVertexForStopId) | ||
| .filter(TransitStopVertex.class::isInstance) // filter out null values if no TransitStopVertex is found for ID |
There was a problem hiding this comment.
Inline comments are not allowed.
|
I'm changing this to a draft for now. I'll return to this once the work on the separate transfer request collections for modes has been completed. |
…into car-transferrequest-filtering
| | [maxDataImportIssuesPerFile](#maxDataImportIssuesPerFile) | `integer` | When to split the import report. | *Optional* | `1000` | 2.0 | | ||
| | maxElevationPropagationMeters | `integer` | The maximum distance to propagate elevation to vertices which have no elevation. | *Optional* | `2000` | 1.5 | | ||
| | [maxStopToShapeSnapDistance](#maxStopToShapeSnapDistance) | `double` | Maximum distance between route shapes and their stops. | *Optional* | `150.0` | 2.1 | | ||
| | maxTransferDuration | `duration` | Transfers up to this duration with the default walk speed value will be pre-calculated and included in the Graph. | *Optional* | `"PT30M"` | 2.1 | |
There was a problem hiding this comment.
Should this parameter be moved to be inside transferParameters? Also, I think the description is wrong since this can be used for other types of transfers as well. There might be one or two other parameters that could be moved to be under transferParameters such as discardMinTransferTimes and maybe stationTransferPreference.
There was a problem hiding this comment.
As per the OTP meeting discussion, I renamed transferParameters to transferParametersForMode. I also changed the summary for maxTransferDuration to Transfers up to this duration with a mode-specific speed value will be pre-calculated and included in the Graph.
| Duration carsAllowedStopMaxTransferDuration, | ||
| boolean disableDefaultTransfers | ||
| ) { | ||
| public static final Duration DEFAULT_MAX_TRANSFER_DURATION = Duration.ZERO; |
There was a problem hiding this comment.
Isn't the default 30 minutes? I think the default should be set only in one place and then used from there elsewhere.
There was a problem hiding this comment.
I set both of the Duration.ZERO to null
| boolean disableDefaultTransfers | ||
| ) { | ||
| public static final Duration DEFAULT_MAX_TRANSFER_DURATION = Duration.ZERO; | ||
| public static final Duration DEFAULT_CARS_ALLOWED_STOP_MAX_TRANSFER_DURATION = Duration.ZERO; |
There was a problem hiding this comment.
I don't know if the default value for this should be the same as the normal default or null.
There was a problem hiding this comment.
I set both of the Duration.ZERO to null
| "Transfers up to this duration with the default walk speed value will be pre-calculated and included in the Graph." | ||
| ) | ||
| .asDuration(Duration.ofMinutes(30)); | ||
| transferParametersForMode = TransferConfig.map(root, "transferParameters"); |
There was a problem hiding this comment.
This variable should be renamed if we decide to make the transferParameters used for other transfer parameters as well.
There was a problem hiding this comment.
As per the OTP meeting discussion, I renamed transferParameters to transferParametersForMode
| import org.opentripplanner.graph_builder.module.TransferParameters; | ||
| import org.opentripplanner.standalone.config.framework.json.NodeAdapter; | ||
|
|
||
| public class TransferParametersMapper { |
There was a problem hiding this comment.
These parameters don't show up in the BuildConfiguration.md now. If I remember correctly, you should at least add them to https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/application/src/test/resources/standalone/config/build-config.json and https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/application/src/test/java/org/opentripplanner/generate/doc/framework/NodeAdapterHelper.java#L8-L20 as well.
There was a problem hiding this comment.
I added changes to both files
| .description( | ||
| """ | ||
| This parameter configures additional transfers to be calculated for the specified mode only between stops that have trips with cars. | ||
| The transfers are calculated for the mode in a range based on the given duration. | ||
| By default, these transfers are not calculated for the specified mode. | ||
| """ | ||
| ) |
There was a problem hiding this comment.
Since this parameter is rather odd on the first glance, you could explain a bit here that this might be useful when there are ferries that sort of extend the road network.
There was a problem hiding this comment.
Yeah, it's a difficult concepts so needs a bit more docs.
There was a problem hiding this comment.
I added more documentation
| builder.withDisableDefaultTransfers( | ||
| c | ||
| .of("disableDefaultTransfers") | ||
| .summary("This disables default transfer calculations.") |
There was a problem hiding this comment.
You could add a bit more descriptive description for what the default transfer calculations means and why you might want to do this.
There was a problem hiding this comment.
I added more documentation
leonardehrenfried
left a comment
There was a problem hiding this comment.
If you fix @optionsome 's points I can approve this.
The mode-dependency for PathTransfers was added in another PR. Because this PR changes how transfer calculations can be configured, I think the serialization id should be bumped. |
|
|
||
| // Calculate default transfers. | ||
| for (RouteRequest transferProfile : transferRequests) { | ||
| for (RouteRequest transferProfile : transferConfiguration.defaultTransferRequests) { |
There was a problem hiding this comment.
I think it's better if you use the record fields through the getters instead of accessing the fields directly.
There was a problem hiding this comment.
This has now been changed
| List<RouteRequest> carsAllowedStopTransferRequests = new ArrayList<>(); | ||
| List<RouteRequest> flexTransferRequests = new ArrayList<>(); | ||
| HashMap<StreetMode, NearbyStopFinder> defaultNearbyStopFinderForMode = new HashMap<>(); | ||
| /* These are used for calculating transfers only between carsAllowedStops. */ |
There was a problem hiding this comment.
Use normal comments inside methods.
There was a problem hiding this comment.
These were from a previous commit. I changed them in this file everywhere I could find them
| ``` | ||
|
|
||
|
|
||
| <h3 id="tpfm_BIKE_carsAllowedStopMaxTransferDuration">carsAllowedStopMaxTransferDuration</h3> |
There was a problem hiding this comment.
Now the same fields are documented for all modes (specified in the example build-config.json) which is not what we want since I doubt we will have mode specific parameters. I don't know what is the best way to get rid of this. One option would be to have a structure like:
{
"transferParametersForModes": [
{"mode": "CAR", "maxTransferDuration": "30m"}
]
}
instead of having this kind of an enum map.
There was a problem hiding this comment.
As discussed this has been left as is. I added a topic discussion in the dev meeting thread
| createPathTransfer(sd.stop, stop, sd, distinctTransfers, mode); | ||
| } | ||
| } | ||
| // Calculate transfers between stops that are visited by trips that allow cars, if configured. |
There was a problem hiding this comment.
This method is getting too long. Please split it up into the various phases (default, flex, cars allowed) and then convert these line comments into javadoc.
Afterwards I'm satisfied and will approve.
There was a problem hiding this comment.
I split this into three functions
|
I think the issue with the documentation getting generated in a wrong way still exists. I think we should investigate fixing it in the scope of this pr. |
Summary
This PR adds the
transferParametersForModebuild config field for configuring transfers. These parameters can be configured for all transfer modes:disableDefaultTransfers: allows disabling default transfer calculationsmaxTransferDuration: allows configuring a mode-specificmaxTransferDurationcarsAllowedStopMaxTransferDuration: allows changing max transfer durations between stops that allow carsThis is a follow-up PR related to #5966. Example configuration:
Issue
This is a follow-up PR related to issue #5875.
Unit tests
I created new unit tests for testing the changes to the
DirectTransferGeneratorDocumentation
Changes to
BuildConfiguration.mdBumping the serialization version id
This change affects how transfers are calculated and adds a new field to the
build-config.jsonfile.