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

探索結果からシェイプ情報を取得する

経路探索結果を利用して、経路のシェイプ情報(地図に経路をポリライン描画するための情報)を取得します。

※ポリライン描画のイメージ図(野方二丁目/関東バス--関東バス・赤31--高円寺駅北口/関東バス--徒歩--高円寺--JR中央・総武線各駅停車--中野(東京都)--東京メトロ東西線--高田馬場) Course shape sample

関連URL

手順

1. 経路を探索する

ダイヤによる探索を利用して、シェイプ情報を取得したい経路の情報を取得します。

例は経路探索 /search/course/extreme ですが、ダイヤによる探索を行うことができるAPI(経路簡易探索)でも可能です。

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

GET /v1/xml/search/course/extreme?key=アクセスキーを入力してください&viaList=P-自宅-野方二丁目/関東バス-5----0----:高円寺:高田馬場&date=20231101&time=1050&answerCount=1
<?xml version="1.0" encoding="UTF-8"?>
<ResultSet apiVersion="1.27.0.0" engineVersion="202311_02a">
   <Course searchType="departure" dataType="onTimetable">
      <Route index="1" ...>
         <Point index="1">
            <Name>自宅</Name>
         </Point>
         <Line index="1" ...>
            <Color>230230230</Color>
              :
         </Line>
         <Point index="2">
            <Station code="45885">
               <Name>野方二丁目/関東バス</Name>
                 :
            </Station>
              :
         </Point>
         <Line index="2" ...>
            <Name>関東バス・赤31・高円寺駅北口行</Name>
            <Type detail="local">bus</Type>
            <Color>255028026</Color>
              :
         </Line>
         <Point index="3">
            <Station code="45640">
               <Name>高円寺駅北口/関東バス</Name>
                 :
            </Station>
              :
         </Point>
         <Line index="3" ...>
            <Name>徒歩</Name>
            <Type>walk</Type>
            <Color>230230230</Color>
              :
         </Line>
         <Point index="4">
            <Station code="22671">
               <Name>高円寺</Name>
                 :
            </Station>
              :
         </Point>
         <Line index="4" ...>
            <Name>JR総武線・千葉行</Name>
            <Type>train</Type>
            <Color>255222000</Color>
              :
         </Line>
         <Point index="5">
            <Station code="22849">
               <Name>中野(東京都)</Name>
                 :
            </Station>
              :
         </Point>
         <Line index="5" ...>
            <Name>東京メトロ東西線・西船橋行</Name>
            <Type>train</Type>
            <Color>000175239</Color>
              :
         </Line>
         <Point index="6">
            <Station code="22790">
               <Name>高田馬場</Name>
                 :
            </Station>
              :
         </Point>
      </Route>
        :
      <SerializeData>経路シリアライズデータ</SerializeData>
        :
   </Course>
</ResultSet>

2. 経路のシェイプ情報を取得する

1で取得できる経路シリアライズデータを利用して、シェイプ情報を取得します。

ここではすべての交通種別の区間のシェイプ情報を取得します。typeパラメータにallを指定します。
この場合、探索経路のすべての交通種別の区間の運行路線パターンが返ります。

なお、allを指定したとしても、座標情報、住所情報、または地点データからまでの区間の運行路線パターンは返りませんのでご注意ください。(この例では、自宅〜野方二丁目/関東バスまでの区間)

もし、鉄道の区間のシェイプ情報のみ取得したい場合は、typeパラメータを未指定、もしくはtrainを指定してください。

GET /v1/xml/course/shape?key=アクセスキーを入力してください&serializeData=1で取得できる経路シリアライズデータを入力してください&checkEngineVersion=false&type=all
<?xml version="1.0" encoding="UTF-8"?>
<ResultSet apiVersion="1.27.0.0" engineVersion="202311_02a">
   <Course dataType="onTimetable">
      <OperationLinePattern routeLineIndex="2">
         <Point index="1">
            <Station code="45885">
               <Name>野方二丁目/関東バス</Name>
                 :
            </Station>
              :
         </Point>
         <Line direction="Up" index="1">
            <Name>関東バス・赤31</Name>
            <Shape index="1">
               <GeoPoint longi_d="139.65385" lati_d="35.712585" gcs="wgs84" />
            </Shape>
            <Shape index="2">
               <GeoPoint longi_d="139.653937" lati_d="35.705555" gcs="wgs84" />
            </Shape>
            <Shape index="3">
               <GeoPoint longi_d="139.650049" lati_d="35.705778" gcs="wgs84" />
            </Shape>
            <Type detail="local">bus</Type>
            <Color>255028026</Color>
         </Line>
         <Point index="2">
            <Station code="45640">
               <Name>高円寺駅北口/関東バス</Name>
                 :
            </Station>
              :
         </Point>
      </OperationLinePattern>
      <OperationLinePattern routeLineIndex="3">
         <Point index="1">
            <Station code="45640">
               <Name>高円寺駅北口/関東バス</Name>
                 :
            </Station>
              :
         </Point>
         <Line direction="Up" index="1">
            <Name>徒歩</Name>
            <Shape index="1">
               <GeoPoint longi_d="139.650049" lati_d="35.705778" gcs="wgs84" />
            </Shape>
            <Shape index="2">
               <GeoPoint longi_d="139.649826" lati_d="35.705333" gcs="wgs84" />
            </Shape>
            <Type>walk</Type>
            <Color>230230230</Color>
         </Line>
         <Point index="2">
            <Station code="22671">
               <Name>高円寺</Name>
                 :
            </Station>
              :
         </Point>
      </OperationLinePattern>
      <OperationLinePattern routeLineIndex="4">
         <Point index="1">
            <Station code="22671">
               <Name>高円寺</Name>
                 :
            </Station>
              :
         </Point>
         <Line direction="Up" track="railway" toStationPos="420" index="1" fromStationPos="430" code="110">
            <Name>JR中央・総武線各駅停車</Name>
            <Type>train</Type>
            <Color>255222000</Color>
            <Shape index="1">
               <GeoPoint longi_d="139.6497" lati_d="35.70532406" gcs="wgs84" />
            </Shape>
            <Shape index="2">
               <GeoPoint longi_d="139.64992" lati_d="35.70533" gcs="wgs84" />
            </Shape>
              :
            <Shape index="11">
               <GeoPoint longi_d="139.66482" lati_d="35.70551" gcs="wgs84" />
            </Shape>
            <Shape index="12">
               <GeoPoint longi_d="139.666085" lati_d="35.705555" gcs="wgs84" />
            </Shape>
         </Line>
         <Point index="2">
            <Station code="22849">
               <Name>中野(東京都)</Name>
                 :
            </Station>
              :
         </Point>
      </OperationLinePattern>
      <OperationLinePattern routeLineIndex="5">
         <Point index="1">
            <Station code="22849">
               <Name>中野(東京都)</Name>
                 :
            </Station>
              :
         </Point>
         <Line direction="Down" track="railway" toStationPos="120" index="1" fromStationPos="100" code="331">
            <Name>東京メトロ東西線</Name>
            <Type>train</Type>
            <Color>000175239</Color>
            <Shape index="1">
               <GeoPoint longi_d="139.665605" lati_d="35.70574" gcs="wgs84" />
            </Shape>
            <Shape index="2">
               <GeoPoint longi_d="139.66688" lati_d="35.70579" gcs="wgs84" />
            </Shape>
              :
            <Shape index="53">
               <GeoPoint longi_d="139.70406" lati_d="35.71376" gcs="wgs84" />
            </Shape>
            <Shape index="54">
               <GeoPoint longi_d="139.705045" lati_d="35.71328" gcs="wgs84" />
            </Shape>
         </Line>
         <Point index="2">
            <Station code="22790">
               <Name>高田馬場</Name>
                 :
            </Station>
              :
         </Point>
      </OperationLinePattern>
   </Course>
</ResultSet>

経路の区間毎に運行路線パターン ResultSet/Course/OperationLinePattern が返ります。

地図サービスなどにポリラインを描画する際は、 ResultSet/Course/OperationLinePattern/Line/Shape/GeoPoint 要素配下の座標情報をindex順に連結してご利用ください。

なお、地図サービス上へのポリラインの描画方法につきましては、各サービスの仕様をご確認ください。

ページ上部へ