加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl – 地理编码……我做错了吗?

发布时间:2020-12-15 21:46:33 所属栏目:大数据 来源:网络整理
导读:我正在使用Geo :: Coder ::许多perl模块得到一些奇怪的结果.当我将Google设置为提供程序时,会正确显示结果.但是,将提供程序设置为Bing将会反转纬度和范围.经度值.例如: use Geo::Coder::Google;use Geo::Coder::Bing;use Geo::Coder::Many;use Geo::Coder::
我正在使用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

当我将提供者更改为Bing时,事情就出错了:

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

返回:

经度:37.423176
纬度:-122.085962

Bing始终如一地向后退回结果?我如何在模块中更改此内容?

解决方法

在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中的一个错误,而不是Geo :: Coder :: Bing.确保您向right author报告了错误和此修复程序.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读