mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
reachableFrom(loc, [opt]) -> reachableFrom(address, [opt])
This commit is contained in:
parent
e65b2d8780
commit
3ac04a0ebd
9 changed files with 16 additions and 16 deletions
|
@ -1,10 +1,10 @@
|
|||
# `reachableFrom(location, [opt])`
|
||||
# `reachableFrom(address, [opt])`
|
||||
|
||||
This method can be used to compute the area around a location that is reachable within a certain time. This concept is called [isochrone diagram](https://en.wikipedia.org/wiki/Isochrone_map#Transportation_planning).
|
||||
This method can be used to get stations reachable within a certain time from an address. This concept is called [isochrone diagram](https://en.wikipedia.org/wiki/Isochrone_map#Transportation_planning).
|
||||
|
||||
*Note*: It appears that HAFAS cannot generate actual isochrones, but a list of reachable stations, which you can estimate the isochrone(s) from.
|
||||
*Note*: It appears that HAFAS cannot generate actual isochrones, but only the list of reachable stations, which you can estimate the isochrone(s) from.
|
||||
|
||||
`location` must be an [*FPTF* `location` object](https://github.com/public-transport/friendly-public-transport-format/blob/1.1.1/spec/readme.md#location-objects).
|
||||
`address` must be an [*FPTF* `location` object](https://github.com/public-transport/friendly-public-transport-format/blob/1.1.1/spec/readme.md#location-objects).
|
||||
|
||||
With `opt`, you can override the default options, which look like this:
|
||||
|
||||
|
@ -24,7 +24,7 @@ With `opt`, you can override the default options, which look like this:
|
|||
|
||||
## Response
|
||||
|
||||
`reachableFrom(loc, [opt])` returns an array, in which each item has a `duration` and an array of [*Friendly Public Transport Format* `1.1.1`](https://github.com/public-transport/friendly-public-transport-format/tree/1.1.1) stations.
|
||||
`reachableFrom(address, [opt])` returns an array, in which each item has a `duration` and an array of [*Friendly Public Transport Format* `1.1.1`](https://github.com/public-transport/friendly-public-transport-format/tree/1.1.1) stations.
|
||||
|
||||
As an example, we're going to use the [VBB profile](../p/vbb):
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
- [`station(id, [opt])`](station.md) – get details about a station
|
||||
- [`nearby(location, [opt])`](nearby.md) – show stations & POIs around
|
||||
- [`radar(north, west, south, east, [opt])`](radar.md) – find all vehicles currently in a certain area
|
||||
- [`reachableFrom(location, [opt])`](reachable-from.md) – get all stations reachable from a location within `n` minutes
|
||||
- [`reachableFrom(address, [opt])`](reachable-from.md) – get all stations reachable from an address within `n` minutes
|
||||
|
||||
## Writing a profile
|
||||
|
||||
|
|
6
index.js
6
index.js
|
@ -463,8 +463,8 @@ const createClient = (profile, userAgent, request = _request) => {
|
|||
})
|
||||
}
|
||||
|
||||
const reachableFrom = (location, opt = {}) => {
|
||||
validateLocation(location, 'location')
|
||||
const reachableFrom = (address, opt = {}) => {
|
||||
validateLocation(address, 'address')
|
||||
|
||||
opt = Object.assign({
|
||||
when: Date.now(),
|
||||
|
@ -477,7 +477,7 @@ const createClient = (profile, userAgent, request = _request) => {
|
|||
return request(profile, userAgent, opt, {
|
||||
meth: 'LocGeoReach',
|
||||
req: {
|
||||
loc: profile.formatLocation(profile, location, 'location'),
|
||||
loc: profile.formatLocation(profile, address, 'address'),
|
||||
maxDur: opt.maxDuration,
|
||||
maxChg: opt.maxTransfers,
|
||||
date: profile.formatDate(profile, opt.when),
|
||||
|
|
|
@ -380,7 +380,7 @@ test('reachableFrom', co(function* (t) {
|
|||
yield testReachableFrom({
|
||||
test: t,
|
||||
reachableFrom: client.reachableFrom,
|
||||
loc: torfstr17,
|
||||
address: torfstr17,
|
||||
when,
|
||||
maxDuration: 15,
|
||||
validate
|
||||
|
|
|
@ -266,7 +266,7 @@ test('reachableFrom', co(function* (t) {
|
|||
yield testReachableFrom({
|
||||
test: t,
|
||||
reachableFrom: client.reachableFrom,
|
||||
loc: {
|
||||
address: {
|
||||
type: 'location',
|
||||
address: '604 W 9TH ST, Austin, TX 78701',
|
||||
latitude: 30.272910,
|
||||
|
|
|
@ -361,7 +361,7 @@ test('reachableFrom', co(function* (t) {
|
|||
yield testReachableFrom({
|
||||
test: t,
|
||||
reachableFrom: client.reachableFrom,
|
||||
loc: torfstr17,
|
||||
address: torfstr17,
|
||||
when,
|
||||
maxDuration: 15,
|
||||
validate
|
||||
|
|
|
@ -8,13 +8,13 @@ const testReachableFrom = co(function* (cfg) {
|
|||
const {
|
||||
test: t,
|
||||
reachableFrom,
|
||||
loc,
|
||||
address,
|
||||
when,
|
||||
maxDuration,
|
||||
validate
|
||||
} = cfg
|
||||
|
||||
const results = yield reachableFrom(loc, {
|
||||
const results = yield reachableFrom(address, {
|
||||
when, maxDuration
|
||||
})
|
||||
|
||||
|
|
|
@ -360,7 +360,7 @@ test('reachableFrom', co(function* (t) {
|
|||
yield testReachableFrom({
|
||||
test: t,
|
||||
reachableFrom: client.reachableFrom,
|
||||
loc: berlinerStr,
|
||||
address: berlinerStr,
|
||||
when,
|
||||
maxDuration: 60,
|
||||
validate
|
||||
|
|
|
@ -370,7 +370,7 @@ test('reachableFrom', co(function* (t) {
|
|||
yield testReachableFrom({
|
||||
test: t,
|
||||
reachableFrom: client.reachableFrom,
|
||||
loc: torfstr17,
|
||||
address: torfstr17,
|
||||
when,
|
||||
maxDuration: 15,
|
||||
validate
|
||||
|
|
Loading…
Add table
Reference in a new issue