line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::Google::StaticMaps::Navigation; |
2
|
2
|
|
|
2
|
|
1260
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
91
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
82
|
|
4
|
2
|
|
|
2
|
|
12
|
use base 'Geo::Google::StaticMaps'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
2330
|
|
5
|
2
|
|
|
2
|
|
5361
|
use Carp; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
142
|
|
6
|
2
|
|
|
2
|
|
2332
|
use Geo::Mercator; |
|
2
|
|
|
|
|
82329
|
|
|
2
|
|
|
|
|
1336
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $DEGREE_PER_PIXEL_ON_ZOOM_3 = 60/342; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _clone { |
12
|
12
|
|
|
12
|
|
648
|
my ($self) = @_; |
13
|
12
|
|
|
|
|
250
|
__PACKAGE__->new(%$self); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
1
|
186
|
sub north {$_[0]->nearby({lat => 1})}; |
17
|
1
|
|
|
1
|
1
|
5
|
sub south {$_[0]->nearby({lat => -1})}; |
18
|
3
|
|
|
3
|
1
|
21
|
sub east {$_[0]->nearby({lng => 1})}; |
19
|
1
|
|
|
1
|
1
|
6
|
sub west {$_[0]->nearby({lng => -1})}; |
20
|
1
|
|
|
1
|
1
|
24
|
sub zoom_in {$_[0]->scale(1)} |
21
|
3
|
|
|
3
|
1
|
23
|
sub zoom_out {$_[0]->scale(-1)} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub pageurl { |
24
|
1
|
|
|
1
|
1
|
11142
|
my ($self, $old_uri) = @_; |
25
|
1
|
|
|
|
|
13
|
my %orig = $old_uri->query_form; |
26
|
1
|
|
|
|
|
264
|
my $uri = $old_uri->clone; |
27
|
1
|
|
|
|
|
20
|
$uri->query_form( |
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
%orig, |
30
|
|
|
|
|
|
|
lat => $self->{center}->[0], |
31
|
|
|
|
|
|
|
lng => $self->{center}->[1], |
32
|
|
|
|
|
|
|
zoom => $self->{zoom}, |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
); |
35
|
1
|
|
|
|
|
188
|
return $uri; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub nearby { |
39
|
7
|
|
|
7
|
1
|
11
|
my ($self, $args) = @_; |
40
|
7
|
|
|
|
|
18
|
my $clone = $self->_clone; |
41
|
7
|
50
|
|
|
|
104
|
croak "zoom parameter is required" unless defined $clone->{zoom}; |
42
|
7
|
|
100
|
|
|
25
|
$clone->{center} = _next_latlng( |
|
|
|
100
|
|
|
|
|
43
|
|
|
|
|
|
|
$clone->{center}->[0], |
44
|
|
|
|
|
|
|
$clone->{center}->[1], |
45
|
|
|
|
|
|
|
_degree($clone->{size}->[1], $clone->{zoom}) * ($args->{lat} || 0), |
46
|
|
|
|
|
|
|
_degree($clone->{size}->[0], $clone->{zoom}) * ($args->{lng} || 0), |
47
|
|
|
|
|
|
|
); |
48
|
7
|
|
|
|
|
29
|
return $clone; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub scale { |
52
|
4
|
|
|
4
|
1
|
7
|
my ($self, $arg) = @_; |
53
|
4
|
|
|
|
|
9
|
my $clone = $self->_clone; |
54
|
4
|
50
|
|
|
|
56
|
croak "zoom parameter is required" unless defined $clone->{zoom}; |
55
|
4
|
|
|
|
|
6
|
$clone->{zoom} += $arg; |
56
|
4
|
|
|
|
|
34
|
return $clone; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _degree { |
60
|
15
|
|
|
15
|
|
5372
|
my ($size, $zoom) = @_; |
61
|
15
|
|
|
|
|
148
|
return $size * $DEGREE_PER_PIXEL_ON_ZOOM_3 * ( 2 ** (3 - $zoom)); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub _next_latlng { |
65
|
7
|
|
|
7
|
|
10
|
my ($lat, $lng, $move_lat, $move_lng) = @_; |
66
|
7
|
|
|
|
|
22
|
my $move_y = [ mercate($move_lat, 0) ]->[1] - [ mercate(0,0) ]->[1]; |
67
|
7
|
|
|
|
|
412
|
my ($x, $y) = mercate($lat, $lng); |
68
|
7
|
|
|
|
|
154
|
my ($new_lat) = demercate($x, $y+$move_y); |
69
|
|
|
|
|
|
|
return [ |
70
|
7
|
|
|
|
|
264
|
$new_lat, |
71
|
|
|
|
|
|
|
$lng + $move_lng, |
72
|
|
|
|
|
|
|
]; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
__END__ |