line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::Coordinates::Converter::Format::Dms; |
2
|
6
|
|
|
6
|
|
5727
|
use strict; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
224
|
|
3
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
173
|
|
4
|
6
|
|
|
6
|
|
30
|
use parent 'Geo::Coordinates::Converter::Format'; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
35
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
7310
|
use POSIX; |
|
6
|
|
|
|
|
82036
|
|
|
6
|
|
|
|
|
47
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $DIGITS = 3; |
9
|
|
|
|
|
|
|
|
10
|
101
|
|
|
101
|
0
|
399
|
sub name { 'dms' } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub detect { |
13
|
51
|
|
|
51
|
0
|
113
|
my($self, $point) = @_; |
14
|
|
|
|
|
|
|
|
15
|
51
|
100
|
100
|
|
|
183
|
return unless defined $point->lat && $point->lat =~ /^[\-\+NS]?[0-9]{1,2}\.[0-9][0-9]?\.[0-9][0-9]?(?:\.[0-9]+)$/i; |
16
|
33
|
50
|
33
|
|
|
730
|
return unless defined $point->lng && $point->lng =~ /^[\-\+EW]?[0-9]{1,3}\.[0-9][0-9]?\.[0-9][0-9]?(?:\.[0-9]+)$/i; |
17
|
|
|
|
|
|
|
|
18
|
33
|
|
|
|
|
932
|
return $self->name; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub to { |
22
|
24
|
|
|
24
|
0
|
50
|
my($self, $point) = @_; |
23
|
|
|
|
|
|
|
|
24
|
24
|
|
|
|
|
62
|
for my $meth (qw/ lat lng /) { |
25
|
48
|
|
|
|
|
262
|
my($ws, $deg, $min, $sec) = $point->$meth =~ /^(\-?)([0-9]+)\.([0-9]+)\.([0-9]+(?:\.[0-9]+)?)$/i; |
26
|
48
|
|
|
|
|
749
|
my $ret = $deg + ($min / 60) + ($sec / 3600); |
27
|
48
|
100
|
|
|
|
139
|
$ret = $ws =~ /\-/i ? -1 * $ret : $ret; |
28
|
48
|
|
|
|
|
146
|
$point->$meth($ret); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
24
|
|
|
|
|
200
|
$point; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub from { |
35
|
30
|
|
|
30
|
0
|
50
|
my($self, $point) = @_; |
36
|
|
|
|
|
|
|
|
37
|
30
|
|
|
|
|
64
|
for my $meth (qw/ lat lng /) { |
38
|
60
|
|
|
|
|
313
|
my($ws, $degree) = $point->$meth =~ /^(\-?)(.+)$/; |
39
|
|
|
|
|
|
|
|
40
|
60
|
|
|
|
|
909
|
my $deg = floor($degree); |
41
|
60
|
|
|
|
|
224
|
my $min = floor(($degree - $deg) * 60 % 60); |
42
|
60
|
|
|
|
|
126
|
my $sec = ($degree - $deg) * 3600 - $min * 60; |
43
|
60
|
|
100
|
|
|
690
|
$point->$meth(sprintf "%s%s.%s.%s", $ws || '', $deg, $min, $sec); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
30
|
|
|
|
|
232
|
$point; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub round { |
50
|
70
|
|
|
70
|
0
|
483
|
my($self, $val) = @_; |
51
|
70
|
|
|
|
|
1687
|
sprintf "%s%s.%02d.%06.${DIGITS}f", ($val =~ /^(\-?)([^\.]+)\.([^\.]+)\.(.+)$/); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |