mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
INSA: enable radar
This commit is contained in:
parent
ba97275bae
commit
c123d9e451
5 changed files with 58 additions and 3 deletions
|
@ -16,6 +16,7 @@ client.journeys('008010226', '008013456', {results: 1})
|
||||||
// latitude: 52.148842,
|
// latitude: 52.148842,
|
||||||
// longitude: 11.641705
|
// longitude: 11.641705
|
||||||
// }, {distance: 200})
|
// }, {distance: 200})
|
||||||
|
// client.radar(52.148364, 11.600826, 52.108486, 11.651451, {results: 10})
|
||||||
|
|
||||||
// .then(([journey]) => {
|
// .then(([journey]) => {
|
||||||
// const leg = journey.legs[0]
|
// const leg = journey.legs[0]
|
||||||
|
|
|
@ -76,7 +76,7 @@ const insaProfile = {
|
||||||
parseLine: createParseLine,
|
parseLine: createParseLine,
|
||||||
|
|
||||||
journeyLeg: true
|
journeyLeg: true
|
||||||
// todo: radar?
|
radar: true
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = insaProfile;
|
module.exports = insaProfile;
|
||||||
|
|
|
@ -65,7 +65,8 @@ p.bitmasks[2] = p.national
|
||||||
p.bitmasks[8] = p.regional
|
p.bitmasks[8] = p.regional
|
||||||
p.bitmasks[16] = p.suburban
|
p.bitmasks[16] = p.suburban
|
||||||
p.bitmasks[32] = p.tram
|
p.bitmasks[32] = p.tram
|
||||||
p.bitmasks[64+128] = p.bus
|
p.bitmasks[64] = p.bus
|
||||||
|
p.bitmasks[128] = p.bus
|
||||||
p.bitmasks[256] = p.tourismTrain
|
p.bitmasks[256] = p.tourismTrain
|
||||||
|
|
||||||
p.allProducts = [
|
p.allProducts = [
|
||||||
|
|
|
@ -20,7 +20,7 @@ const parseLocation = (profile, l, lines) => {
|
||||||
type: 'station',
|
type: 'station',
|
||||||
id: l.extId,
|
id: l.extId,
|
||||||
name: l.name,
|
name: l.name,
|
||||||
location: res
|
location: 'number' === typeof res.latitude ? res : null
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('pCls' in l) station.products = profile.parseProducts(l.pCls)
|
if ('pCls' in l) station.products = profile.parseProducts(l.pCls)
|
||||||
|
|
53
test/insa.js
53
test/insa.js
|
@ -310,3 +310,56 @@ test('location', co(function*(t) {
|
||||||
|
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
test('radar', co(function* (t) {
|
||||||
|
const north = 52.148364
|
||||||
|
const west = 11.600826
|
||||||
|
const south = 52.108486
|
||||||
|
const east = 11.651451
|
||||||
|
const vehicles = yield client.radar(north, west, south, east, {
|
||||||
|
duration: 5 * 60, when, results: 10
|
||||||
|
})
|
||||||
|
|
||||||
|
t.ok(Array.isArray(vehicles))
|
||||||
|
t.ok(vehicles.length > 0)
|
||||||
|
for (let v of vehicles) {
|
||||||
|
assertValidLine(t, v.line)
|
||||||
|
|
||||||
|
t.equal(typeof v.location.latitude, 'number')
|
||||||
|
t.ok(v.location.latitude <= 57, 'vehicle is too far away')
|
||||||
|
t.ok(v.location.latitude >= 47, 'vehicle is too far away')
|
||||||
|
t.equal(typeof v.location.longitude, 'number')
|
||||||
|
t.ok(v.location.longitude >= 8, 'vehicle is too far away')
|
||||||
|
t.ok(v.location.longitude <= 14, 'vehicle is too far away')
|
||||||
|
|
||||||
|
t.ok(Array.isArray(v.nextStops))
|
||||||
|
for (let st of v.nextStops) {
|
||||||
|
assertValidStopover(t, st, true)
|
||||||
|
|
||||||
|
if (st.arrival) {
|
||||||
|
t.equal(typeof st.arrival, 'string')
|
||||||
|
const arr = +new Date(st.arrival)
|
||||||
|
// note that this can be an ICE train
|
||||||
|
t.ok(isRoughlyEqual(14 * hour, +when, arr))
|
||||||
|
}
|
||||||
|
if (st.departure) {
|
||||||
|
t.equal(typeof st.departure, 'string')
|
||||||
|
const dep = +new Date(st.departure)
|
||||||
|
// note that this can be an ICE train
|
||||||
|
t.ok(isRoughlyEqual(14 * hour, +when, dep))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
t.ok(Array.isArray(v.frames))
|
||||||
|
for (let f of v.frames) {
|
||||||
|
// see #28
|
||||||
|
// todo: check if this works by now
|
||||||
|
assertValidStation(t, f.origin, true)
|
||||||
|
assertValidStationProducts(t, f.origin.products)
|
||||||
|
assertValidStation(t, f.destination, true)
|
||||||
|
assertValidStationProducts(t, f.destination.products)
|
||||||
|
t.equal(typeof f.t, 'number')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t.end()
|
||||||
|
}))
|
||||||
|
|
Loading…
Add table
Reference in a new issue