KUMAGAI Kentaro > Geo-Coder-YahooJapan-0.04 > Geo::Coder::YahooJapan

Download:
Geo-Coder-YahooJapan-0.04.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.04   Source  

NAME ^

Geo::Coder::YahooJapan - a simple wrapper for Yahoo Japan Geocoder API

SYNOPSIS ^

  use Geo::Coder::YahooJapan;
  $r = lookup( $address_in_japanese_characters );
  my ($lat, $lng) = ( $r->{latitude}, $r->{longitude} ); # coordinate in WGS87.

  # if you want to get result in TOKYO datum, specify it in option.
  $r = lookup( $address_in_japanese_characters, { datum => 'tokyo' } );

  # if address is ambiguous and the server returns multiple items
  $r = lookup( $address_in_japanese_characters );
  # $r->{latitude} and $r->{longitude} contains coordinate of first item.
  ($lat, $lng) = ( $r->{latitude}, $r->{longitude} );

  # $r->{hits} has the number of candidates.
  if ( $r->{hits} > 1 ) {
        # and $r->{items} contains each candidates infomation.
        foreach ( $r->{items} ) {
                print join "\t", ( $_->{title}, $_->{latitude}, $_->{longitude} );
                print "\n";
        }
  }

DESCRIPTION ^

Geo::Coder::YahooJapan is a wrapper for Yahoo Japan Geocoder API that is used by the official Yahoo Japan's local search widget http://widgets.yahoo.co.jp/gallery/detail.html?wid=10 . This module converts the coordinate into WGS84 from TOKYO datum which is returned by API server.

lookup(address, opts)

Lookup is an only method in this package that returns coordinate information in an hash reference. When address is not enough precise, the server returns multiple candidates. These candidatse are found in $response->{items}. You can determine geocoding result has multiple candidates or not by seeing $response->{hits}.

You can specify the address in UTF8, SHIFT_JIS, EUC_JP. But the API server does not understand ISO-2022-JP, so you need convert into other character set if your address is written in ISO-2022-JP. In $opts->{num}, you can specify the number of candidates you want to receive when multiple items are found. Default value is 10. If you want to get results in other datum, not in WGS84, set the datum name in $opts->{datum}. the value is passed to Location::GeoTool and it converts them properly.

DEPENDENCIES ^

HTTP::Request LWP::UserAgent Location::GeoTool

AUTHOR ^

KUMAGAI Kentaro <ku0522a+cpan@gmail.com>

syntax highlighting: