db-stations icon indicating copy to clipboard operation
db-stations copied to clipboard

foreign stations missing

Open juliuste opened this issue 9 years ago • 7 comments
trafficstars

The collection does not include stations in other countries, even though some of them are regularely operated by DB and available in its 'Fernverkehr' API.

juliuste avatar Aug 20 '16 02:08 juliuste

Maybe we could fetch all of them from the DB API. But how do we make sure we cover all?

derhuerst avatar Aug 20 '16 02:08 derhuerst

Possible idea: Call the API with every station ids between 8000000 and 10000000. 😁

derhuerst avatar Aug 20 '16 02:08 derhuerst

Will try to find the missing ones using captaintrain/stations.

derhuerst avatar Aug 22 '16 23:08 derhuerst

The following script will walk through the captaintrain/stations data and filter all stations that DB can provide departures for. They also need to have a db_id.

'use strict'

const floor = require('floordate')
const fs = require('fs')
const hafas = require('db-hafas')
const pipe = require('multipipe')
const csv = require('csv-parse')
const filter = require('stream-filter')

const hour = 60 * 60 * 1000
const day = 24 * hour
const when = new Date(+floor(new Date(), 'day') + day + 10 * hour)

const isDBStation = (station, cb) => {
    hafas.departures(+station.db_id, {when})
    .then(() => cb(null, true), () => cb(null, false))
}

pipe(
    fs.createReadStream('stations.csv'),
    csv({delimiter: ';', columns: true}),
    filter((station) => station.db_id.length > 0, {objectMode: true}),
    filter.async(isDBStation, {objectMode: true})
)

derhuerst avatar Aug 31 '16 02:08 derhuerst

Siehe auch https://iris.noncd.db.de/iris-tts/timetable/station/*.

highsource avatar Jan 10 '17 19:01 highsource

Hey, i´ve a question: I´m looking for all stations of all cities in saxony for the last years (cause i want to look, how the connection of the cities has changed over the time). First: I found the data of DB Station&Service AG (https://data.deutschebahn.com/dataset/data-stationsdaten). Pretty good, but: These data doesnt include the sold - but still active - stations (for example Erzgebirgsbahn).

Do you know, where I can get all these data?

Konkordanz avatar Oct 16 '19 09:10 Konkordanz

I made db-hafas-stations once, but it's a bit outdated, and I have never assessed if it contains all (or reasonably many rather) stations. It should contain all that bahn.de knows about though.

Also, I just wrote hafas-find-stations, but I haven't tried it on a large scale. You can test it if you want.

Other than that, OSM might be a good source, but again there's no guarantee that every station is in there.

derhuerst avatar Oct 17 '19 11:10 derhuerst