diff --git a/docs/journeys.md b/docs/journeys.md index a316f7ae..34ed7b85 100644 --- a/docs/journeys.md +++ b/docs/journeys.md @@ -126,6 +126,11 @@ The `Promise` returned by `journeys()` will resolve with an object with the `jou express: false, night: false }, + currentLocation: { + type: 'location', + latitude: 52.51384, + longitude: 13.526806, + }, origin: { type: 'station', diff --git a/docs/trip.md b/docs/trip.md index 9445c3d8..639a83f3 100644 --- a/docs/trip.md +++ b/docs/trip.md @@ -57,6 +57,31 @@ The response looked like this: ```js { 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: { type: 'station', @@ -107,26 +132,7 @@ The response looked like this: arrivalDelay: 90, arrivalPlatform: '3a', 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: [ /* … */ ] } ``` diff --git a/parse/journey-leg.js b/parse/journey-leg.js index 08944941..d64cc6c3 100644 --- a/parse/journey-leg.js +++ b/parse/journey-leg.js @@ -107,6 +107,15 @@ const parseJourneyLeg = (ctx, pt, date) => { // pt = raw leg res.tripId = pt.jny.jid res.line = pt.jny.line || 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) res.arrivalPlatform = arrPl.platform res.plannedArrivalPlatform = arrPl.plannedPlatform diff --git a/test/fixtures/rsag-journey.js b/test/fixtures/rsag-journey.js index 82219d96..fca9935b 100644 --- a/test/fixtures/rsag-journey.js +++ b/test/fixtures/rsag-journey.js @@ -23,6 +23,11 @@ module.exports = { } }, reachable: true, + currentLocation: { + type: 'location', + latitude: 54.078242, + longitude: 12.131078, + }, origin: { type: 'stop',