Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev-2.x' into geocoder-agency
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Jan 30, 2024
2 parents a0e40e3 + 6980767 commit bfc479f
Show file tree
Hide file tree
Showing 116 changed files with 2,325 additions and 1,685 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ jobs:
timeout-minutes: 20
steps:
# Starting in v2.2 checkout action fetches all tags when fetch-depth=0, for auto-versioning.
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4
with:
fetch-depth: 0

# nodejs is needed because the dynamic download of it via the prettier maven plugin often
# times out
# Example: https://github.com/opentripplanner/OpenTripPlanner/actions/runs/4490450225/jobs/7897533439
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18

# Java setup step completes very fast, no need to run in a preconfigured docker container
- name: Set up JDK 21
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
Expand Down Expand Up @@ -65,9 +65,9 @@ jobs:
timeout-minutes: 20
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
Expand All @@ -91,7 +91,7 @@ jobs:

steps:

- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4
# this is necessary so that the correct credentials are put into the git configuration
# when we push to dev-2.x and push the HTML to the git repo
if: github.event_name == 'push' && (github.ref == 'refs/heads/dev-2.x' || github.ref == 'refs/heads/master')
Expand All @@ -101,7 +101,7 @@ jobs:
# was modified last
fetch-depth: 1000

- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4
# for a simple PR where we don't push, we don't need any credentials
if: github.event_name == 'pull_request'

Expand All @@ -113,7 +113,7 @@ jobs:
if: github.event_name == 'pull_request'
run: mkdocs build

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18

Expand Down Expand Up @@ -174,8 +174,8 @@ jobs:
if: github.repository_owner == 'opentripplanner'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
- name: Run code generator
Expand All @@ -184,7 +184,7 @@ jobs:
yarn install
yarn generate
- name: Set up JDK 21
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
Expand All @@ -199,16 +199,16 @@ jobs:
- build-windows
- build-linux
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
cache: maven
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Build container image with Jib, push to Dockerhub
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/debug-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: actions/checkout@v4
if: github.event_name == 'pull_request'

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/performance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ jobs:
profile: extended

steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4
if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x'
with:
fetch-depth: 0

- name: Set up JDK
if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x'
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/post-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:

- name: Checkout
uses: actions/checkout@v3.1.0
uses: actions/checkout@v4
with:
token: ${{ secrets.CHANGELOG_TOKEN }}

Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
git config --global user.email '[email protected]'
- name: Checkout
uses: actions/checkout@v3.1.0
uses: actions/checkout@v4
with:
token: ${{ secrets.CHANGELOG_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion client-next/src/components/MapView/MapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function MapView({
}}
// it's unfortunate that you have to list these layers here.
// maybe there is a way around it: https://github.com/visgl/react-map-gl/discussions/2343
interactiveLayerIds={['regular-stop', 'vertex', 'edge', 'link']}
interactiveLayerIds={['regular-stop', 'area-stop', 'vertex', 'edge', 'link']}
onClick={showFeaturePropPopup}
// put lat/long in URL and pan to it on page reload
hash={true}
Expand Down
4 changes: 2 additions & 2 deletions doc-templates/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ you can run the following bash command:
- `head -c 29 Graph.obj ==> OpenTripPlannerGraph;0000007;` (file header)
- `head -c 28 Graph.obj | tail -c 7 ==> 0000007` (version id)

The Maven _pom.xml_, the _META-INF/MANIFEST.MF_, the OTP command line(`--serVerId`), log start-up
messages and all OTP APIs can be used to get the OTP Serialization Version Id.
The Maven _pom.xml_, the _META-INF/MANIFEST.MF_, the OTP command line(`--serializationVersionId`),
log start-up messages and all OTP APIs can be used to get the OTP Serialization Version Id.

## Include file directive

Expand Down
194 changes: 194 additions & 0 deletions doc-templates/sandbox/MapboxVectorTilesApi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
# Mapbox Vector Tiles API

## Contact Info

- HSL, Finland
- Arcadis, US

## Documentation

This API produces [Mapbox vector tiles](https://docs.mapbox.com/vector-tiles/reference/), which are
used by [Digitransit-ui](https://github.com/HSLdevcom/digitransit-ui) and
[`otp-react-redux`](https://github.com/opentripplanner/otp-react-redux) to show information about
public transit entities on the map.

The tiles can be fetched from `/otp/routers/{routerId}/vectorTiles/{layers}/{z}/{x}/{y}.pbf`,
where `layers` is a comma separated list of layer names from the configuration.

Maplibre/Mapbox GL JS also requires a tilejson.json endpoint which is available at
`/otp/routers/{routerId}/vectorTiles/{layers}/tilejson.json`.

Translatable fields in the tiles are translated based on the `accept-language` header in requests.
Currently, only the language with the highest priority from the header is used.

### Configuration

To enable this you need to add the feature `otp-config.json`.

```json
// otp-config.json
{
"otpFeatures": {
"SandboxAPIMapboxVectorTilesApi": true
}
}
```

The feature must be configured in `router-config.json` as follows

```JSON
{
"vectorTiles": {
"basePath": "/only/configure/if/required",
"layers": [
{
"name": "stops",
"type": "Stop",
"mapper": "Digitransit",
"maxZoom": 20,
"minZoom": 14,
"cacheMaxSeconds": 600
},
{
"name": "stations",
"type": "Station",
"mapper": "Digitransit",
"maxZoom": 20,
"minZoom": 12,
"cacheMaxSeconds": 600
},
// all rental places: stations and free-floating vehicles
{
"name": "citybikes",
"type": "VehicleRental",
"mapper": "Digitransit",
"maxZoom": 20,
"minZoom": 14,
"cacheMaxSeconds": 60,
"expansionFactor": 0.25
},
// just free-floating vehicles
{
"name": "rentalVehicles",
"type": "VehicleRentalVehicle",
"mapper": "DigitransitRealtime",
"maxZoom": 20,
"minZoom": 14,
"cacheMaxSeconds": 60
},
// just rental stations
{
"name": "rentalStations",
"type": "VehicleRentalStation",
"mapper": "Digitransit",
"maxZoom": 20,
"minZoom": 14,
"cacheMaxSeconds": 600
},
// Contains just stations and real-time information for them
{
"name": "realtimeRentalStations",
"type": "VehicleRentalStation",
"mapper": "DigitransitRealtime",
"maxZoom": 20,
"minZoom": 14,
"cacheMaxSeconds": 60
},
// This exists for backwards compatibility. At some point, we might want
// to add a new real-time parking mapper with better translation support
// and less unnecessary fields.
{
"name": "stadtnaviVehicleParking",
"type": "VehicleParking",
"mapper": "Stadtnavi",
"maxZoom": 20,
"minZoom": 14,
"cacheMaxSeconds": 60,
"expansionFactor": 0.25
},
// no real-time, translatable fields are translated based on accept-language header
// and contains less fields than the Stadtnavi mapper
{
"name": "vehicleParking",
"type": "VehicleParking",
"mapper": "Digitransit",
"maxZoom": 20,
"minZoom": 14,
"cacheMaxSeconds": 600,
"expansionFactor": 0.25
},
{
"name": "vehicleParkingGroups",
"type": "VehicleParkingGroup",
"mapper": "Digitransit",
"maxZoom": 17,
"minZoom": 14,
"cacheMaxSeconds": 600,
"expansionFactor": 0.25
}
]
}
}
```

For each layer, the configuration includes:

- `name` which is used in the url to fetch tiles, and as the layer name in the vector tiles.
- `type` which tells the type of the layer. Currently supported:
- `Stop`
- `Station`
- `VehicleRental`: all rental places: stations and free-floating vehicles
- `VehicleRentalVehicle`: free-floating rental vehicles
- `VehicleRentalStation`: rental stations
- `VehicleParking`
- `VehicleParkingGroup`

<!-- INSERT: parameters -->

### Extending

If more generic layers are created for this API, the code should be moved out from the sandbox, into
the core, perhaps potentially leaving specific property mappers in place.

#### Creating a new layer

In order to create a new type of layer, you need to create a new class extending `LayerBuilder<T>`.
You need to implement two methods, `List<Geometry> getGeometries(Envelope query)`, which returns a
list of geometries, with an object of type `T` as their userData in the geometry,
and `double getExpansionFactor()`, which describes how much information outside the tile bounds
should be included. This layer then needs to be added into `VectorTilesResource.layers`, with a
new `LayerType` enum as the key, and the class constructor as the value.

A new mapper needs to be added every time a new layer is added. See below for information.

#### Creating a new mapper

The mapping contains information of what data to include in the vector tiles. The mappers are
defined per layer.

In order to create a new mapper for a layer, you need to create a new class
extending `PropertyMapper<T>`. In that class, you need to implement the
method `Collection<KeyValue<String, Object>> map(T input)`. The type T is dependent on the layer for which
you implement the mapper for. It needs to return a list of attributes, as key-value pairs which will
be written into the vector tile.

The mapper needs to be added to the `mappers` map in the layer, with a new `MapperType` enum as the
key, and a function to create the mapper, with a `Graph` object as a parameter, as the value.

## Changelog

- 2020-07-09: Initial version of Mapbox vector tiles API
- 2021-05-12: Make expansion factor configurable
- 2021-09-07: Rename `BikeRental` to `VehicleRental`
- 2021-10-13: Correctly serialize the vehicle rental name [#3648](https://github.com/opentripplanner/OpenTripPlanner/pull/3648)
- 2022-01-03: Add support for VehicleParking entities
- 2022-04-27: Read the headsign for frequency-only patterns correctly [#4122](https://github.com/opentripplanner/OpenTripPlanner/pull/4122)
- 2022-08-23: Remove patterns and add route gtfsTypes to stop layer [#4404](https://github.com/opentripplanner/OpenTripPlanner/pull/4404)
- 2022-10-11: Added layer for VehicleParkingGroups [#4510](https://github.com/opentripplanner/OpenTripPlanner/pull/4510)
- 2022-10-14: Add separate layers for vehicle rental place types [#4516](https://github.com/opentripplanner/OpenTripPlanner/pull/4516)
- 2022-10-19 [#4529](https://github.com/opentripplanner/OpenTripPlanner/pull/4529):
* Translatable fields are now translated based on accept-language header
* Added DigitransitRealtime for vehicle rental stations
* Changed old vehicle parking mapper to be Stadtnavi
* Added a new Digitransit vehicle parking mapper with no real-time information and less fields
- 2024-01-22: Make `basePath` configurable [#5627](https://github.com/opentripplanner/OpenTripPlanner/pull/5627)
6 changes: 6 additions & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ based on merged pull requests. Search GitHub issues and pull requests for smalle
- Add new path for GTFS GraphQL API, remove batch feature [#5581](https://github.com/opentripplanner/OpenTripPlanner/pull/5581)
- Restructure walk/bicycle/car preferences in router-config.json [#5582](https://github.com/opentripplanner/OpenTripPlanner/pull/5582)
- Revert REST API spelling change of real-time [#5629](https://github.com/opentripplanner/OpenTripPlanner/pull/5629)
- Remove `FareComponent` [#5613](https://github.com/opentripplanner/OpenTripPlanner/pull/5613)
- Add AreaStop layer to new debug frontend [#5636](https://github.com/opentripplanner/OpenTripPlanner/pull/5636)
- Allow configuration of vector tiles base path [#5627](https://github.com/opentripplanner/OpenTripPlanner/pull/5627)
- Change Transmodel API path to `/otp/transmodel/v3` [#5637](https://github.com/opentripplanner/OpenTripPlanner/pull/5637)
- Add flexibleArea to GroupStop Quays [#5625](https://github.com/opentripplanner/OpenTripPlanner/pull/5625)
- Pass-through should override transit-group-priority [#5638](https://github.com/opentripplanner/OpenTripPlanner/pull/5638)
[](AUTOMATIC_CHANGELOG_PLACEHOLDER_DO_NOT_REMOVE)

## 2.4.0 (2023-09-13)
Expand Down
4 changes: 2 additions & 2 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ you can run the following bash command:
- `head -c 29 Graph.obj ==> OpenTripPlannerGraph;0000007;` (file header)
- `head -c 28 Graph.obj | tail -c 7 ==> 0000007` (version id)

The Maven _pom.xml_, the _META-INF/MANIFEST.MF_, the OTP command line(`--serVerId`), log start-up
messages and all OTP APIs can be used to get the OTP Serialization Version Id.
The Maven _pom.xml_, the _META-INF/MANIFEST.MF_, the OTP command line(`--serializationVersionId`),
log start-up messages and all OTP APIs can be used to get the OTP Serialization Version Id.

## Include file directive

Expand Down
Loading

0 comments on commit bfc479f

Please sign in to comment.