| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Geo::GNIS; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
28054
|
use 5.006; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
42
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
34
|
|
|
5
|
1
|
|
|
1
|
|
953
|
use Carp::Assert; |
|
|
1
|
|
|
|
|
1369
|
|
|
|
1
|
|
|
|
|
8
|
|
|
6
|
1
|
|
|
|
|
1031
|
use base qw( |
|
7
|
|
|
|
|
|
|
Geo::TigerLine::Record::Parser |
|
8
|
|
|
|
|
|
|
Geo::TigerLine::Record::Accessor |
|
9
|
|
|
|
|
|
|
Geo::TigerLine::Record |
|
10
|
|
|
|
|
|
|
Class::Data::Inheritable |
|
11
|
1
|
|
|
1
|
|
129
|
); |
|
|
1
|
|
|
|
|
1
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Auto-generated data dictionary. |
|
16
|
|
|
|
|
|
|
my @Proto_Dict = ( |
|
17
|
|
|
|
|
|
|
fid => { |
|
18
|
|
|
|
|
|
|
beg => 1, end => 10, type => "N", description => "Feature ID" }, |
|
19
|
|
|
|
|
|
|
state => { |
|
20
|
|
|
|
|
|
|
beg => 11, end => 13, type => "L", description => "State Alpha Code" }, |
|
21
|
|
|
|
|
|
|
name => { |
|
22
|
|
|
|
|
|
|
beg => 14, end => 114, type => "L", description => "Feature Name" }, |
|
23
|
|
|
|
|
|
|
type => { |
|
24
|
|
|
|
|
|
|
beg => 115, end => 124, type => "L", description => "Feature Type" }, |
|
25
|
|
|
|
|
|
|
county => { |
|
26
|
|
|
|
|
|
|
beg => 125, end => 140, type => "L", description => "County" }, |
|
27
|
|
|
|
|
|
|
coord => { |
|
28
|
|
|
|
|
|
|
beg => 141, end => 157, type => "L", |
|
29
|
|
|
|
|
|
|
description => "Geographic Coordinates" }, |
|
30
|
|
|
|
|
|
|
cell => { |
|
31
|
|
|
|
|
|
|
beg => 158, end => 182, type => "L", description => "Cell Name" }, |
|
32
|
|
|
|
|
|
|
elev => { |
|
33
|
|
|
|
|
|
|
beg => 183, end => 189, type => "N", description => "Elevation" }, |
|
34
|
|
|
|
|
|
|
est_pop => { |
|
35
|
|
|
|
|
|
|
beg => 190, end => 197, type => "N", description => "Est. Population" }, |
|
36
|
|
|
|
|
|
|
status => { |
|
37
|
|
|
|
|
|
|
beg => 199, end => 207, type => "L", |
|
38
|
|
|
|
|
|
|
description => "Federal Status of Feature Name" }, |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my %Data_Dict = (); |
|
42
|
|
|
|
|
|
|
my @Data_Fields = (); |
|
43
|
|
|
|
|
|
|
my $fieldnum = 1; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
while (my ($field, $args) = splice(@Proto_Dict, 0, 2)) { |
|
46
|
|
|
|
|
|
|
$Data_Dict{$field} = { |
|
47
|
|
|
|
|
|
|
fieldnum => $fieldnum++, bv => "Yes", field => $field, |
|
48
|
|
|
|
|
|
|
len => $args->{end} - $args->{beg} + 1, |
|
49
|
|
|
|
|
|
|
fmt => ($args->{type} eq "N" ? "R" : "L"), |
|
50
|
|
|
|
|
|
|
%$args |
|
51
|
|
|
|
|
|
|
}; |
|
52
|
|
|
|
|
|
|
push @Data_Fields, $field; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
assert(keys %Data_Dict == @Data_Fields); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Turn the data dictionary into class data |
|
58
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('Fields'); |
|
59
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('Dict'); |
|
60
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('Pack_Tmpl'); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__PACKAGE__->Dict(\%Data_Dict); |
|
63
|
|
|
|
|
|
|
__PACKAGE__->Fields(\@Data_Fields); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Generate a pack template for parsing and turn it into class data. |
|
66
|
|
|
|
|
|
|
my $pack_tmpl = join ' ', map { "A$_" } map { $_->{len} } |
|
67
|
|
|
|
|
|
|
@Data_Dict{@Data_Fields}; |
|
68
|
|
|
|
|
|
|
__PACKAGE__->Pack_Tmpl($pack_tmpl); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Generate accessors for each data field |
|
71
|
|
|
|
|
|
|
foreach my $def (@Data_Dict{@Data_Fields}) { |
|
72
|
|
|
|
|
|
|
__PACKAGE__->mk_accessor($def); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub lat { |
|
76
|
1
|
|
|
1
|
0
|
6008
|
my $self = shift; |
|
77
|
1
|
|
|
|
|
6
|
my ($d, $m, $s, $ns) = $self->coord =~ /(\d\d)(\d\d)(\d\d)([NS])/gos; |
|
78
|
1
|
|
|
|
|
22
|
my $lat = $d + $m / 60 + $s / 3600; |
|
79
|
1
|
50
|
|
|
|
8
|
return ($ns eq "N" ? $lat : -$lat); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub lon { |
|
83
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
|
84
|
1
|
|
|
|
|
5
|
my ($d, $m, $s, $ew) = $self->coord =~ /(\d\d\d?)(\d\d)(\d\d)([EW])/gos; |
|
85
|
1
|
|
|
|
|
19
|
my $lon = $d + $m / 60 + $s / 3600; |
|
86
|
1
|
50
|
|
|
|
7
|
return ($ew eq "W" ? -$lon : $lon); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
|
90
|
|
|
|
|
|
|
__END__ |