line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Location::GeoTool::Plugin::Locapoint; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
39
|
use 5.008; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
88
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
66
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
72
|
|
6
|
2
|
|
|
2
|
|
11
|
no strict 'refs'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
73
|
|
7
|
2
|
|
|
2
|
|
11
|
no warnings 'redefine'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
83
|
|
8
|
2
|
|
|
2
|
|
19
|
use Location::GeoTool; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
9
|
2
|
|
|
2
|
|
2016
|
use Math::Round qw(nhimult); |
|
2
|
|
|
|
|
29812
|
|
|
2
|
|
|
|
|
173
|
|
10
|
2
|
|
|
2
|
|
25
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
2024
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub import { |
15
|
0
|
|
|
0
|
|
0
|
__PACKAGE__->setup(); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my @devider = (1757600,67600,6760,260,10); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub int2code |
21
|
|
|
|
|
|
|
{ |
22
|
20
|
|
|
20
|
0
|
24
|
my ($value,$count) = @_; |
23
|
20
|
|
|
|
|
32
|
my $this = int($value / $devider[$count]); |
24
|
20
|
|
|
|
|
22
|
my $low = $value % $devider[$count]; |
25
|
20
|
100
|
|
|
|
50
|
$this = pack "C", 65 + $this if ($count != 2); |
26
|
20
|
100
|
|
|
|
34
|
if ($count == 4) |
27
|
|
|
|
|
|
|
{ |
28
|
4
|
|
|
|
|
6
|
$this .= $low; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else |
31
|
|
|
|
|
|
|
{ |
32
|
16
|
|
|
|
|
34
|
$this .= int2code($low,$count+1); |
33
|
|
|
|
|
|
|
} |
34
|
20
|
|
|
|
|
35
|
return $this; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub code2int |
38
|
|
|
|
|
|
|
{ |
39
|
20
|
|
|
20
|
0
|
28
|
my ($value,$count) = @_; |
40
|
20
|
|
|
|
|
39
|
my $this = substr($value,0,1); |
41
|
20
|
|
|
|
|
31
|
my $low = substr($value,1); |
42
|
20
|
100
|
|
|
|
79
|
$this = unpack("C",$this) - 65 if ($this =~ /^[A-Z]$/); |
43
|
20
|
|
|
|
|
33
|
$this *= $devider[$count]; |
44
|
20
|
100
|
|
|
|
37
|
if ($count == 4) |
45
|
|
|
|
|
|
|
{ |
46
|
4
|
|
|
|
|
18
|
$this += $low; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else |
49
|
|
|
|
|
|
|
{ |
50
|
16
|
|
|
|
|
41
|
$this += code2int($low,$count+1); |
51
|
|
|
|
|
|
|
} |
52
|
20
|
|
|
|
|
47
|
return $this; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub setup { |
56
|
2
|
|
|
2
|
0
|
16
|
Location::GeoTool->_make_accessors(qw(cache_locapo)); |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
6
|
my $createcoord_3d = \&Location::GeoTool::create_coord3d; |
59
|
2
|
|
|
|
|
9
|
*{"Location::GeoTool\::create_coord3d"} = sub |
60
|
|
|
|
|
|
|
{ |
61
|
4
|
|
|
4
|
|
7
|
my $self = shift; |
62
|
4
|
|
|
|
|
14
|
$self = &$createcoord_3d($self,@_); |
63
|
4
|
|
|
|
|
9
|
$self->{cache_locapo} = undef; |
64
|
4
|
|
|
|
|
12
|
return $self; |
65
|
2
|
|
|
|
|
7
|
}; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Location::GeoTool->set_original_code( |
68
|
|
|
|
|
|
|
"locapoint", |
69
|
|
|
|
|
|
|
[ |
70
|
|
|
|
|
|
|
sub { |
71
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
72
|
2
|
|
|
|
|
4
|
my $locapo = shift; |
73
|
|
|
|
|
|
|
|
74
|
2
|
50
|
|
|
|
14
|
$locapo =~ /^([A-Z][A-Z][0-9])\.([A-Z][A-Z][0-9])(\.([A-Z][A-Z][0-9])\.([A-Z][A-Z][0-9]))$/ or croak "Argument $locapo is not locapoint!!"; |
75
|
2
|
|
50
|
|
|
11
|
my $lat = $1.($4 || 'NA0'); |
76
|
2
|
|
50
|
|
|
10
|
my $long = $2.($5 || 'NA0'); |
77
|
|
|
|
|
|
|
|
78
|
2
|
|
|
|
|
6
|
foreach ($lat,$long) |
79
|
|
|
|
|
|
|
{ |
80
|
4
|
|
|
|
|
11
|
$_ = code2int($_,0); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
2
|
|
|
|
|
15
|
$lat = nhimult(.000001,$lat * 9 / 2284880 - 90); |
84
|
2
|
|
|
|
|
48
|
$long = nhimult(.000001,$long * 9 / 1142440 - 180); |
85
|
|
|
|
|
|
|
|
86
|
2
|
|
|
|
|
24
|
$self = $self->create_coord($lat,$long,"wgs84","degree"); |
87
|
2
|
|
|
|
|
4
|
$self->{cache_locapo} = $locapo; |
88
|
2
|
|
|
|
|
16
|
return $self; |
89
|
|
|
|
|
|
|
}, |
90
|
|
|
|
|
|
|
sub { |
91
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
92
|
2
|
50
|
|
|
|
6
|
return $self->cache_locapo if ($self->cache_locapo); |
93
|
2
|
|
|
|
|
35
|
my ($lat,$long) = $self->datum_wgs84->format_degree->array; |
94
|
|
|
|
|
|
|
|
95
|
2
|
|
|
|
|
27
|
$lat = int(($lat + 90) * 2284880 / 9); |
96
|
2
|
|
|
|
|
5
|
$long = int(($long + 180) *1142440 / 9); |
97
|
|
|
|
|
|
|
|
98
|
2
|
|
|
|
|
4
|
foreach ($lat,$long) |
99
|
|
|
|
|
|
|
{ |
100
|
4
|
|
33
|
|
|
91
|
while (($_ < 0) || ($_ > 45697599)) |
101
|
|
|
|
|
|
|
{ |
102
|
0
|
0
|
|
|
|
0
|
$_ = $_ < 0 ? $_ + 45697600 : $_ - 45697600; |
103
|
|
|
|
|
|
|
} |
104
|
4
|
|
|
|
|
11
|
$_ = int2code($_,0); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
2
|
|
|
|
|
28
|
$self->{cache_locapo} = sprintf("%s.%s.%s.%s",substr($lat,0,3),substr($long,0,3),substr($lat,3,3),substr($long,3,3)); |
108
|
2
|
|
|
|
|
9
|
return $self->cache_locapo; |
109
|
|
|
|
|
|
|
}, |
110
|
2
|
|
|
|
|
27
|
] |
111
|
|
|
|
|
|
|
); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
115
|
|
|
|
|
|
|
__END__ |