2010-10-02 50 views
5

我正在使用Geo :: Coder ::许多Perl模块&得到一些奇怪的结果。当我将Google设置为提供商时,结果将正确显示。但是,将提供者设置为Bing会颠倒纬度&经度值。例如:地理编码....我做错了什么?

use Geo::Coder::Google; 
use Geo::Coder::Bing; 
use Geo::Coder::Many; 
use Geo::Coder::Many::Util qw(country_filter); 

# Create the Geo::Coder::Many object, telling it to use a 'weighted random' 
# scheduling method 
my $options = { 
    scheduler_type => 'WRR', 
}; 
my $geocoder_many = Geo::Coder::Many->new($options); 


# Create and add a geocoder 
my $Locatorize = Geo::Coder::Google->new(apikey => 'yur Key'); 
my $Locatorize_options = { 
    geocoder => $Locatorize, 
    daily_limit => 2500, #google has a 2,500 limit/day 
}; 
$geocoder_many->add_geocoder($Locatorize_options); 


my $result = $geocoder_many->geocode( 
    { 
     location => '1600 Amphitheatre Parkway Mountain View, CA 94043' 
    } 
); 

if (defined $result) { 
    print "Longitude: ",  $result->{longitude},  "\n"; 
    print "Latitude: ",  $result->{latitude},  "\n"; 
} 
else { 
    print "Failed to geocode!\n"; 
} 

这将(正确)返回:

经度:-122.085099 纬度:37.422782

当我改变提供商兵,事情出差错:

my $WhereIzIt = Geo::Coder::Bing->new(key => 'Yur key'); 
my $WhereIzIt_options = { 
    geocoder => $WhereIzIt, 
    daily_limit => 4000, 
}; 
$geocoder_many->add_geocoder($WhereIzIt_options); 

此回报:

经度:37.42317 6 纬度:-122.085962

Bing一贯向后返回结果?我将如何改变这个模块?

+0

我已通过电子邮件通知了该模块的作者,但我该如何自己修复此问题? – kristen 2010-10-02 22:16:59

回答

10

Geo/Coder/Many/Bing.pm,找到行:

longitude => $raw_reply->{point}->{coordinates}->[0], 
latitude => $raw_reply->{point}->{coordinates}->[1], 

和交换0和1:

longitude => $raw_reply->{point}->{coordinates}->[1], 
latitude => $raw_reply->{point}->{coordinates}->[0], 

这是Geo-Coder-Many的错误,而不是地理编码器:: ::兵。确保你将错误和此修复报告给right author

+0

+1:这是非常好的,你发现... – dawg 2010-10-03 00:42:54

+0

这个错误在[Geo-Coder-Many](http://search.cpan.org/dist/Geo-Coder-Many/)0.14中得到修复,它昨天发布。 – cjm 2010-11-09 08:45:37