derhuerst / db-stations

A list of Deutsche Bahn stations.
ISC License
29 stars 4 forks source link

foreign stations missing #1

Open juliuste opened 8 years ago

juliuste commented 8 years ago

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.

derhuerst commented 8 years ago

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

derhuerst commented 8 years ago

Possible idea: Call the API with every station ids between 8000000 and 10000000. šŸ˜

derhuerst commented 8 years ago

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

derhuerst commented 8 years ago

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})
)
highsource commented 7 years ago

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

Konkordanz commented 4 years ago

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?

derhuerst commented 4 years ago

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.