はじめに
定期券
交通費精算(定期区間控除)
通勤費管理(定期代支給)
探索
運賃
探索結果
探索条件
地点
路線
路線図

特急列車時刻表を利用して経路探索を行う

特急列車時刻表の結果を利用して、経路探索を行います。

関連URL

手順

1. 運行区間コードを取得する

特急列車時刻表を取得するには、運行区間コードが必要です。 特急列車時刻表に、stationNameパラメータまたはstationCodeパラメータを指定して運行区間コードを取得します。

※リクエスト例では日本語で記述しておりますが、リクエストパラメータに日本語が含まれる場合には、日本語の部分をUTF8でURLエンコード(パーセントエンコード)してください。

GET /v1/xml/train/timetable?stationName=新宿
<ResultSet apiVersion="1.26.0.0" max="15" engineVersion="201603_02a">
:
<Line>
<Name>きぬがわ</Name>
<ServiceSection arrival="新宿" code="運行区間コード" departure="鬼怒川温泉">鬼怒川温泉-新宿</ServiceSection>
<ServiceSection arrival="鬼怒川温泉" code="運行区間コード" departure="新宿">新宿-鬼怒川温泉</ServiceSection>
</Line>
:

2. 特急列車時刻表を取得する

1のレスポンスで運行区間コードResultSet/Line/ServiceSection/codeを取得することができます。 運行区間コードをserviceSectionCodeパラメータに指定して、特急列車時刻表を取得します。

GET /v1/xml/train/timetable?serviceSectionCode=1で取得できる運行区間コードを入れてください
<ResultSet apiVersion="1.26.0.0" max="1" engineVersion="201603_02a">
:
<Line corporationIndex="1" trainID="1064M" code="列車コード">
<Name type_part="特急" line_part="きぬがわ">特急 きぬがわ4号</Name>
<GuideComment/>
<Stop>
<Point getOff="False" getOn="True">
<Station code="21759">
<Name>鬼怒川温泉</Name>
</Station>
<Prefecture code="9">
<Name>栃木県</Name>
</Prefecture>
</Point>
<DepartureState>
<Datetime operation="today">10:38:00+09:00</Datetime>
</DepartureState>
</Stop>
:
<Stop>
<ArrivalState>
<Datetime operation="today">12:48:00+09:00</Datetime>
</ArrivalState>
<Point getOff="True" getOn="False">
<Station code="22741">
<Name>新宿</Name>
</Station>
<Prefecture code="13">
<Name>東京都</Name>
</Prefecture>
</Point>
</Stop>
:

3. 経路探索を行う

2のレスポンスで以下の値を取得することができます。

  • 列車コード ResultSet/Line/code
  • 列車名 ResultSet/Line/Name
  • 列車の停車駅 ResultSet/Line/Stop/Point/Station/Name
  • 列車の発時刻 ResultSet/Line/Stop/DepartureState/Detetime
  • 列車の着時刻 ResultSet/Line/Stop/ArrivalState/Detetime

リクエスト例は、特急 きぬがわ4号を利用して鬼怒川温泉ー新宿で経路探索を行うことにします。

2のレスポンスで列車名が特急 きぬがわ4号となっている同要素内の列車コードをfixedTrainListパラメータに指定します。 また、列車の停車駅が鬼怒川温泉となっている同要素内の発時刻と、列車の停車駅が新宿となっている同要素内の着時刻をfixedTimeListパラメータに指定します。

GET /v1/xml/course/create?viaList=21759:22741&fixedTrainList=2で取得できる列車コードを入れてください&fixedTimeList=1038:1248&fixedDateList=20160324
<ResultSet apiVersion="1.26.0.0" engineVersion="201603_02a">
<Course dataType="onTimetable">
<Route timeOther="0" timeOnBoard="130" exhaustCO2="3084" index="1" exhaustCO2atPassengerCar="23553" distance="1402" timeWalk="0" transferCount="0">
<Point index="1">
<Station code="21759">
<Name>鬼怒川温泉</Name>
<Type>train</Type>
<Yomi>きぬがわおんせん</Yomi>
</Station>
<Prefecture code="9">
<Name>栃木県</Name>
</Prefecture>
<GeoPoint longi="139.43.11.89" lati="36.49.10.0" longi_d="139.719971777777776" gcs="tokyo" lati_d="36.81944444444444"/>
</Point>
<Line stopStationCount="6" chargeIndex="1" timeOnBoard="130" track="railway" exhaustCO2="3084" fareIndex="1" index="1" exhaustCO2atPassengerCar="23553" distance="1402">
<Name>JR特急きぬがわ</Name>
<Type detail="limitedExpress">train</Type>
<ArrivalState no="5">
<Type>normal</Type>
<Datetime operation="today">2016-03-24T12:48:00+09:00</Datetime>
</ArrivalState>
<Destination>新宿</Destination>
<Number>4</Number>
<TimeReliability>onTimetable</TimeReliability>
<DepartureState>
<Type>normal</Type>
<Datetime operation="today">2016-03-24T10:38:00+09:00</Datetime>
</DepartureState>
<Color>255000000</Color>
</Line>
<Point index="2">
<Station code="22741">
<Name>新宿</Name>
<Type>train</Type>
<Yomi>しんじゅく</Yomi>
</Station>
<Prefecture code="13">
<Name>東京都</Name>
</Prefecture>
<GeoPoint longi="139.42.11.0" lati="35.41.15.0" longi_d="139.703055555555552" gcs="tokyo" lati_d="35.6875"/>
</Point>
</Route>
<Price kind="FareSummary">
<Oneway>1940</Oneway>
<Round>3880</Round>
</Price>
<Price fareRevisionStatus="none" toLineIndex="1" fromLineIndex="1" kind="Fare" index="1" selected="true">
<Type>Fare</Type>
<Oneway>1940</Oneway>
<Round>3880</Round>
</Price>
<Price kind="ChargeSummary">
<Oneway>2060</Oneway>
<Round>4120</Round>
</Price>
<Price fareRevisionStatus="none" toLineIndex="1" fromLineIndex="1" kind="Charge" index="1" selected="true">
<Name>指定席</Name>
<Type>Reserved</Type>
<Oneway>2060</Oneway>
<Round>4120</Round>
<Rate area="Main">Regular</Rate>
</Price>
<SerializeData>SHlUczAxLjAwLjA0rAQBAAAANJ8zAQIAAQAAAAEAAQAAAAgAAQAAAgAAAwAAAAAAAAABAP9UAADVWAAAAAAAAAoAgQAAALgPAAEACESfMwF|AgAAAAMAAAIAAQABAAIAAQABAAAAAAABAAEAAQAAAA**--T3221233232319:F3321122120:A23121141:--afb62db7511185df42b254a6a888264b26821299--0--0--0</SerializeData>
</Course>
</ResultSet>
ページ上部へ