blib/lib/Geo/GNIS.pm

filter: Statementstmt 100% 40 / 40 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 92.8% 52 / 56 CC 3 SCAR 4.1
CC
3
Cov
96%
lat
2.0
lon
2.0
BEGIN
1.0
CRAP 1.5
↑ Summary
1 package Geo::GNIS;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp::Assert;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use base qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
7 Geo::TigerLine::Record::Parser
8 Geo::TigerLine::Record::Accessor
9 Geo::TigerLine::Record
10 Class::Data::Inheritable
11 1 );
12  
13 1 our $VERSION = '0.01';
14  
15 # Auto-generated data dictionary.
16 1 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 1 my %Data_Dict = ();
42 1 my @Data_Fields = ();
43 1 my $fieldnum = 1;
44  
45 1 ▶while (my ($field, $args) = splice(@Proto_Dict, 0, 2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@Proto_Dict, 0, 2)) 10 1 11
46 $Data_Dict{$field} = {
47 fieldnum => $fieldnum++, bv => "Yes", field => $field,
48 len => $args->{end} - $args->{beg} + 1,
49 10 ▶ fmt => ($args->{type} eq "N" ? "R" : "L"),
Branch: 1 branch
BranchTrueFalseTotal
$args->{'type'} eq 'N' ? : 3 7 10
50 %$args
51 };
52 10 push @Data_Fields, $field;
53 }
54  
55 1 assert(keys %Data_Dict == @Data_Fields);
56  
57 # Turn the data dictionary into class data
58 1 __PACKAGE__->mk_classdata('Fields');
59 1 __PACKAGE__->mk_classdata('Dict');
60 1 __PACKAGE__->mk_classdata('Pack_Tmpl');
61  
62 1 __PACKAGE__->Dict(\%Data_Dict);
63 1 __PACKAGE__->Fields(\@Data_Fields);
64  
65 # Generate a pack template for parsing and turn it into class data.
66 10 my $pack_tmpl = join ' ', map { "A$_" } map { $_->{len} }
67 1 @Data_Dict{@Data_Fields};
68 1 __PACKAGE__->Pack_Tmpl($pack_tmpl);
69  
70 # Generate accessors for each data field
71 1 foreach my $def (@Data_Dict{@Data_Fields}) {
72 10 __PACKAGE__->mk_accessor($def);
73 }
74  
75 1 ▶sub lat {
Subroutine lat: called CC=2 SCAR=7.0
Pod undocumented
76 1 my $self = shift;
77 1 my ($d, $m, $s, $ns) = $self->coord =~ /(\d\d)(\d\d)(\d\d)([NS])/gos;
78 1 my $lat = $d + $m / 60 + $s / 3600;
79 1 ▶ return ($ns eq "N" ? $lat : -$lat);
Branch: 1 branch
BranchTrueFalseTotal
$ns eq 'N' ? : 1 0 1
80 }
81  
82 1 ▶sub lon {
Subroutine lon: called CC=2 SCAR=7.0
Pod undocumented
83 1 my $self = shift;
84 1 my ($d, $m, $s, $ew) = $self->coord =~ /(\d\d\d?)(\d\d)(\d\d)([EW])/gos;
85 1 my $lon = $d + $m / 60 + $s / 3600;
86 1 ▶ return ($ew eq "W" ? -$lon : $lon);
Branch: 1 branch
BranchTrueFalseTotal
$ew eq 'W' ? : 1 0 1
87 }
88  
89 1 1;
90 __END__
↑ Summary