diff -Nru libgeo-coder-googlev3-perl-0.15/Changes libgeo-coder-googlev3-perl-0.16/Changes --- libgeo-coder-googlev3-perl-0.15/Changes 2017-01-20 21:30:09.000000000 +0000 +++ libgeo-coder-googlev3-perl-0.16/Changes 2017-07-14 19:23:09.000000000 +0000 @@ -1,5 +1,12 @@ Revision history for Perl extension Geo::Coder::Googlev3. +0.16 2017-07-14 + - new parameter key + - new parameter use_https + - no default for sensor is set anymore + - failing bounds test is now marked as TODO (RT #122485) + - improved test diagnostics + 0.15 - fixed test for changed results (Brandenburger Tor vs Pariser Platz) diff -Nru libgeo-coder-googlev3-perl-0.15/debian/changelog libgeo-coder-googlev3-perl-0.16/debian/changelog --- libgeo-coder-googlev3-perl-0.15/debian/changelog 2017-01-21 13:04:21.000000000 +0000 +++ libgeo-coder-googlev3-perl-0.16/debian/changelog 2017-07-16 08:18:08.000000000 +0000 @@ -1,3 +1,13 @@ +libgeo-coder-googlev3-perl (0.16-1) unstable; urgency=medium + + * Team upload. + * debian/copyright: Update copyright years + * Bump Standards-Version to 4.0.0 (no changes) + * debian/patches/tests-no-network.patch: Refresh patch + * Import upstream version 0.16 + + -- Angel Abad Sun, 16 Jul 2017 10:18:08 +0200 + libgeo-coder-googlev3-perl (0.15-1) unstable; urgency=medium [ Salvatore Bonaccorso ] diff -Nru libgeo-coder-googlev3-perl-0.15/debian/control libgeo-coder-googlev3-perl-0.16/debian/control --- libgeo-coder-googlev3-perl-0.15/debian/control 2017-01-21 13:04:21.000000000 +0000 +++ libgeo-coder-googlev3-perl-0.16/debian/control 2017-07-16 08:18:08.000000000 +0000 @@ -11,7 +11,7 @@ liburi-perl, libwww-perl, perl -Standards-Version: 3.9.8 +Standards-Version: 4.0.0 Vcs-Browser: https://anonscm.debian.org/cgit/pkg-perl/packages/libgeo-coder-googlev3-perl.git Vcs-Git: https://anonscm.debian.org/git/pkg-perl/packages/libgeo-coder-googlev3-perl.git Homepage: https://metacpan.org/release/Geo-Coder-Googlev3 diff -Nru libgeo-coder-googlev3-perl-0.15/debian/copyright libgeo-coder-googlev3-perl-0.16/debian/copyright --- libgeo-coder-googlev3-perl-0.15/debian/copyright 2017-01-21 13:04:21.000000000 +0000 +++ libgeo-coder-googlev3-perl-0.16/debian/copyright 2017-07-16 08:18:08.000000000 +0000 @@ -8,7 +8,7 @@ License: Artistic or GPL-1+ Files: debian/* -Copyright: 2011-2014, Angel Abad +Copyright: 2011-2017, Angel Abad 2011, Ansgar Burchardt 2011, Ernesto Hernández-Novich (USB) 2011-2017, gregor herrmann diff -Nru libgeo-coder-googlev3-perl-0.15/debian/patches/tests-no-network.patch libgeo-coder-googlev3-perl-0.16/debian/patches/tests-no-network.patch --- libgeo-coder-googlev3-perl-0.15/debian/patches/tests-no-network.patch 2017-01-21 13:04:21.000000000 +0000 +++ libgeo-coder-googlev3-perl-0.16/debian/patches/tests-no-network.patch 2017-07-16 08:18:08.000000000 +0000 @@ -6,9 +6,9 @@ --- a/t/geocode.t +++ b/t/geocode.t -@@ -16,6 +16,8 @@ - - SKIP: { +@@ -23,6 +23,8 @@ + like $info{err}, qr{REQUEST_DENIED}, 'invalid api key'; + } +last SKIP if $ENV{NO_NETWORK}; + diff -Nru libgeo-coder-googlev3-perl-0.15/lib/Geo/Coder/Googlev3.pm libgeo-coder-googlev3-perl-0.16/lib/Geo/Coder/Googlev3.pm --- libgeo-coder-googlev3-perl-0.15/lib/Geo/Coder/Googlev3.pm 2017-01-20 21:29:40.000000000 +0000 +++ libgeo-coder-googlev3-perl-0.16/lib/Geo/Coder/Googlev3.pm 2017-07-14 19:21:50.000000000 +0000 @@ -12,7 +12,7 @@ use strict; use vars qw($VERSION); -our $VERSION = '0.15'; +our $VERSION = '0.16'; use Carp ('croak'); use Encode (); @@ -39,14 +39,14 @@ if ($sensor !~ m{^(false|true)$}) { croak "sensor argument has to be either 'false' or 'true'"; } - } else { - $sensor = 'false'; } $self->{sensor} = $sensor; } if ($args{bounds}) { $self->bounds(delete $args{bounds}); } + $self->{key} = delete $args{key}; + $self->{use_https} = delete $args{use_https}; croak "Unsupported arguments: " . join(" ", %args) if %args; $self; } @@ -91,15 +91,16 @@ sub geocode_url { my($self, %args) = @_; my $loc = $args{location}; - my $url = URI->new('http://maps.google.com/maps/api/geocode/json'); + my $url = URI->new(($self->{use_https} ? 'https' : 'http') . '://maps.google.com/maps/api/geocode/json'); my %url_params; $url_params{address} = $loc; - $url_params{sensor} = $self->{sensor}; + $url_params{sensor} = $self->{sensor} if defined $self->{sensor}; $url_params{region} = $self->{region} if defined $self->{region}; $url_params{language} = $self->{language} if defined $self->{language}; if (defined $self->{bounds}) { $url_params{bounds} = join '|', map { $_->{lat}.','.$_->{lng} } @{ $self->{bounds} }; } + $url_params{key} = $self->{key} if defined $self->{key}; while(my($k,$v) = each %url_params) { $url->query_param($k => Encode::encode_utf8($v)); } @@ -190,10 +191,9 @@ L object. The default C object sets the C to 15 seconds and enables the C option. -The L's C and C parameters are not -supported. +The L's C parameter is not supported. -The parameters C, C, and C are also +The parameters C, C, C, and C are also accepted. The C parameter should be in the form: [{lat => ..., lng => ...}, {lat => ..., lng => ...}] @@ -201,7 +201,10 @@ The parameter C should be set to the string C if the geocoding request comes from a device with a location sensor (see L). -The default is C. +There's no default. + +By default queries are done using C. By setting the C +parameter to a true value C is used. =back diff -Nru libgeo-coder-googlev3-perl-0.15/META.json libgeo-coder-googlev3-perl-0.16/META.json --- libgeo-coder-googlev3-perl-0.15/META.json 2017-01-20 21:36:33.000000000 +0000 +++ libgeo-coder-googlev3-perl-0.16/META.json 2017-07-14 19:37:19.000000000 +0000 @@ -45,5 +45,5 @@ "url" : "git://github.com/eserte/Geo-Coder-Googlev3.git" } }, - "version" : "0.15" + "version" : "0.16" } diff -Nru libgeo-coder-googlev3-perl-0.15/META.yml libgeo-coder-googlev3-perl-0.16/META.yml --- libgeo-coder-googlev3-perl-0.15/META.yml 2017-01-20 21:36:33.000000000 +0000 +++ libgeo-coder-googlev3-perl-0.16/META.yml 2017-07-14 19:37:18.000000000 +0000 @@ -24,4 +24,4 @@ URI: 0 resources: repository: git://github.com/eserte/Geo-Coder-Googlev3.git -version: 0.15 +version: 0.16 diff -Nru libgeo-coder-googlev3-perl-0.15/t/geocode.t libgeo-coder-googlev3-perl-0.16/t/geocode.t --- libgeo-coder-googlev3-perl-0.15/t/geocode.t 2017-01-20 21:29:05.000000000 +0000 +++ libgeo-coder-googlev3-perl-0.16/t/geocode.t 2017-07-14 19:21:12.000000000 +0000 @@ -6,8 +6,8 @@ use Test::More 'no_plan'; -sub within ($$$$$$); -sub safe_geocode (&); +sub within ($$$$$$;$); +sub safe_geocode (&;$); use_ok 'Geo::Coder::Googlev3'; @@ -16,6 +16,13 @@ SKIP: { +{ # key + my $geocoder = Geo::Coder::Googlev3->new(key => "INVALID_KEY"); + my %info; + safe_geocode { $geocoder->geocode(location => 'Berlin') } \%info; + like $info{err}, qr{REQUEST_DENIED}, 'invalid api key'; +} + { # list context ## There are eight hits in Berlin. Google uses to know seven of them. ## But beginning from approx. 2010-05, only one location is returned. @@ -102,16 +109,18 @@ } { # bounds + local $TODO = "Started to fail (RT #122485)"; # XXX check! + my $location_chicago = safe_geocode { $geocoder->geocode(location => 'Winnetka') }; within $location_chicago->{geometry}->{location}->{lat}, $location_chicago->{geometry}->{location}->{lng}, - 42.1080830, 42.1080840, -87.735900, -87.735890; + 42.1080830, 42.1080840, -87.735900, -87.735890, 'Winnetka without bounds'; my $bounds = [{lat=>34.172684,lng=>-118.604794},{lat=>34.236144,lng=>-118.500938}]; my $geocoder_la = Geo::Coder::Googlev3->new(bounds => $bounds); is_deeply $geocoder_la->bounds, $bounds, 'bounds accessor'; my $location_la = safe_geocode { $geocoder_la->geocode(location => 'Winnetka') }; within $location_la->{geometry}->{location}->{lat}, $location_la->{geometry}->{location}->{lng}, - 34.172684, 34.236144, -118.604794, -118.500938; + 34.172684, 34.236144, -118.604794, -118.500938, 'Winnetka with bounds'; } { # invalid bounds @@ -155,9 +164,9 @@ my $geocoder_default = Geo::Coder::Googlev3->new(); ok $geocoder_default; - is $geocoder_default->sensor, 'false', 'Default is false'; + is $geocoder_default->sensor, undef, "There's no default"; my $url_default = $geocoder_default->geocode_url(location => 'Hauptstr., Berlin'); - like $url_default, qr{sensor=false}, 'sensor=false detected in URL without explicit sensor setting'; + unlike $url_default, qr{sensor=false}, 'no sensor=false required anymore in URL without explicit sensor setting'; } { @@ -174,18 +183,39 @@ like $@, qr{sensor argument has to be either 'false' or 'true'}, 'expected error message for unsupported sensor argument'; } +{ # https + my $geocoder = Geo::Coder::Googlev3->new(use_https => 1); + + # Probably should not use nested SKIP blocks here + if ($geocoder->ua->is_protocol_supported('https')) { + my $location = safe_geocode { + $geocoder->geocode(location => 'Berlin') + }; + like $location->{formatted_address}, qr{berlin}i, 'https query'; + } else { + # but here is OK + SKIP: { + skip "UA does not support https (maybe you have to install LWP::Protocol::https or so", 1; + } + } } -sub within ($$$$$$) { - my($lat,$lng,$lat_min,$lat_max,$lng_min,$lng_max) = @_; - cmp_ok $lat, ">=", $lat_min; - cmp_ok $lat, "<=", $lat_max; - cmp_ok $lng, ">=", $lng_min; - cmp_ok $lng, "<=", $lng_max; +} # SKIP + +sub within ($$$$$$;$) { + my($lat,$lng,$lat_min,$lat_max,$lng_min,$lng_max,$testname_prefix) = @_; + my $testname = sub ($) { + (defined $testname_prefix ? "$testname_prefix (" : "") . $_[0] . (defined $testname_prefix ? ")" : ""); + }; + local $Test::Builder::Level = $Test::Builder::Level + 1; + cmp_ok $lat, ">=", $lat_min, $testname->("southern latitude"); + cmp_ok $lat, "<=", $lat_max, $testname->("northern latitude"); + cmp_ok $lng, ">=", $lng_min, $testname->("western longitude"); + cmp_ok $lng, "<=", $lng_max, $testname->("eastern longitude"); } -sub safe_geocode (&) { - my($code0) = @_; +sub safe_geocode (&;$) { + my($code0, $inforef) = @_; my @locations; my $code; if (wantarray) { @@ -213,6 +243,10 @@ last SKIP; } + if ($inforef) { + $inforef->{err} = $@; + } + if (wantarray) { @locations; } else {