taiyoh's memorandum

@ttaiyoh が、技術ネタで気づいたことを書き溜めておきます。

WebService::GoogleDirectionAPIというモジュールを書いた

 本当はもう誰かがやってる可能性高いけど。
 → Google Directions API - Google Maps API Web サービス - Google Code
 経路探索をするgoogleAPIPerlから操作するためのものです。

#!perl

use strict;
use warnings;

use WebService::GoogleDirectionAPI;
use YAML;

my $gd = WebService::GoogleDirectionAPI->new(sensor => "false");

my $from = '東京都渋谷区恵比寿西1-16-15 EBISU WEST';
my $to   = '神奈川県鎌倉市小町2-14-7 かまくら春秋スクエア';

my $res = $gd->search($from, $to);

print YAML::Dump($res);

 これを実行するとこうなる。

% perl sample.pl
---
routes:
  - bounds:
      northeast:
        lat: 35.65794
        lng: 139.70801
      southwest:
        lat: 35.31853
        lng: 139.48168
    copyrights: Map data ©2011 ZENRIN
    legs:
      - distance:
          text: 61.2 km
          value: 61230
        duration:
          text: 1 hour 19 mins
          value: 4766
        end_address: 'Japan, Kanagawa Prefecture, Kamakura, Komachi, 2丁目14−7'
        end_location:
          lat: 35.32103
          lng: 139.55341
        start_address: 'Japan, Tokyo, Shibuya, Ebisunishi, 1丁目16−15'
        start_location:
          lat: 35.64909
          lng: 139.70732
        steps:

~~~~~~~~~~~~~~~~~~~~(以下略)