mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
parseJourneyLeg/parseTrip: expose currentLocation ✅📝
This commit is contained in:
parent
464650c366
commit
0a096a13d7
4 changed files with 45 additions and 20 deletions
|
@ -126,6 +126,11 @@ The `Promise` returned by `journeys()` will resolve with an object with the `jou
|
||||||
express: false,
|
express: false,
|
||||||
night: false
|
night: false
|
||||||
},
|
},
|
||||||
|
currentLocation: {
|
||||||
|
type: 'location',
|
||||||
|
latitude: 52.51384,
|
||||||
|
longitude: 13.526806,
|
||||||
|
},
|
||||||
|
|
||||||
origin: {
|
origin: {
|
||||||
type: 'station',
|
type: 'station',
|
||||||
|
|
46
docs/trip.md
46
docs/trip.md
|
@ -57,6 +57,31 @@ The response looked like this:
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
id: '1|31431|28|86|17122017',
|
id: '1|31431|28|86|17122017',
|
||||||
|
direction: 'S Spandau',
|
||||||
|
line: {
|
||||||
|
type: 'line',
|
||||||
|
id: '18299',
|
||||||
|
fahrtNr: '12345',
|
||||||
|
name: 'S9',
|
||||||
|
public: true,
|
||||||
|
mode: 'train',
|
||||||
|
product: 'suburban',
|
||||||
|
symbol: 'S',
|
||||||
|
nr: 9,
|
||||||
|
metro: false,
|
||||||
|
express: false,
|
||||||
|
night: false,
|
||||||
|
operator: {
|
||||||
|
type: 'operator',
|
||||||
|
id: 's-bahn-berlin-gmbh',
|
||||||
|
name: 'S-Bahn Berlin GmbH'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
currentLocation: {
|
||||||
|
type: 'location',
|
||||||
|
latitude: 52.447455,
|
||||||
|
longitude: 13.522464,
|
||||||
|
},
|
||||||
|
|
||||||
origin: {
|
origin: {
|
||||||
type: 'station',
|
type: 'station',
|
||||||
|
@ -107,26 +132,7 @@ The response looked like this:
|
||||||
arrivalDelay: 90,
|
arrivalDelay: 90,
|
||||||
arrivalPlatform: '3a',
|
arrivalPlatform: '3a',
|
||||||
plannedArrivalPlatform: '2',
|
plannedArrivalPlatform: '2',
|
||||||
line: {
|
|
||||||
type: 'line',
|
|
||||||
id: '18299',
|
|
||||||
fahrtNr: '12345',
|
|
||||||
name: 'S9',
|
|
||||||
public: true,
|
|
||||||
mode: 'train',
|
|
||||||
product: 'suburban',
|
|
||||||
symbol: 'S',
|
|
||||||
nr: 9,
|
|
||||||
metro: false,
|
|
||||||
express: false,
|
|
||||||
night: false,
|
|
||||||
operator: {
|
|
||||||
type: 'operator',
|
|
||||||
id: 's-bahn-berlin-gmbh',
|
|
||||||
name: 'S-Bahn Berlin GmbH'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
direction: 'S Spandau',
|
|
||||||
stopovers: [ /* … */ ]
|
stopovers: [ /* … */ ]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -107,6 +107,15 @@ const parseJourneyLeg = (ctx, pt, date) => { // pt = raw leg
|
||||||
res.tripId = pt.jny.jid
|
res.tripId = pt.jny.jid
|
||||||
res.line = pt.jny.line || null
|
res.line = pt.jny.line || null
|
||||||
res.direction = pt.jny.dirTxt && profile.parseStationName(ctx, pt.jny.dirTxt) || null
|
res.direction = pt.jny.dirTxt && profile.parseStationName(ctx, pt.jny.dirTxt) || null
|
||||||
|
|
||||||
|
if (pt.jny.pos) {
|
||||||
|
res.currentLocation = {
|
||||||
|
type: 'location',
|
||||||
|
latitude: pt.jny.pos.y / 1000000,
|
||||||
|
longitude: pt.jny.pos.x / 1000000,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const arrPl = profile.parsePlatform(ctx, pt.arr.aPlatfS || (pt.arr.aPltfS !== undefined ? pt.arr.aPltfS.txt : null), pt.arr.aPlatfR || (pt.arr.aPltfR !== undefined ? pt.arr.aPltfR.txt : null), pt.arr.aCncl)
|
const arrPl = profile.parsePlatform(ctx, pt.arr.aPlatfS || (pt.arr.aPltfS !== undefined ? pt.arr.aPltfS.txt : null), pt.arr.aPlatfR || (pt.arr.aPltfR !== undefined ? pt.arr.aPltfR.txt : null), pt.arr.aCncl)
|
||||||
res.arrivalPlatform = arrPl.platform
|
res.arrivalPlatform = arrPl.platform
|
||||||
res.plannedArrivalPlatform = arrPl.plannedPlatform
|
res.plannedArrivalPlatform = arrPl.plannedPlatform
|
||||||
|
|
5
test/fixtures/rsag-journey.js
vendored
5
test/fixtures/rsag-journey.js
vendored
|
@ -23,6 +23,11 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
reachable: true,
|
reachable: true,
|
||||||
|
currentLocation: {
|
||||||
|
type: 'location',
|
||||||
|
latitude: 54.078242,
|
||||||
|
longitude: 12.131078,
|
||||||
|
},
|
||||||
|
|
||||||
origin: {
|
origin: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
|
|
Loading…
Add table
Reference in a new issue