-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rest.exe: adapt to ctx-based parse fns
- Loading branch information
Showing
9 changed files
with
194 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
'use strict' | ||
|
||
const omit = require('lodash/omit') | ||
// todo: get the original parseHint differently | ||
const _parseHint = require('../parse/hint') | ||
|
||
const parseHint = (profile, hint, _) => { | ||
return _parseHint(profile, { | ||
const parseHint = (ctx, hint) => { | ||
return _parseHint(ctx, { | ||
...omit(hint, ['value']), | ||
code: hint.key, | ||
txtN: hint.value | ||
// todo: map hint.routeIdxFrom & hint.routeIdxTo | ||
}, _) | ||
}) | ||
} | ||
|
||
module.exports = parseHint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,22 @@ | ||
'use strict' | ||
|
||
const parseScheduledDays = require('../parse/scheduled-days') | ||
const parseJourney = (ctx, j) => { // j = journey | ||
const {profile, opt} = ctx | ||
|
||
const createParseJourney = (profile, opt) => { | ||
const parseLeg = profile.parseJourneyLeg(profile, opt) | ||
|
||
const parseJourney = (j) => { | ||
const legs = j.legs.map(leg => parseLeg(j, leg)) | ||
const res = { | ||
type: 'journey', | ||
legs, | ||
// todo: refreshToken | ||
// todo: cycle | ||
// todo: remarks? | ||
} | ||
|
||
if (opt.scheduledDays && j.serviceDays) { | ||
res.scheduledDays = parseScheduledDays(profile, j.serviceDays.sDaysB) | ||
} | ||
const res = { | ||
type: 'journey', | ||
legs: j.legs.map(leg => profile.parseJourneyLeg(ctx, leg)), | ||
// todo: refreshToken | ||
// todo: cycle | ||
// todo: remarks? | ||
} | ||
|
||
return res | ||
if (opt.scheduledDays && j.serviceDays) { | ||
// todo: year | ||
res.scheduledDays = profile.parseScheduledDays(ctx, j.serviceDays.sDaysB, year) | ||
} | ||
|
||
return parseJourney | ||
return res | ||
} | ||
|
||
module.exports = createParseJourney | ||
module.exports = parseJourney |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,22 @@ | ||
'use strict' | ||
|
||
const createParsePolyline = (profile, opt, _) => { | ||
const parsePolyline = (p) => { | ||
const coordinates = [] | ||
for (let i = 0; i < p.crd.length; i += 2) { | ||
coordinates.push({ | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [p.crd[i], p.crd[i + 1]] | ||
} | ||
}) | ||
} | ||
const parsePolyline = (ctx, p) => { | ||
const coordinates = [] | ||
for (let i = 0; i < p.crd.length; i += 2) { | ||
coordinates.push({ | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [p.crd[i], p.crd[i + 1]] | ||
} | ||
}) | ||
} | ||
|
||
return { | ||
type: 'FeatureCollection', | ||
features: coordinates | ||
} | ||
return { | ||
type: 'FeatureCollection', | ||
features: coordinates | ||
} | ||
return parsePolyline | ||
} | ||
|
||
module.exports = createParsePolyline | ||
module.exports = parsePolyline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.