remove HVV profile 💥

closes #262
closes #261
This commit is contained in:
Jannis R 2022-11-18 19:04:50 +01:00
parent 1e8b5982a2
commit 0349ebac20
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
10 changed files with 1 additions and 459 deletions

View file

@ -91,7 +91,7 @@ You may want to start with the [profile boilerplate](profile-boilerplate.js).
- **Identify the `locale`.** Basically guess work; Use the date & time formats as an indicator.
- **Identify the `timezone`.** This may be tricky, a for example [Deutsche Bahn](https://en.wikipedia.org/wiki/Deutsche_Bahn) returns departures for Moscow as `+01:00` instead of `+03:00`.
- **Copy the authentication** and other meta fields, namely `ver`, `ext`, `client` and `lang`.
- You can find these fields in the root of each request JSON. Check [a HVV request](https://gist.github.com/derhuerst/5a9d29a556b54182f9d30202f7244bfd#file-journeys-http-L11-L54) and [the corresponding HVV profile](https://github.com/public-transport/hafas-client/blob/99142acf8b156599daa69f2e1470901088827982/p/hvv/index.js#L5-L23) for an example.
- You can find these fields in the root of each request JSON. Check [a VBB request](https://gist.github.com/derhuerst/ea5d6482b61aeb7384a2c788f43dc11d#file-0-serverinfo-http-L11-L33) and [the corresponding VBB profile](https://github.com/public-transport/hafas-client/blob/2baf2f6f0444ffc67317f8bafe0fe05f687e5fae/p/vbb/base.json#L2-L11) for an example.
- Add a function `transformReqBody(ctx, body)` to your profile, which adds the fields to `body`. todo: adapt this
- Some profiles have a `checksum` parameter (like [here](https://gist.github.com/derhuerst/2a735268bd82a0a6779633f15dceba33#file-journey-details-1-http-L1)) or two `mic` & `mac` parameters (like [here](https://gist.github.com/derhuerst/5fa86ed5aec63645e5ae37e23e555886#file-1-http-L1)). If you see one of them in your requests, jump to the [*Authentication* section of the `mgate.exe` docs](hafas-mgate-api.md#authentication). Unfortunately, this is necessary to get the profile working.

View file

@ -1,17 +0,0 @@
{
"auth": {
"type": "AID",
"aid": "andcXUmC9Mq6hjrwDIGd2l3oiaMrTUzyH"
},
"salt": "pqjM3iKEGOAhYbX76k9R5zutv",
"client": {
"type": "AND",
"id": "HVV",
"v": "4020100",
"name": "HVVPROD_ADHOC"
},
"endpoint": "https://hvv-app.hafas.de/bin/mgate.exe",
"ext": "HVV.1",
"ver": "1.18",
"defaultLanguage": "de"
}

View file

@ -1,46 +0,0 @@
import {inspect} from 'util'
import {createClient} from '../../index.js'
import {profile} from './index.js'
const client = createClient(profile, 'hafas-client-example')
// client.journeys('116', '5900', {results: 1, polylines: true})
// client.departures('116', {duration: 1})
// client.arrivals('116', {duration: 10, linesOfStops: true})
client.locations('dammtor', {results: 2})
// client.stop('116', {linesOfStops: true}) // Dammtor
// client.nearby({
// type: 'location',
// latitude: 53.554422,
// longitude: 9.977934
// }, {distance: 60})
// client.radar({
// north: 53.55,
// west: 9.95,
// south: 52.51,
// east: 10
// }, {results: 10})
// client.reachableFrom({
// type: 'location',
// address: 'Hamburg, Holstenwall 9',
// latitude: 53.553766,
// longitude: 9.977514
// }, {
// when: new Date('2019-05-16T10:00:00+0200'),
// maxDuration: 8
// })
// .then(({journeys}) => {
// const [journey] = journeys
// const leg = journey.legs[0]
// return client.trip(leg.tripId, {polyline: true})
// })
// .then(({journeys}) => {
// const [journey] = journeys
// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true})
// })
.then((data) => {
console.log(inspect(data, {depth: null, colors: true}))
})
.catch(console.error)

View file

@ -1,31 +0,0 @@
// todo: use import assertions once they're supported by Node.js & ESLint
// https://github.com/tc39/proposal-import-assertions
import {createRequire} from 'module'
const require = createRequire(import.meta.url)
const baseProfile = require('./base.json')
import {products} from './products.js'
const profile = {
...baseProfile,
locale: 'de-DE',
timezone: 'Europe/Berlin',
// baseProfile.salt is interpreted as hex by hafas-client
salt: Buffer.from('pqjM3iKEGOAhYbX76k9R5zutv', 'utf8'),
addMicMac: true,
products,
departuresGetPasslist: true,
departuresStbFltrEquiv: true,
trip: true,
radar: true,
refreshJourney: true,
reachableFrom: true,
remarksGetPolyline: false,
lines: false, // fails with `FAIL` "HCI Service: request failed"
}
export {
profile,
}

View file

@ -1,94 +0,0 @@
const products = [ // todo: what is `512`?
{
id: 'subway',
mode: 'train',
bitmasks: [1],
name: 'U-Bahn',
short: 'U',
default: true
},
{
id: 'suburban',
mode: 'train',
bitmasks: [2],
name: 'S-Bahn',
short: 'S',
default: true
},
{
id: 'akn',
mode: 'train',
bitmasks: [4],
name: 'AKN',
short: 'A',
default: true
},
{
id: 'regional-express-train',
mode: 'train',
bitmasks: [8],
name: 'RegionalExpress',
short: 'RE',
default: true
},
{
id: 'regional-train',
mode: 'train',
bitmasks: [16],
name: 'Regionalbahn',
short: 'RB',
default: true
},
{
id: 'ferry',
mode: 'watercraft',
bitmasks: [32],
name: 'Fähre',
short: 'F',
default: true
},
{
id: 'bus',
mode: 'bus',
bitmasks: [128],
name: 'Bus',
short: 'Bus',
default: true
},
{
id: 'express-bus',
mode: 'bus',
bitmasks: [256],
name: 'Schnellbus',
short: 'Schnellbus',
default: true
},
{
id: 'anruf-sammel-taxi',
mode: null, // todo
bitmasks: [1024],
name: 'Anruf-Sammel-Taxi',
short: 'AST',
default: true
},
{
id: 'long-distance-train',
mode: 'train',
bitmasks: [4096, 64],
name: 'Fernzug',
short: 'ICE/IC/EC/EN',
default: false
},
{
id: 'long-distance-bus',
mode: 'bus',
bitmasks: [2048],
name: 'Fernbus',
short: 'Fernbus',
default: false
}
]
export {
products,
}

View file

@ -1,18 +0,0 @@
# HVV profile for `hafas-client`
[*Hamburger Verkehrsverbund (HVV)*](https://en.wikipedia.org/wiki/Hamburger_Verkehrsverbund) is the major local transport provider in [Hamburg](https://en.wikipedia.org/wiki/Hamburg). This profile adds *HVV*-specific customizations to `hafas-client`.
## Usage
```js
import {createClient} from 'hafas-client'
import {hvvProfile} from 'hafas-client/p/hvv/index.js'
// create a client with HVV profile
const client = createClient(hvvProfile, 'my-awesome-program')
```
## Customisations
- parses *HVV*-specific products (such as *AKN*)

View file

@ -25,7 +25,6 @@ HAFAS endpoint | wrapper library | docs | example code | profile name
[*S-Bahn München*](https://en.wikipedia.org/wiki/Munich_S-Bahn) | - | [docs](sbahn-muenchen/readme.md) | [example](sbahn-muenchen/example.js) | [`sbahn-muenchen`](sbahn-muenchen)
*Saarfahrplan*/VGS ([Saarland](https://en.wikipedia.org/wiki/Saarland)) | - | [docs](saarfahrplan/readme.md) | [example](saarfahrplan/example.js) | [`saarfahrplan`](saarfahrplan)
[Société Nationale des Chemins de Fer Luxembourgeois (CFL)](https://en.wikipedia.org/wiki/Société_Nationale_des_Chemins_de_Fer_Luxembourgeois) | - | [docs](cfl/readme.md) | [example](cfl/example.js) | [`cfl`](cfl)
[Hamburg public transport (HVV)](https://en.wikipedia.org/wiki/Hamburger_Verkehrsverbund) | - | [docs](hvv/readme.md) | [example](hvv/example.js) | [`hvv`](hvv)
[*Nordhessischer Verkehrsverbund (NVV)*](https://en.wikipedia.org/wiki/Nordhessischer_Verkehrsverbund) ([Hesse](https://en.wikipedia.org/wiki/Hesse)) | - | [docs](nvv/readme.md) | [example](nvv/example.js) | [`nvv`](nvv)
[*mobil.nrw*](https://www.mobil.nrw) | - | [docs](mobil-nrw/readme.md) | [example](mobil-nrw/example.js) | [`mobil-nrw`](mobil-nrw)
*DB Busradar NRW* ([DB Regio Bus](https://en.wikipedia.org/wiki/DB_Regio#Bus_division_(DB_Regio_Bus))) | - | [docs](db-busradar-nrw/readme.md) | [example](db-busradar-nrw/example.js) | [`db-busradar-nrw`](db-busradar-nrw)

View file

@ -1,249 +0,0 @@
import tap from 'tap'
import isRoughlyEqual from 'is-roughly-equal'
import {createWhen} from './lib/util.js'
import {createClient} from '../../index.js'
import {profile as hvvProfile} from '../../p/hvv/index.js'
import {createValidateFptfWith as createValidate} from './lib/validate-fptf-with.js'
import {testJourneysStationToStation} from './lib/journeys-station-to-station.js'
import {journeysFailsWithNoProduct} from './lib/journeys-fails-with-no-product.js'
import {testJourneysStationToAddress} from './lib/journeys-station-to-address.js'
import {testJourneysStationToPoi} from './lib/journeys-station-to-poi.js'
import {testEarlierLaterJourneys} from './lib/earlier-later-journeys.js'
import {testDepartures} from './lib/departures.js'
import {testDeparturesInDirection} from './lib/departures-in-direction.js'
import {testArrivals} from './lib/arrivals.js'
const T_MOCK = 1641897000 * 1000 // 2022-01-11T11:30:00+01
const when = createWhen(hvvProfile.timezone, hvvProfile.locale, T_MOCK)
const cfg = {
when,
// stationCoordsOptional: false,
products: hvvProfile.products,
// minLatitude: 50.7,
// maxLatitude: 53.2,
// minLongitude: 10.25,
// maxLongitude: 13.4
}
const validate = createValidate(cfg, {})
const client = createClient(hvvProfile, 'public-transport/hafas-client:test')
const tiefstack = '4117'
const barmbek = '4933'
const altona = '20626'
// const hasselbachplatzSternstrasse = '6545'
// const stendal = '8010334'
// const dessau = '8010077'
tap.skip('journeys  Hamburg Tiefstack to Hamburg Barmbek', async (t) => {
const res = await client.journeys(tiefstack, barmbek, {
results: 4,
departure: when,
stopovers: true
})
await testJourneysStationToStation({
test: t,
res,
validate,
fromId: tiefstack,
toId: barmbek
})
t.end()
})
// todo: journeys, only one product
tap.skip('journeys fails with no product', async (t) => {
await journeysFailsWithNoProduct({
test: t,
fetchJourneys: client.journeys,
fromId: tiefstack,
toId: barmbek,
when,
products: hvvProfile.products,
})
t.end()
})
tap.skip('Hamburg Tiefstack to Gilbertstr. 30, Hamburg', async (t) => {
const gilbertstr30 = {
type: 'location',
id: '970026640',
address: 'Hamburg, Gilbertstraße 30',
latitude: 53.554791,
longitude: 9.95781
}
const res = await client.journeys(tiefstack, gilbertstr30, {
results: 3,
departure: when
})
await testJourneysStationToAddress({
test: t,
res,
validate,
fromId: tiefstack,
to: gilbertstr30
})
t.end()
})
tap.skip('Hamburg Tiefstack to Hamburger Meile', async (t) => {
const meile = {
type: 'location',
id: '980001841',
poi: true,
name: 'Hamburger Meile',
latitude: 53.572455,
longitude: 10.030541
}
const res = await client.journeys(tiefstack, meile, {
results: 3,
departure: when
})
await testJourneysStationToPoi({
test: t,
res,
validate,
fromId: tiefstack,
to: meile
})
t.end()
})
// todo: via works with detour
// todo: via works without detour
tap.skip('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({
test: t,
fetchJourneys: client.journeys,
validate,
fromId: tiefstack,
toId: barmbek,
when
})
t.end()
})
tap.skip('trip details', async (t) => {
const res = await client.journeys(tiefstack, barmbek, {
results: 1, departure: when
})
const p = res.journeys[0].legs.find(l => !l.walking)
t.ok(p.tripId, 'precondition failed')
t.ok(p.line.name, 'precondition failed')
const tripRes = await client.trip(p.tripId, {when})
validate(t, tripRes, 'tripResult', 'res')
t.end()
})
tap.skip('departures at Hamburg Barmbek', async (t) => {
const res = await client.departures(barmbek, {
duration: 5, when,
})
await testDepartures({
test: t,
res,
validate,
id: barmbek
})
t.end()
})
tap.skip('departures with station object', async (t) => {
const res = await client.departures({
type: 'station',
id: tiefstack,
name: 'Hamburg Tiefstack',
location: {
type: 'location',
latitude: 1.23,
longitude: 2.34
}
}, {when})
validate(t, res, 'departuresResponse', 'res')
t.end()
})
tap.skip('departures at Barmbek in direction of Altona', async (t) => {
await testDeparturesInDirection({
test: t,
fetchDepartures: client.departures,
fetchTrip: client.trip,
id: barmbek,
directionIds: [altona],
when,
validate
})
t.end()
})
tap.skip('arrivals at Hamburg Barmbek', async (t) => {
const res = await client.arrivals(barmbek, {
duration: 5, when
})
await testArrivals({
test: t,
res,
validate,
id: barmbek
})
t.end()
})
// todo: nearby
tap.skip('locations named Elbphilharmonie', async (t) => {
const elbphilharmonie = '6242'
const locations = await client.locations('Elbphilharmonie', {
results: 20
})
validate(t, locations, 'locations', 'locations')
t.ok(locations.length <= 20)
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
t.ok(locations.find(s => s.poi)) // POIs
t.ok(locations.some((l) => {
return l.station && l.station.id === elbphilharmonie || l.id === elbphilharmonie
}))
t.end()
})
tap.skip('station Hamburg Barmbek', async (t) => {
const s = await client.stop(barmbek)
validate(t, s, ['stop', 'station'], 'station')
t.equal(s.id, barmbek)
t.end()
})
tap.skip('radar', async (t) => {
const res = await client.radar({
north: 53.569,
west: 10.022,
south: 53.55,
east: 10.0436
}, {
duration: 5 * 60, when, results: 10
})
validate(t, res, 'radarResult', 'res')
t.end()
})

File diff suppressed because one or more lines are too long

View file

@ -35,7 +35,6 @@ node -p "$query" "$src/lu/cfl-hafas-mgate.json" >../p/cfl/base.json
node -p "$query" "$src/us/cmta-hafas-mgate.json" >../p/cmta/base.json
node -p "$query" "$src/de/db-hafas-mgate.json" >../p/db/base.json
node -p "$query" "$src/de/db-busradar-nrw-hafas-mgate.json" >../p/db-busradar-nrw/base.json
node -p "$query" "$src/de/hvv-hafas-mgate.json" >../p/hvv/base.json
node -p "$query" "$src/de/nasa-hafas-mgate.json" >../p/insa/base.json
node -p "$query" "$src/de/invg-hafas-mgate.json" >../p/invg/base.json
node -p "$query" "$src/ie/iarnrod-eireann-hafas-mgate.json" >../p/irish-rail/base.json