Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev-2.x' into upstream-merge-2…
Browse files Browse the repository at this point in the history
…023-10-12
  • Loading branch information
leonardehrenfried committed Oct 12, 2023
2 parents 18373bc + 0654eb4 commit cb5b34e
Show file tree
Hide file tree
Showing 52 changed files with 1,338 additions and 504 deletions.
39 changes: 39 additions & 0 deletions doc-templates/sandbox/VehicleRentalServiceDirectory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Vehicle Rental Service Directory API support.

This adds support for the GBFS service directory endpoint component located at
https://github.com/entur/lamassu. OTP uses the service directory to lookup and connect to all GBFS
endpoints registered in the directory. This simplifies the management of the GBFS endpoints, since
multiple services/components like OTP can connect to the directory and get the necessary
configuration from it.


## Contact Info

- Entur, Norway


## Changelog

- Initial implementation of bike share updater API support
- Make json tag names configurable [#3447](https://github.com/opentripplanner/OpenTripPlanner/pull/3447)
- Enable GBFS geofencing with VehicleRentalServiceDirectory [#5324](https://github.com/opentripplanner/OpenTripPlanner/pull/5324)


## Configuration

To enable this you need to specify a url for the `vehicleRentalServiceDirectory` in
the `router-config.json`

### Parameter Summary

<!-- INSERT: PARAMETERS-TABLE -->


### Parameter Details

<!-- INSERT: PARAMETERS-DETAILS -->


### Example

<!-- INSERT: JSON-EXAMPLE -->
3 changes: 3 additions & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ based on merged pull requests. Search GitHub issues and pull requests for smalle
- Apply correct traversal permissions to barrier vertex [#5369](https://github.com/opentripplanner/OpenTripPlanner/pull/5369)
- Move GTFS GraphQL API out of the sandbox [#5339](https://github.com/opentripplanner/OpenTripPlanner/pull/5339)
- Transmodel GraphQL API for pass-through searches [#5320](https://github.com/opentripplanner/OpenTripPlanner/pull/5320)
- Fix check for OSM relation members not being present in the extract [#5379](https://github.com/opentripplanner/OpenTripPlanner/pull/5379)
- Add a configurable limit for the search window [#5293](https://github.com/opentripplanner/OpenTripPlanner/pull/5293)
- Fix fare calculation for combined interlined legs [#5408](https://github.com/opentripplanner/OpenTripPlanner/pull/5408)
[](AUTOMATIC_CHANGELOG_PLACEHOLDER_DO_NOT_REMOVE)

## 2.4.0 (2023-09-13)
Expand Down
32 changes: 18 additions & 14 deletions docs/RouterConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ A full list of them can be found in the [RouteRequest](RouteRequest.md).
| [transit](#transit) | `object` | Configuration for transit searches with RAPTOR. | *Optional* | | na |
|    [iterationDepartureStepInSeconds](#transit_iterationDepartureStepInSeconds) | `integer` | Step for departure times between each RangeRaptor iterations. | *Optional* | `60` | na |
|    [maxNumberOfTransfers](#transit_maxNumberOfTransfers) | `integer` | This parameter is used to allocate enough memory space for Raptor. | *Optional* | `12` | na |
|    [maxSearchWindow](#transit_maxSearchWindow) | `duration` | Upper limit of the request parameter searchWindow. | *Optional* | `"PT24H"` | 2.4 |
|    [scheduledTripBinarySearchThreshold](#transit_scheduledTripBinarySearchThreshold) | `integer` | This threshold is used to determine when to perform a binary trip schedule search. | *Optional* | `50` | na |
|    [searchThreadPoolSize](#transit_searchThreadPoolSize) | `integer` | Split a travel search in smaller jobs and run them in parallel to improve performance. | *Optional* | `0` | na |
|    [transferCacheMaxSize](#transit_transferCacheMaxSize) | `integer` | The maximum number of distinct transfers parameters to cache pre-calculated transfers for. | *Optional* | `25` | na |
Expand All @@ -67,13 +68,7 @@ A full list of them can be found in the [RouteRequest](RouteRequest.md).
|    [tracingHeaderTags](#transmodelApi_tracingHeaderTags) | `string[]` | Used to group requests when monitoring OTP. | *Optional* | | na |
| [updaters](UpdaterConfig.md) | `object[]` | Configuration for the updaters that import various types of data into OTP. | *Optional* | | 1.5 |
| [vectorTileLayers](sandbox/MapboxVectorTilesApi.md) | `object[]` | Configuration of the individual layers for the Mapbox vector tiles. | *Optional* | | 2.0 |
| vehicleRentalServiceDirectory | `object` | Configuration for the vehicle rental service directory. | *Optional* | | 2.0 |
|    language | `string` | Language code. | *Optional* | | na |
|    sourcesName | `string` | Json tag name for updater sources. | *Optional* | `"systems"` | na |
|    updaterNetworkName | `string` | Json tag name for the network name for each source. | *Optional* | `"id"` | na |
|    updaterUrlName | `string` | Json tag name for endpoint urls for each source. | *Optional* | `"url"` | na |
|    url | `uri` | Endpoint for the VehicleRentalServiceDirectory | *Required* | | na |
|    [headers](#vehicleRentalServiceDirectory_headers) | `map of string` | HTTP headers to add to the request. Any header key, value can be inserted. | *Optional* | | na |
| [vehicleRentalServiceDirectory](sandbox/VehicleRentalServiceDirectory.md) | `object` | Configuration for the vehicle rental service directory. | *Optional* | | 2.0 |

<!-- PARAMETERS-TABLE END -->

Expand Down Expand Up @@ -204,6 +199,22 @@ entire transit network. The memory overhead of setting this higher than the maxi
transfers is very little so it is better to set it too high than to low.


<h3 id="transit_maxSearchWindow">maxSearchWindow</h3>

**Since version:** `2.4`**Type:** `duration`**Cardinality:** `Optional`**Default value:** `"PT24H"`
**Path:** /transit

Upper limit of the request parameter searchWindow.

Maximum search window that can be set through the searchWindow API parameter.
Due to the way timetable data are collected before a Raptor trip search,
using a search window larger than 24 hours may lead to inconsistent search results.
Limiting the search window prevents also potential performance issues.
The recommended maximum value is 24 hours.
This parameter does not restrict the maximum duration of a dynamic search window (use
the parameter `transit.dynamicSearchWindow.maxWindow` to specify such a restriction).


<h3 id="transit_scheduledTripBinarySearchThreshold">scheduledTripBinarySearchThreshold</h3>

**Since version:** `na`**Type:** `integer`**Cardinality:** `Optional`**Default value:** `50`
Expand Down Expand Up @@ -415,13 +426,6 @@ Only turn this feature on if you have unique ids across all feeds, without the f

Used to group requests when monitoring OTP.

<h3 id="vehicleRentalServiceDirectory_headers">headers</h3>

**Since version:** `na`**Type:** `map of string`**Cardinality:** `Optional`
**Path:** /vehicleRentalServiceDirectory

HTTP headers to add to the request. Any header key, value can be inserted.


<!-- PARAMETERS-DETAILS END -->

Expand Down
100 changes: 89 additions & 11 deletions docs/sandbox/VehicleRentalServiceDirectory.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,102 @@
# Vehicle Rental Service Directory API support.

This adds support for the GBFS service directory endpoint component located at
https://github.com/entur/lamassu. OTP uses the service directory to lookup and connect to all GBFS
endpoints registered in the directory. This simplifies the management of the GBFS endpoints, since
multiple services/components like OTP can connect to the directory and get the necessary
configuration from it.


## Contact Info

- Gard Mellemstrand, Entur, Norway
- Entur, Norway


## Changelog

- Initial implementation of bike share updater API support
- Make json tag names
configurable [#3447](https://github.com/opentripplanner/OpenTripPlanner/pull/3447)

## Documentation
- Make json tag names configurable [#3447](https://github.com/opentripplanner/OpenTripPlanner/pull/3447)
- Enable GBFS geofencing with VehicleRentalServiceDirectory [#5324](https://github.com/opentripplanner/OpenTripPlanner/pull/5324)

This adds support for the GBFS service directory endpoint component located
at https://github.com/entur/lahmu. OTP use the service directory to lookup and connect to all GBFS
endpoints registered in the directory. This simplify the management of the GBFS endpoints, since
multiple services/components like OTP can connect to the directory and get the necessary
configuration from it.

### Configuration
## Configuration

To enable this you need to specify a url for the `vehicleRentalServiceDirectory` in
the `router-config.json`

### Parameter Summary

<!-- PARAMETERS-TABLE BEGIN -->
<!-- NOTE! This section is auto-generated. Do not change, change doc in code instead. -->

| Config Parameter | Type | Summary | Req./Opt. | Default Value | Since |
|-----------------------------------------------------|:---------------:|---------------------------------------------------------------------------------|:----------:|---------------|:-----:|
| language | `string` | Language code. | *Optional* | | 2.1 |
| sourcesName | `string` | Json tag name for updater sources. | *Optional* | `"systems"` | 2.1 |
| updaterNetworkName | `string` | Json tag name for the network name for each source. | *Optional* | `"id"` | 2.1 |
| updaterUrlName | `string` | Json tag name for endpoint urls for each source. | *Optional* | `"url"` | 2.1 |
| url | `uri` | Endpoint for the VehicleRentalServiceDirectory | *Required* | | 2.1 |
| [headers](#vehicleRentalServiceDirectory_headers) | `map of string` | HTTP headers to add to the request. Any header key, value can be inserted. | *Optional* | | 2.1 |
| [networks](#vehicleRentalServiceDirectory_networks) | `object[]` | List all networks to include. Use "network": "default-network" to set defaults. | *Optional* | | 2.4 |
|       geofencingZones | `boolean` | Enables geofencingZones for the given network | *Optional* | `false` | 2.4 |
|       network | `string` | The network name | *Required* | | 2.4 |

<!-- PARAMETERS-TABLE END -->


### Parameter Details

<!-- PARAMETERS-DETAILS BEGIN -->
<!-- NOTE! This section is auto-generated. Do not change, change doc in code instead. -->

<h4 id="vehicleRentalServiceDirectory_headers">headers</h4>

**Since version:** `2.1`**Type:** `map of string`**Cardinality:** `Optional`
**Path:** /vehicleRentalServiceDirectory

HTTP headers to add to the request. Any header key, value can be inserted.

<h4 id="vehicleRentalServiceDirectory_networks">networks</h4>

**Since version:** `2.4`**Type:** `object[]`**Cardinality:** `Optional`
**Path:** /vehicleRentalServiceDirectory

List all networks to include. Use "network": "default-network" to set defaults.

If no default network exists only the listed networks are used. Configure a network with
name "default-network" to include all unlisted networks. If not present, all unlisted
networks are dropped. Note! The values in the "default-network" are not used to set
missing field values in networks listed.



<!-- PARAMETERS-DETAILS END -->


### Example

<!-- JSON-EXAMPLE BEGIN -->
<!-- NOTE! This section is auto-generated. Do not change, change doc in code instead. -->

```JSON
// router-config.json
{
"vehicleRentalServiceDirectory" : {
"url" : "https://example.com",
"sourcesName" : "systems",
"updaterUrlName" : "url",
"updaterNetworkName" : "id",
"headers" : {
"ET-Client-Name" : "otp"
},
"networks" : [
{
"network" : "oslo-by-sykkel",
"geofencingZones" : true
}
]
}
}
```

<!-- JSON-EXAMPLE END -->
17 changes: 6 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@


<properties>
<otp.serialization.version.id>120</otp.serialization.version.id>
<otp.serialization.version.id>121</otp.serialization.version.id>
<!-- Lib versions - keep list sorted on property name -->
<geotools.version>29.2</geotools.version>
<google.dagger.version>2.48.1</google.dagger.version>
<jackson.version>2.15.2</jackson.version>
<jersey.version>3.1.3</jersey.version>
<junit.version>5.10.0</junit.version>
<micrometer.version>1.11.4</micrometer.version>
<micrometer.version>1.11.5</micrometer.version>
<netcdf4.version>5.5.3</netcdf4.version>
<logback.version>1.4.11</logback.version>
<lucene.version>9.8.0</lucene.version>
Expand Down Expand Up @@ -579,7 +579,7 @@
<!-- This make sure all google libraries are using compatible versions. -->
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.22.0</version>
<version>26.24.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -954,22 +954,17 @@
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.36.0</version>
<version>1.43.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-messaging-servicebus</artifactId>
<version>7.13.2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-servicebus</artifactId>
<version>3.6.7</version>
<version>7.14.4</version>
</dependency>
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-servicebus</artifactId>
<version>2.24.0</version>
<version>2.30.0</version>
</dependency>
<dependency>
<groupId>ch.poole</groupId>
Expand Down
4 changes: 3 additions & 1 deletion renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
"@graphql-codegen/cli",
"@graphql-codegen/java",
"@graphql-codegen/java-resolvers",
"graphql"
"graphql",
"io.micrometer:micrometer-registry-prometheus",
"io.micrometer:micrometer-registry-influx"
],
// we don't use the 'monthly' preset because that only fires on the first day of the month
// when there might already other PRs open
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.util.List;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.opentripplanner.ext.fares.impl.CombinedInterlinedLegsFareService.CombinationMode;
Expand Down Expand Up @@ -54,7 +55,7 @@ class CombinedInterlinedLegsFareServiceTest implements PlanTestConstants {
name = "Itinerary with {3} and combination mode {0} should lead to a fare of {2}"
)
@VariableSource("testCases")
void modeAlways(CombinationMode mode, Itinerary itinerary, Money expectedPrice, String hint) {
void modes(CombinationMode mode, Itinerary itinerary, Money totalPrice, String hint) {
var service = new CombinedInterlinedLegsFareService(mode);
service.addFareRules(
FareType.regular,
Expand All @@ -65,7 +66,43 @@ void modeAlways(CombinationMode mode, Itinerary itinerary, Money expectedPrice,
assertNotNull(fare);

var price = fare.getFare(FareType.regular);
assertEquals(totalPrice, price);

assertEquals(expectedPrice, price);
var firstLeg = itinerary.getTransitLeg(0);
var uses = fare.legProductsFromComponents().get(firstLeg);
assertEquals(1, uses.size());

var secondLeg = itinerary.getTransitLeg(1);
uses = fare.legProductsFromComponents().get(secondLeg);
assertEquals(1, uses.size());
}

@Test
void legFares() {
var itinerary = interlinedWithSameRoute;
var service = new CombinedInterlinedLegsFareService(ALWAYS);
service.addFareRules(
FareType.regular,
List.of(AIRPORT_TO_CITY_CENTER_SET, INSIDE_CITY_CENTER_SET)
);

var fare = service.calculateFares(itinerary);

var firstLeg = itinerary.getTransitLeg(0);
var uses = List.copyOf(fare.legProductsFromComponents().get(firstLeg));
assertEquals(1, uses.size());

var firstLegUse = uses.get(0);
assertEquals(tenDollars, firstLegUse.product().price());

var secondLeg = itinerary.getTransitLeg(1);
uses = List.copyOf(fare.legProductsFromComponents().get(secondLeg));
assertEquals(1, uses.size());

var secondLegUse = uses.get(0);
assertEquals(tenDollars, secondLegUse.product().price());

// the same far product is used for both legs as you only need to buy one
assertEquals(secondLegUse, firstLegUse);
}
}
Loading

0 comments on commit cb5b34e

Please sign in to comment.