vbb hafas
1.0.0
ベルリンおよびブランデンブルク公共交通サービス (VBB) のクライアント。これは、冗長な API 上で一貫性のある簡単なインターフェイスとして機能します。
このプロジェクトは、実際にはhafas-client@6
の薄いラッパーです。そのドキュメントには API 全般について文書化されています。
注: 自分で VBB API をクエリしたくない場合もあります。 vbb-client
、私のラッパー API であるvbb-rest
の API 互換クライアントです。ブラウザでも動作します。
npm install vbb-hafas
hafas-client
とその VBB 固有のカスタマイズについてはドキュメントを確認してください。
const createHafas = require ( 'vbb-hafas' )
const hafas = createHafas ( 'my-awesome-program' )
例として、ベルリン中央駅からベルリン シャルロッテンブルクまでの移動を検索します。ステーション ID を取得するには、 vbb-stations
使用します。
hafas . journeys ( '900000003201' , '900000024101' , { results : 1 } )
. then ( ( journeys ) => console . log ( journeys [ 0 ] ) )
. catch ( console . error )
出力は、 Friendly Public Transport Format 1.2.1
形式のjourney
オブジェクトの配列になります。
[ {
legs : [ {
tripId : '1|50420|0|86|25122017' ,
direction : 'Brandenburg, Hbf' ,
line : {
type : 'line' ,
id : '10' ,
name : 'RE1' ,
public : true ,
mode : 'train' ,
product : 'regional' ,
symbol : 'RE' ,
nr : 1 ,
metro : false ,
express : true ,
night : false ,
class : 64 ,
productCode : 6 ,
operator : {
type : 'operator' ,
id : 'db-regio-ag' ,
name : 'DB Regio AG'
}
} ,
origin : {
type : 'station' ,
id : '900000003201' ,
name : 'S+U Berlin Hauptbahnhof' ,
location : {
type : 'location' ,
latitude : 52.52585 ,
longitude : 13.368928
} ,
products : {
suburban : true ,
subway : true ,
tram : true ,
bus : true ,
ferry : false ,
express : true ,
regional : true
}
} ,
departure : '2017-12-26T00:41:00.000+01:00' ,
plannedDeparture : '2017-12-26T00:41:00.000+01:00' ,
departureDelay : 0 ,
departurePlatform : '14' ,
plannedDeparturePlatform : '13' ,
destination : {
type : 'station' ,
id : '900000024101' ,
name : 'S Charlottenburg' ,
location : {
type : 'location' ,
latitude : 52.504806 ,
longitude : 13.303846
} ,
products : {
suburban : true ,
subway : false ,
tram : false ,
bus : true ,
ferry : false ,
express : false ,
regional : true
}
} ,
arrival : '2017-12-26T00:50:00.000+01:00' ,
plannedArrival : '2017-12-26T00:50:00.000+01:00' ,
arrivalDelay : null ,
arrivalPlatform : '4' ,
plannedArrivalPlatform : '4'
} ] ,
// all these are from the first leg
origin : {
type : 'station' ,
id : '900000003201' ,
name : 'S+U Berlin Hauptbahnhof'
// …
} ,
departure : '2017-12-26T00:41:00.000+01:00' ,
plannedDeparture : '2017-12-26T00:41:00.000+01:00' ,
departureDelay : 0 ,
departurePlatform : '14' ,
plannedDeparturePlatform : '13' ,
// all these are from the last leg
destination : {
type : 'station' ,
id : '900000024101' ,
name : 'S Charlottenburg'
// …
} ,
arrival : '2017-12-26T00:50:00.000+01:00' ,
plannedArrival : '2017-12-26T00:50:00.000+01:00' ,
arrivalDelay : null ,
arrivalPlatform : '4' ,
plannedArrivalPlatform : '4'
// …
} ]
transferInfo: true
オプションとして渡すと、 vbb-hafas
vbb-change-positions
から転送情報を追加しようとします。
既知の乗り換えを識別した場合、前の区間にはbestArrivalPosition
があり、次の区間にはdeparturePosition
があり、両方のプラットフォーム間の最適な乗り換えを示します。詳細については、 vbb-change-positions
のマークアップを確認してください。
hafas-client
の関連プロジェクトを確認してください。
質問がある場合、バグを見つけた場合、または機能を提案したい場合は、問題ページをご覧ください。