Geocoding ... did I do something wrong?

I use the Geo :: Coder :: Many perl module and get some weird results. When I install Google as a provider, the results are displayed correctly. However, setting the provider to Bing will change the latitude and longitude values. For instance:

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";
}

This will return (correct):

Longitude: -122.085099 Latitude: 37.422782

When I change the provider to Bing, everything goes wrong:

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

This returns:

Longitude: 37.423176 Latitude: -122.085962

Does Bing consistently return results back? How can I change this in a module?

+5
source share
1 answer

In Geo/Coder/Many/Bing.pmfind lines:

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

and replace 0 and 1:

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

This is a bug in Geo-Coder-Many, not Geo :: Coder :: Bing. Make sure you report a bug, and this fix is ​​for the rights of the author .

+10
source

All Articles