Skip to content

Commit

Permalink
Merge pull request #260 from HSLdevcom/DT-6111
Browse files Browse the repository at this point in the history
Dt 6111 Update OTP2 information to Digitransit.fi
  • Loading branch information
vesameskanen authored Nov 11, 2024
2 parents 2924992 + f855ad9 commit 82a5800
Show file tree
Hide file tree
Showing 95 changed files with 1,426 additions and 1,637 deletions.
10 changes: 7 additions & 3 deletions src/components/DockerInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ export default props => {
<div>
<h2>Docker image</h2>
<p>
The resulting Docker image is called{" "}
The Docker image is called{" "}
<strong>{props.docker.imageName}</strong> and it is available at{" "}
<a href={"https://hub.docker.com/r/" + props.docker.imageName}>
{" "}
DockerHub
</a>
. The image can be built using this{" "}
<a href={props.docker.buildScript}>build script</a>.
.
{props.docker.buildScript && (
<span>&nbsp;The image can be built using this{" "}
<a href={props.docker.buildScript}>build script</a>.
</span>
)}
</p>
<p>
To run Docker container, run:
Expand Down
2 changes: 1 addition & 1 deletion src/components/SEO.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default ({ pageTitle, pageDescription, pagePath }) => (

const description =
pageDescription ||
"HSL:n reittiopas.hsl.fi ja Traficomin opas.matka.fi uudistuivat. Apuasi kaivataan kehitystyössä.";
"Uuden ajan reittioppaan käyttöliittymät ja rajapinnat.";

const shareImageUrl = "http://digitransit.fi/share-image.png";

Expand Down
26 changes: 0 additions & 26 deletions src/html.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,32 +81,6 @@ export default class HTML extends React.Component {
id="___gatsby"
dangerouslySetInnerHTML={{ __html: this.props.body }}
/>
<script
type="text/javascript"
dangerouslySetInnerHTML={{
__html: `
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//piwik.digitransit.fi/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 1]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
`
}}
/>
<noscript>
<p>
<img
src="//piwik.digitransit.fi/piwik.php?idsite=1"
style={{ border: 0 }}
alt=""
/>
</p>
</noscript>
{this.props.postBodyComponents}
</body>
</html>
Expand Down
64 changes: 15 additions & 49 deletions src/pages/en/developers/apis/1-routing-api/0-graphql/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: GraphQL
# replit:
# title: "Examples"
# note: "The examples below send a GraphQL query using HTTP POST to <code>https://api.digitransit.fi/routing/v1/routers/hsl/index/graphql</code>. This example query asks the server to find a stop with the ID <i>HSL:1040129</i> and return its name, latitude and longitude coordinates, and whether is is accessible by wheelchair.<br/><b>Note:</b> If the examples provided do not return expected results, the stop id may not be in use any more and you should try again with an existing id."
# note: "The examples below send a GraphQL query using HTTP POST to <code>https://api.digitransit.fi/routing/v2/hsl/gtfs/v1</code>. This example query asks the server to find a stop with the ID <i>HSL:1040129</i> and return its name, latitude and longitude coordinates, and whether is is accessible by wheelchair.<br/><b>Note:</b> If the examples provided do not return expected results, the stop id may not be in use any more and you should try again with an existing id."
# embeds:
# -
# title: "Content-Type: application/graphql"
Expand Down Expand Up @@ -70,17 +70,17 @@ The following queries would request a stop with id `HSL:1173434` and return its

### IDs

All objects in the GraphQL API have a global ID (field `id`), which can be used as a cache key or to refetch the object using query type **node**.
Some objects in the GraphQL API have a global ID (field `id`), which can be used as a cache key or to refetch the object using query type **node**.

Global IDs in the Routing API are defined by [Relay](https://facebook.github.io/relay/graphql/objectidentification.htm) and should not be confused with other IDs (such as `gtfsId`) that objects may have.

### Interfaces

GraphQL supports interfaces, which objects can implement by including fields required by the interface. Two interfaces used in the Routing API are **Node** (which has the field `id` used for global IDs) and **PlaceInterface**.
GraphQL supports interfaces, which objects can implement by including fields required by the interface.

If a query type returns an interface, [inline fragments](https://graphql.org/learn/queries/#inline-fragments) have to be used to access fields defined by the object implementing the interface.

For example, query type **nearest** returns a list of **PlaceInterfaces** and types **BikePark** and **Stop** implement **PlaceInterface**.<br/>
For example, query type **nearest** returns a list of **PlaceInterfaces** and types **VehicleParking** and **Stop** implement **PlaceInterface**.<br/>
The following query returns field `spacesAvailable` for bike parks and field `code` for stops.
```graphql
{
Expand All @@ -95,10 +95,10 @@ The following query returns field `spacesAvailable` for bike parks and field `co
gtfsId
code
}
...on BikePark {
...on VehicleParking {
vehicleParkingId
name
bikeParkId
spacesAvailable
bicyclePlaces
}
}
distance
Expand Down Expand Up @@ -131,49 +131,11 @@ For example, the following query would request a route with name `550` (using *R
}
```

### <a name="batching"></a>Batching

Multiple queries can be combined and sent in one POST request. Batched queries require less server roundtrips and can be processed more efficiently on the server.

For example, the following query would request a stop with id `HSL:1173434` and a route with id `HSL:1009`:
```graphql
{
stop(id: "HSL:1173434") {
name
lat
lon
routes {
shortName
longName
}
}
route(id: "HSL:1009") {
shortName
longName
}
}
```

If the request includes multiple queries with same type, they must be renamed using aliases. For example, the following query would request two routes and return them as `route1` and `route2`:

```graphql
{
route1: route(id: "HSL:2550") {
shortName
longName
}
route2: route(id: "HSL:2551") {
shortName
longName
}
}
```

### Pagination
* Query types which support pagination can be used without pagination by omitting arguments `first` and `after`, in which case all data is returned on one page

Some query types support pagination, which can be used to limit the amount of data returned per query.
<br/>Query types which support pagination return a [Relay cursor connection](https://facebook.github.io/relay/graphql/connections.htm) to the data.
<br/>Query types which support pagination return a [Relay cursor connection](https://relay.dev/graphql/connections.htm) to the data.

For example, **stopsByRadius** supports pagination. The following query requests stops within 300m of 60.19924, 24.94112 and returns 2 stops per page (argument `first`).
```graphql
Expand Down Expand Up @@ -299,11 +261,15 @@ An example response:
In most cases, a GraphQL client should be used instead of plain HTTP requests, as GraphQL clients have many useful features (such as caching, batching and validating queries), which would otherwise have to be implemented manually.

Two commonly used GraphQL clients are
* [Relay](http://facebook.github.io/relay/en/) by Facebook, supports React
* [Apollo](https://www.apollographql.com/client), supports multiple development platforms, including Android and iOS
* [Relay](https://relay.dev/) by Facebook, supports React
* [Apollo](https://www.apollographql.com/), supports multiple development platforms, including Android and iOS

### GraphQL schema

The current development version of the schema is available [here](https://raw.githubusercontent.com/HSLdevcom/OpenTripPlanner/refs/heads/dev-2.x/application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls). It might not always match the production version completely. The production schema can be accessed either by browsing the files from our latest [release in Github](https://github.com/HSLdevcom/OpenTripPlanner/releases) or by running [this example in GraphQL console](<https://api.digitransit.fi/graphiql/hsl/v2?query=query%2520IntrospectionQuery%2520%257B%250A%2520%2520__schema%2520%257B%250A%2520%2520%2520%2520queryType%2520%257B%250A%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520mutationType%2520%257B%250A%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520subscriptionType%2520%257B%250A%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520types%2520%257B%250A%2520%2520%2520%2520%2520%2520...FullType%250A%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520directives%2520%257B%250A%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%2520%2520description%250A%2520%2520%2520%2520%2520%2520locations%250A%2520%2520%2520%2520%2520%2520args%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520...InputValue%250A%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%257D%250A%2520%2520%257D%250A%257D%250A%250Afragment%2520FullType%2520on%2520__Type%2520%257B%250A%2520%2520kind%250A%2520%2520name%250A%2520%2520description%250A%2520%2520fields%28includeDeprecated%253A%2520true%29%2520%257B%250A%2520%2520%2520%2520name%250A%2520%2520%2520%2520description%250A%2520%2520%2520%2520args%2520%257B%250A%2520%2520%2520%2520%2520%2520...InputValue%250A%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520type%2520%257B%250A%2520%2520%2520%2520%2520%2520...TypeRef%250A%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520isDeprecated%250A%2520%2520%2520%2520deprecationReason%250A%2520%2520%257D%250A%2520%2520inputFields%2520%257B%250A%2520%2520%2520%2520...InputValue%250A%2520%2520%257D%250A%2520%2520interfaces%2520%257B%250A%2520%2520%2520%2520...TypeRef%250A%2520%2520%257D%250A%2520%2520enumValues%28includeDeprecated%253A%2520true%29%2520%257B%250A%2520%2520%2520%2520name%250A%2520%2520%2520%2520description%250A%2520%2520%2520%2520isDeprecated%250A%2520%2520%2520%2520deprecationReason%250A%2520%2520%257D%250A%2520%2520possibleTypes%2520%257B%250A%2520%2520%2520%2520...TypeRef%250A%2520%2520%257D%250A%257D%250A%250Afragment%2520InputValue%2520on%2520__InputValue%2520%257B%250A%2520%2520name%250A%2520%2520description%250A%2520%2520type%2520%257B%250A%2520%2520%2520%2520...TypeRef%250A%2520%2520%257D%250A%2520%2520defaultValue%250A%257D%250A%250Afragment%2520TypeRef%2520on%2520__Type%2520%257B%250A%2520%2520kind%250A%2520%2520name%250A%2520%2520ofType%2520%257B%250A%2520%2520%2520%2520kind%250A%2520%2520%2520%2520name%250A%2520%2520%2520%2520ofType%2520%257B%250A%2520%2520%2520%2520%2520%2520kind%250A%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%2520%2520ofType%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520kind%250A%2520%2520%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%2520%2520%2520%2520ofType%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520kind%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520ofType%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520kind%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520ofType%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520kind%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520ofType%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520kind%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%257D%250A%2520%2520%257D%250A%257D%250A&operationName=IntrospectionQuery>)

## Further reading

* The [GraphQL site](https://graphql.org/learn/) provides more information on how to use GraphQL
* [How Facebook sees GraphQL](https://facebook.github.io/relay/docs/thinking-in-graphql.html)
* [Thinking in GraphQL](https://relay.dev/docs/principles-and-architecture/thinking-in-graphql/)

16 changes: 10 additions & 6 deletions src/pages/en/developers/apis/1-routing-api/1-graphiql/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ order: 20

### There are a few options for using GraphiQL:

1. Using our hosted browser versions for the three available regions. The browser versions have the correct endpoints configured already.
1. Using our hosted browser versions for the five available regions. The browser versions have the correct endpoints configured already.
* [Helsinki region](https://api.digitransit.fi/graphiql/hsl)
* [Waltti regions](https://api.digitransit.fi/graphiql/waltti)
* [Waltti-Opas regions](https://api.digitransit.fi/graphiql/waltti-alt)
* [Seutu+ regions](https://api.digitransit.fi/graphiql/varely)
* [Entire Finland](https://api.digitransit.fi/graphiql/finland)
2. A browser extension like [ChromeiQL](https://chrome.google.com/webstore/detail/chromeiql/fkkiamalmpiidkljmicmjfbieiclmeij) (see regional endpoints below)
3. For Mac OSX you can use [the desktop GraphiQL app](https://github.com/skevy/graphiql-app) (see regional endpoints below)
Expand All @@ -28,11 +30,13 @@ All options work similarly and their UI looks more or less like this (ChromeiQL

1. If you are using the GraphiQL app or a browser extension, set the GraphQL Endpoint to one of the following:

| Region | Endpoint |
|-----------------|----------------------------------------------------------------------|
| Helsinki region | `https://api.digitransit.fi/routing/v1/routers/hsl/index/graphql` |
| Waltti regions | `https://api.digitransit.fi/routing/v1/routers/waltti/index/graphql` |
| Entire Finland | `https://api.digitransit.fi/routing/v1/routers/finland/index/graphql` |
| Region | Endpoint |
|---------------------|--------------------------------------------------------------------------|
| Helsinki region | `https://api.digitransit.fi/routing/v2/hsl/gtfs/v1` |
| Waltti regions | `https://api.digitransit.fi/routing/v2/waltti/gtfs/v1` |
| Waltti-Opas region | `https://api.digitransit.fi/routing/v2/waltti-alt/gtfs/v1` |
| Seutu+ region | `https://api.digitransit.fi/routing/v2/varely/gtfs/v1` |
| Entire Finland | `https://api.digitransit.fi/routing/v2/finland/gtfs/v1` |

2. Click [this link](https://api.digitransit.fi/graphiql/hsl?query=%7B%0A%20%20stop(id%3A%20%22HSL%3A1040129%22)%20%7B%0A%20%20%20%20name%0A%20%20%20%20lat%0A%20%20%20%20lon%0A%20%20%20%20wheelchairBoarding%0A%20%20%7D%0A%7D) to run the query below in GraphiQL.

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: Real-time information
order: 40
---

The routing API backend is connected to real-time information for some routes. This means that API queries can return real-time information.

**Note:** Real-time information is not always available and somtimes can be potentially slightly inaccurate.

## What does real-time mean?
Real-time means in this context prediction of arrival and departure times, trip cancellations, partial trip cancellations and occupancy status for vehicles that operate on routes.

## How do I know when data is real-time?
Real-time estimates are enabled by default when making itinerary planning requests. Availability of real-time estimates is not guaranteed, but field `realTime` (*true* / *false*) in each leg of the itinerary will indicate whether that leg's arrival / departure time is using real-time or static timetables. When using real-time, it means that uncertainty for arrival time is less than for purely static timetable data.

Real-time estimates for itinerary planning can be turned off by using the argument `preferences: {transit: {timetable: {excludeRealTimeUpdates: true}}}` of **planConnection** query. Setting this to true will mean that the static timetables will be used in routing.

Departures that have been cancelled through a real-time feed can be included using the arguments `preferences: {transit: {timetable: {includeRealTimeCancelations: true}}}` of **planConnection**. This means that an itinerary can include a cancelled departure while some other alternative that contains no cancellations could be filtered out as the alternative containing a cancellation would normally be better.

For stop timetables and route timetables, real-time estimates are available from stop times through `realtimeArrival` and `realtimeDeparture` fields or from leg's `start` and `end` `estimated` field. Note that in stop times, these fields will have the static arrival / departure time by default and field `realtime` indicates whether the values of those fields have been updated from a real-time source.

## Occupancy information
Some vehicles might have real-time occupancy information available. This information can be accessed through `Trip` type's `occupancy` field.

**Note:** Currently, this information is always the current state (or the last known state). There is no occupancy prediction data available.
Loading

0 comments on commit 82a5800

Please sign in to comment.