Show
Ignore:
Timestamp:
01/07/08 00:23:17 (5 years ago)
Author:
tokuhirom
Message:

Geo-Coordinates-Converter-iArea: merge Format-iArea branch.

Location:
lang/perl/Geo-Coordinates-Converter-iArea/trunk
Files:
7 added
4 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Geo-Coordinates-Converter-iArea/trunk

    • Property svn:ignore set to
      META.yml
      Makefile
      blib
      inc
      pm_to_blib
  • lang/perl/Geo-Coordinates-Converter-iArea/trunk/MANIFEST

    r4097 r4130  
    1818inc/Test/Builder/Module.pm 
    1919inc/Test/More.pm 
     20lib/Geo/Coordinates/Converter/Format/IArea.pm 
    2021lib/Geo/Coordinates/Converter/iArea.pm 
    2122Makefile.PL 
     
    2627t/00_compile.t 
    2728t/01_simple.t 
     29t/02_format.t 
  • lang/perl/Geo-Coordinates-Converter-iArea/trunk/lib/Geo/Coordinates/Converter/iArea.pm

    r4097 r4130  
    33use warnings; 
    44our $VERSION = '0.02'; 
    5 use File::ShareDir 'dist_file'; 
     5use Geo::Coordinates::Converter; 
     6use Geo::Coordinates::Converter::iArea::DataLoader; 
     7Geo::Coordinates::Converter->add_default_formats('iArea'); 
    68 
    79sub get_center { 
    810    my ($class, $areacode) = @_; 
    911 
    10     my $file = dist_file('Geo-Coordinates-Converter-iArea', 'iarea-center.csv'); 
    11     open my $fh, '<', $file or die $!; 
    12  
    13     my $geo; 
    14     while (my $line = <$fh>) { 
    15         if (index($line, $areacode) >= 0) { 
    16             my @dat = split m{,}, $line; 
    17  
    18             $geo = Geo::Coordinates::Converter->new( 
    19                 lat    => $dat[1], 
    20                 lng    => $dat[2], 
    21                 datum  => 'tokyo', 
    22                 format => 'degree' 
    23             ); 
    24  
    25             last; 
     12    Geo::Coordinates::Converter::iArea::DataLoader->first( 
     13        sub { 
     14            my $dat = shift; 
     15            if ($dat->{areacode} eq $areacode) { 
     16                return Geo::Coordinates::Converter->new( 
     17                    lat      => $dat->{center_lat}, 
     18                    lng      => $dat->{center_lng}, 
     19                    datum    => 'tokyo', 
     20                    format   => 'degree', 
     21                    areacode => $areacode 
     22                ); 
     23            } 
    2624        } 
    27     } 
    28  
    29     close $fh; 
    30     return $geo; 
     25    ) || undef; 
    3126} 
    3227 
     
    3429__END__ 
    3530 
    36 =for stopwords aaaatttt dotottto gmail DoCoMo MOVA csv FOMA 
     31=for stopwords aaaatttt dotottto gmail DoCoMo MOVA csv FOMA API 
    3732 
    3833=head1 NAME 
  • lang/perl/Geo-Coordinates-Converter-iArea/trunk/t/01_simple.t

    r4084 r4130  
    11use strict; 
    22use warnings; 
    3 use Test::More tests => 7; 
     3use Test::More tests => 9; 
    44use Geo::Coordinates::Converter; 
    55use Geo::Coordinates::Converter::iArea; 
     
    1616    is $point->datum, 'wgs84'; 
    1717    is $point->format, 'degree'; 
     18    is $point->areacode, '05905'; 
     19    is $geo->areacode, '05905'; 
    1820}->(); 
    1921