line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package GPS::Magellan::File; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
2283
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2690
|
|
6
|
1
|
|
|
1
|
|
6
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
55
|
|
7
|
1
|
|
|
1
|
|
5
|
use vars qw($AUTOLOAD); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
840
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
1
|
|
|
1
|
1
|
8759
|
my $proto = shift; |
11
|
1
|
|
33
|
|
|
9
|
my $class = ref($proto) || $proto; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
|
|
4
|
my %args = @_; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
50
|
|
|
8
|
my $self = bless { |
17
|
|
|
|
|
|
|
coords => $args{coords} || [], |
18
|
|
|
|
|
|
|
}, $class; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
10
|
$self->_init(); |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
4
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _init { |
26
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub read { |
31
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
32
|
0
|
|
|
|
|
0
|
my $file = shift; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
my @raw = (); |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
0
|
if($file){ |
37
|
0
|
0
|
|
|
|
0
|
open(INPUT, $file) or die sprintf("%s::read(): cannot open %s\n", ref($self), $file); |
38
|
0
|
|
|
|
|
0
|
@raw = ; |
39
|
0
|
|
|
|
|
0
|
close(INPUT); |
40
|
|
|
|
|
|
|
} else { |
41
|
0
|
|
|
|
|
0
|
@raw = ; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
$self->decode(\@raw); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub as_string { |
48
|
1
|
|
|
1
|
0
|
6
|
shift->encode(); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub write { |
53
|
1
|
|
|
1
|
0
|
56
|
my $self = shift; |
54
|
1
|
|
|
|
|
3
|
my $file = shift; |
55
|
|
|
|
|
|
|
|
56
|
1
|
50
|
|
|
|
5
|
if($file){ |
57
|
1
|
50
|
|
|
|
65
|
open(OUTPUT, ">$file") or die sprintf("%s::write(): cannot open %s\n", ref($self), $file); |
58
|
1
|
|
|
|
|
5
|
print OUTPUT $self->encode(); |
59
|
1
|
|
|
|
|
19
|
close(OUTPUT); |
60
|
|
|
|
|
|
|
} else { |
61
|
0
|
|
|
|
|
0
|
print $self->encode(); |
62
|
|
|
|
|
|
|
} |
63
|
1
|
|
|
|
|
4
|
return; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Interface to be implemented by subclasses representing various file formats |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
0
|
0
|
0
|
sub name { 'PLACEHOLDER' } |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
0
|
0
|
0
|
sub encode { '' } |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
0
|
0
|
sub decode { [] } |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
0
|
0
|
sub can_read { 0 } |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Accessors |
79
|
|
|
|
|
|
|
sub _get { |
80
|
4
|
|
|
4
|
|
7
|
my $self = shift; |
81
|
4
|
|
|
|
|
6
|
my $attr = shift; |
82
|
4
|
|
|
|
|
22
|
return $self->{$attr}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _set { |
86
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
87
|
0
|
|
|
|
|
0
|
my $attr = shift; |
88
|
0
|
|
0
|
|
|
0
|
my $value = shift || ''; |
89
|
|
|
|
|
|
|
|
90
|
0
|
0
|
|
|
|
0
|
return unless $attr; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
0
|
$self->{$attr} = $value; |
93
|
0
|
|
|
|
|
0
|
return $self->_get($attr); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _debug_autoload { |
97
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
98
|
2
|
50
|
|
|
|
8
|
$self->_set('_debug_autoload', shift) if @_; |
99
|
2
|
|
|
|
|
15
|
$self->_get('_debug_autoload'); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub AUTOLOAD { |
104
|
2
|
|
|
2
|
|
6
|
my $self = shift; |
105
|
2
|
|
|
|
|
3
|
my $attr = $AUTOLOAD; |
106
|
|
|
|
|
|
|
|
107
|
2
|
|
|
|
|
12
|
$attr =~ s/.*:://; |
108
|
|
|
|
|
|
|
|
109
|
2
|
50
|
|
|
|
13
|
return if $attr =~ /^_/; |
110
|
|
|
|
|
|
|
|
111
|
2
|
50
|
|
|
|
12
|
warn "AUTOLOAD: $attr\n" if $self->_debug_autoload; |
112
|
|
|
|
|
|
|
|
113
|
2
|
50
|
|
|
|
6
|
if(@_){ |
114
|
0
|
|
|
|
|
0
|
$self->_set($attr, shift); |
115
|
|
|
|
|
|
|
} |
116
|
2
|
|
|
|
|
20
|
return $self->_get($attr); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
0
|
|
0
|
sub DESTROY { |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
package GPS::Magellan::File::Way_Txt; |
124
|
|
|
|
|
|
|
|
125
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
126
|
|
|
|
|
|
|
|
127
|
1
|
|
|
1
|
|
5
|
use base qw/GPS::Magellan::File/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
279
|
|
128
|
|
|
|
|
|
|
|
129
|
1
|
|
|
1
|
|
2433
|
sub name { 'GpsDrive way.txt' } |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# FILE FORMAT: |
132
|
|
|
|
|
|
|
# EEMSSTRA 5220.484000 454.569000 0000016M |
133
|
|
|
|
|
|
|
# WPT002 5220.879000 454.287000 0000000M |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub encode { |
136
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
137
|
|
|
|
|
|
|
|
138
|
2
|
|
|
|
|
5
|
my @output = (); |
139
|
|
|
|
|
|
|
|
140
|
2
|
|
|
|
|
5
|
foreach my $c (@{$self->coords}){ |
|
2
|
|
|
|
|
22
|
|
141
|
20
|
|
|
|
|
101
|
push @output, sprintf("%-22s %04.6f %04.6f %07d%s\n", $c->name, $c->longitude, $c->latitude, $c->altitude, $c->unknown); |
142
|
|
|
|
|
|
|
} |
143
|
2
|
|
|
|
|
32
|
@output; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub decode { |
147
|
0
|
|
|
0
|
|
|
my $self = shift; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
__END__ |