line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::Coordinates::Converter::Format::Geohash; |
2
|
3
|
|
|
3
|
|
181687
|
use strict; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
132
|
|
3
|
3
|
|
|
3
|
|
93
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
85
|
|
4
|
3
|
|
|
3
|
|
843
|
use parent 'Geo::Coordinates::Converter::Format'; |
|
3
|
|
|
|
|
313
|
|
|
3
|
|
|
|
|
19
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
2383
|
use Geo::Coordinates::Converter::Point::Geohash; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
119
|
|
8
|
3
|
|
|
3
|
|
8125
|
use Geohash; |
|
3
|
|
|
|
|
15192
|
|
|
3
|
|
|
|
|
5781
|
|
9
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
0
|
43
|
sub name { 'geohash' } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
4
|
|
|
4
|
0
|
21428
|
my($class, %args) = @_; |
14
|
4
|
|
|
|
|
52
|
my $self = $class->SUPER::new(%args); |
15
|
4
|
|
|
|
|
228
|
$self->{geohash} = Geohash->new; |
16
|
4
|
|
|
|
|
121
|
$self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub detect { |
20
|
3
|
|
|
3
|
0
|
7330
|
my($self, $point) = @_; |
21
|
3
|
100
|
|
|
|
29
|
return unless $point->isa('Geo::Coordinates::Converter::Point::Geohash'); |
22
|
2
|
50
|
|
|
|
9
|
return unless $point->geohash =~ /\A[0-9bcdefghjkmnpqrstuvwxyz]+\z/i; |
23
|
2
|
|
|
|
|
33
|
return $self->name; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# geohash to lat/lng |
27
|
|
|
|
|
|
|
sub to { |
28
|
2
|
|
|
2
|
0
|
2442
|
my($self, $point) = @_; |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
17
|
my($lat, $lng) = $self->{geohash}->decode($point->{geohash}); |
31
|
2
|
|
|
|
|
522
|
$point->lat($lat); |
32
|
2
|
|
|
|
|
19
|
$point->lng($lng); |
33
|
2
|
|
|
|
|
14
|
$point->geohash(undef); |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
163
|
$point; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# lat/lng to geohash |
39
|
|
|
|
|
|
|
sub from { |
40
|
2
|
|
|
2
|
0
|
839
|
my($self, $point) = @_; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# re-bless to geohash point package |
43
|
|
|
|
|
|
|
# because i want ->geohash method |
44
|
2
|
50
|
|
|
|
27
|
bless $point, 'Geo::Coordinates::Converter::Point::Geohash' unless $point->isa(__PACKAGE__); |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
14
|
my $geohash = $self->{geohash}->encode($point->lat, $point->lng); |
47
|
2
|
|
|
|
|
1229
|
$point->geohash($geohash); |
48
|
2
|
|
|
|
|
18
|
$point->lat(undef); |
49
|
2
|
|
|
|
|
15
|
$point->lng(undef); |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
11
|
$point; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
__END__ |