2018-03-16 17:28:48 +01:00
# `radar({north, west, south, east}, [opt])`
2017-12-17 18:16:04 +01:00
Use this method to find all vehicles currently in an area. Note that it is not supported by every profile/endpoint.
`north` , `west` , `south` and `eath` must be numbers (e.g. `52.52411` ). Together, they form a [bounding box ](https://en.wikipedia.org/wiki/Minimum_bounding_box ).
With `opt` , you can override the default options, which look like this:
```js
{
results: 256, // maximum number of vehicles
duration: 30, // compute frames for the next n seconds
frames: 3, // nr of frames to compute
2018-12-13 19:27:31 +01:00
polylines: true, // return a track shape for each vehicle?
2020-03-18 20:04:39 +01:00
subStops: true, // parse & expose sub-stops of stations?
entrances: true, // parse & expose entrances of stops/stations?
2018-07-09 12:40:38 +02:00
language: 'en' // language to get results in
2017-12-17 18:16:04 +01:00
}
```
## Response
2018-09-22 19:24:34 +02:00
*Note:* As stated in the [*Friendly Public Transport Format* `1.2.0` ](https://github.com/public-transport/friendly-public-transport-format/tree/1.2.0 ), the returned `departure` and `arrival` times include the current delay. The `departureDelay` /`arrivalDelay` fields express how much they differ from the schedule.
2017-12-17 18:16:04 +01:00
2018-01-05 15:01:32 +01:00
As an example, we're going to use the [VBB profile ](../p/vbb ):
2017-12-17 18:16:04 +01:00
```js
const createClient = require('hafas-client')
const vbbProfile = require('hafas-client/p/vbb')
2018-07-19 21:55:03 +02:00
const client = createClient(vbbProfile, 'my-awesome-program')
2017-12-17 18:16:04 +01:00
2018-03-16 17:28:48 +01:00
client.radar({
north: 52.52411,
west: 13.41002,
south: 52.51942,
east: 13.41709
}, {results: 5})
2017-12-17 18:16:04 +01:00
.then(console.log)
.catch(console.error)
```
The response may look like this:
```js
[ {
location: {
type: 'location',
latitude: 52.521508,
longitude: 13.411267
},
2019-12-12 18:42:44 +01:00
2017-12-17 18:16:04 +01:00
line: {
type: 'line',
id: 's9',
2018-08-22 19:02:56 +02:00
fahrtNr: '12345',
2017-12-17 18:16:04 +01:00
name: 'S9',
public: true,
mode: 'train',
product: 'suburban',
symbol: 'S',
nr: 9,
metro: false,
express: false,
2018-01-05 18:46:19 +01:00
night: false,
operator: {
type: 'operator',
id: 's-bahn-berlin-gmbh',
name: 'S-Bahn Berlin GmbH'
}
2017-12-17 18:16:04 +01:00
},
direction: 'S Flughafen Berlin-Schönefeld',
trip: 31463,
2019-12-12 18:42:44 +01:00
2018-11-21 19:45:57 +01:00
nextStopovers: [ {
2018-07-13 11:34:54 +02:00
stop: {
2018-07-11 00:32:57 +02:00
type: 'stop',
2017-12-17 18:16:04 +01:00
id: '900000029101',
name: 'S Spandau',
location: {
type: 'location',
latitude: 52.534794,
longitude: 13.197477
},
products: {
suburban: true,
subway: false,
tram: false,
bus: true,
ferry: false,
express: true,
regional: true
}
},
arrival: null,
2019-12-10 19:40:13 +01:00
plannedArrival: null,
2017-12-18 11:57:48 +01:00
arrivalDelay: null,
2019-12-10 19:40:13 +01:00
arrivalPlatform: null,
plannedArrivalPlatform: null,
departure: null,
plannedDeparture: '2017-12-17T19:16:00+01:00',
departureDelay: null,
departurePlatform: null,
plannedDeparturePlatform: '1'
2017-12-17 18:16:04 +01:00
} /* … */ ],
frames: [ {
origin: {
2018-07-11 00:32:57 +02:00
type: 'stop',
2017-12-17 18:16:04 +01:00
id: '900000100003',
name: 'S+U Alexanderplatz',
location: { /* … */ },
products: { /* … */ }
},
destination: {
2018-07-11 00:32:57 +02:00
type: 'stop',
2017-12-17 18:16:04 +01:00
id: '900000100004',
name: 'S+U Jannowitzbrücke',
location: { /* … */ },
products: { /* … */ }
},
t: 0
}, /* … */ {
origin: { /* Alexanderplatz */ },
destination: { /* Jannowitzbrücke */ },
t: 30000
} ]
}, {
location: {
type: 'location',
latitude: 52.523297,
longitude: 13.411151
},
line: {
type: 'line',
id: 'm2',
2018-08-22 19:02:56 +02:00
fahrtNr: '54321',
2017-12-17 18:16:04 +01:00
name: 'M2',
public: true,
mode: 'train',
product: 'tram',
symbol: 'M',
nr: 2,
metro: true,
express: false,
2018-01-05 18:46:19 +01:00
night: false,
operator: {
type: 'operator',
id: 'berliner-verkehrsbetriebe',
name: 'Berliner Verkehrsbetriebe'
}
2017-12-17 18:16:04 +01:00
},
direction: 'Heinersdorf',
trip: 26321,
2018-11-21 19:45:57 +01:00
nextStopovers: [ {
2018-07-13 11:34:54 +02:00
stop: { /* S+U Alexanderplatz/Dircksenstr. */ },
2017-12-17 18:16:04 +01:00
arrival: null,
2019-12-10 19:40:13 +01:00
plannedArrival: null,
2017-12-18 11:57:48 +01:00
arrivalDelay: null,
2019-12-10 19:40:13 +01:00
departure: null,
plannedAeparture: '2017-12-17T19:52:00+01:00',
2017-12-18 11:57:48 +01:00
departureDelay: null
2017-12-17 18:16:04 +01:00
}, {
2018-07-13 11:34:54 +02:00
stop: { /* Memhardstr. */ },
2019-12-10 19:40:13 +01:00
arrival: null,
plannedArrival: '2017-12-17T19:54:00+01:00',
2017-12-18 11:57:48 +01:00
arrivalDelay: null,
2019-12-10 19:40:13 +01:00
arrivalPlatform: null,
plannedArrivalPlatform: null,
departure: null,
plannedDeparture: '2017-12-17T19:54:00+01:00',
departureDelay: null,
departurePlatform: null,
plannedDeparturePlatform: '1'
2017-12-17 18:16:04 +01:00
}, /* … */ ],
frames: [ {
origin: { /* S+U Alexanderplatz/Dircksenstr. */ },
destination: { /* Memhardstr. */ },
t: 0
}, /* … */ {
origin: { /* Memhardstr. */ },
destination: { /* Mollstr./Prenzlauer Allee */ },
t: 30000
} ]
}, /* … */ ]
```
2018-05-15 19:39:28 +02:00
2018-06-29 14:42:40 +02:00
If you pass `polylines: true` , each movement will have a `polyline` field, as documented in [the corresponding section in the `trip()` docs ](trip.md#polyline-option ), with the exception that station info is missing.