line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::Formatter::Format::DMS; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
32
|
use strict; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
196
|
|
4
|
6
|
|
|
6
|
|
41
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
5934
|
|
5
|
6
|
|
|
6
|
|
43
|
use Carp; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
408
|
|
6
|
6
|
|
|
6
|
|
3325
|
use Geo::Formatter::CalcurateDMS; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
328
|
|
7
|
6
|
|
|
6
|
|
33
|
use base qw(Geo::Formatter::FormatBase::Double); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
118
|
|
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
430
|
use version; our $VERSION = qv('0.0.1'); |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
21
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub encode { |
12
|
6
|
|
|
6
|
1
|
16
|
my ($class,$lat,$lng,$opt) = @_; |
13
|
|
|
|
|
|
|
|
14
|
6
|
|
50
|
|
|
18
|
$opt ||= {}; |
15
|
|
|
|
|
|
|
|
16
|
6
|
100
|
|
|
|
20
|
my $under_decimal = defined($opt->{under_decimal}) ? $opt->{under_decimal} : 3; |
17
|
6
|
|
100
|
|
|
93
|
my $sign = $opt->{sign} || 0; |
18
|
6
|
|
100
|
|
|
31
|
my $zerofill = $opt->{zerofill} || 0; |
19
|
6
|
100
|
|
|
|
20
|
my $devider = defined($opt->{devider}) ? $opt->{devider} : "."; |
20
|
|
|
|
|
|
|
|
21
|
6
|
50
|
|
|
|
25
|
croak "Cannot use number character as devider" if ($devider =~ /\d/); |
22
|
6
|
|
|
|
|
14
|
$devider =~ s/%/%%/g; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# %+d.%02d.%06.3f |
25
|
6
|
100
|
|
|
|
55
|
my $form = sprintf( |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
26
|
|
|
|
|
|
|
"%%%sd%s%%%sd%s%%%s.%df", |
27
|
|
|
|
|
|
|
$sign ? "+" : "", |
28
|
|
|
|
|
|
|
$devider, |
29
|
|
|
|
|
|
|
$zerofill ? "02" : "", |
30
|
|
|
|
|
|
|
$devider, |
31
|
|
|
|
|
|
|
$zerofill ? "0" . ($under_decimal + 3) : "", |
32
|
|
|
|
|
|
|
$under_decimal |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
12
|
|
|
|
|
41
|
map { |
36
|
6
|
|
|
|
|
15
|
my ($minus,$d,$m,$s) = __degree2dms($_); |
37
|
|
|
|
|
|
|
|
38
|
12
|
100
|
|
|
|
34
|
$d *= -1 if ($minus); |
39
|
12
|
|
|
|
|
121
|
sprintf($form,$d,$m,$s); |
40
|
|
|
|
|
|
|
} ($lat,$lng); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub decode { |
44
|
8
|
|
|
8
|
1
|
17
|
my ($class,$lat,$lng,$opt) = @_; |
45
|
|
|
|
|
|
|
|
46
|
8
|
|
50
|
|
|
23
|
$opt ||= {}; |
47
|
|
|
|
|
|
|
|
48
|
8
|
|
100
|
|
|
37
|
my $devider = $opt->{devider} || "."; |
49
|
|
|
|
|
|
|
|
50
|
8
|
50
|
|
|
|
30
|
croak "Cannot use number character as devider" if ($devider =~ /\d/); |
51
|
8
|
|
|
|
|
52
|
$devider =~ s/([\.\^\$\[\]\*\+\?\|\(\)\\\/])/\\$1/g; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# ([\+\-]?)(\d+)\.(\d+)\.(\d+(?:\.\d*)) |
54
|
8
|
|
|
|
|
197
|
my $form = qr(([\+\-]?)(\d+)$devider(\d+)$devider(\d+(?:\.\d*)?)); |
55
|
|
|
|
|
|
|
|
56
|
16
|
50
|
|
|
|
142
|
map { |
57
|
8
|
|
|
|
|
20
|
my ($minus,$d,$m,$s) = /$form/ or croak "Arguments are not DMS format"; |
58
|
16
|
100
|
100
|
|
|
71
|
$minus = $minus && $minus eq "-" ? 1 : 0; |
59
|
|
|
|
|
|
|
|
60
|
16
|
|
|
|
|
58
|
__dms2degree($minus,$d,$m,$s); |
61
|
|
|
|
|
|
|
} ($lat,$lng); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |