TigerLine/Record/M.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 42 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Geo::TigerLine::Record::M;
2  
3 use strict;
4  
5 use Carp::Assert;
6 use base qw(Geo::TigerLine::Record::Parser Geo::TigerLine::Record::Accessor
7 Geo::TigerLine::Record Class::Data::Inheritable);
8  
9 use vars qw($VERSION);
10 $VERSION = '0.03';
11  
12  
13 # Auto-generated data dictionary.
14 my %Data_Dict = (
15 'rs_m3' => {
16 'len' => 23,
17 'beg' => 68,
18 'bv' => 'Yes',
19 'fieldnum' => 10,
20 'type' => 'N',
21 'description' => 'Reserved Space M3',
22 'end' => 90,
23 'fmt' => 'L',
24 'field' => 'rs_m3'
25 },
26 'version' => {
27 'len' => 4,
28 'beg' => 2,
29 'bv' => 'No',
30 'fieldnum' => 2,
31 'type' => 'N',
32 'description' => 'Version Number',
33 'end' => 5,
34 'fmt' => 'L',
35 'field' => 'version'
36 },
37 'idflag' => {
38 'len' => 1,
39 'beg' => 47,
40 'bv' => 'Yes',
41 'fieldnum' => 7,
42 'type' => 'A',
43 'description' => 'Identification Code Flag',
44 'end' => 47,
45 'fmt' => 'R',
46 'field' => 'idflag'
47 },
48 'tlid' => {
49 'len' => 10,
50 'beg' => 6,
51 'bv' => 'No',
52 'fieldnum' => 3,
53 'type' => 'N',
54 'description' => 'TIGER/Line ID, Permanent 1-Cell Number',
55 'end' => 15,
56 'fmt' => 'R',
57 'field' => 'tlid'
58 },
59 'sourceid' => {
60 'len' => 10,
61 'beg' => 19,
62 'bv' => 'Yes',
63 'fieldnum' => 5,
64 'type' => 'A',
65 'description' => 'TIGER 1-Cell Source Code',
66 'end' => 28,
67 'fmt' => 'L',
68 'field' => 'sourceid'
69 },
70 'rtsq' => {
71 'len' => 3,
72 'beg' => 16,
73 'bv' => 'No',
74 'fieldnum' => 4,
75 'type' => 'N',
76 'description' => 'Record Sequence Number',
77 'end' => 18,
78 'fmt' => 'R',
79 'field' => 'rtsq'
80 },
81 'rs_m1' => {
82 'len' => 18,
83 'beg' => 48,
84 'bv' => 'Yes',
85 'fieldnum' => 8,
86 'type' => 'N',
87 'description' => 'Reserved Space M1',
88 'end' => 65,
89 'fmt' => 'L',
90 'field' => 'rs_m1'
91 },
92 'rt' => {
93 'len' => 1,
94 'beg' => 1,
95 'bv' => 'No',
96 'fieldnum' => 1,
97 'type' => 'A',
98 'description' => 'Record Type',
99 'end' => 1,
100 'fmt' => 'L',
101 'field' => 'rt'
102 },
103 'id' => {
104 'len' => 18,
105 'beg' => 29,
106 'bv' => 'Yes',
107 'fieldnum' => 6,
108 'type' => 'A',
109 'description' => 'Identification Code',
110 'end' => 46,
111 'fmt' => 'L',
112 'field' => 'id'
113 },
114 'rs_m2' => {
115 'len' => 2,
116 'beg' => 66,
117 'bv' => 'Yes',
118 'fieldnum' => 9,
119 'type' => 'A',
120 'description' => 'Reserved Space M2',
121 'end' => 67,
122 'fmt' => 'L',
123 'field' => 'rs_m2'
124 }
125 );
126  
127  
128 my @Data_Fields = (
129 'rt',
130 'version',
131 'tlid',
132 'rtsq',
133 'sourceid',
134 'id',
135 'idflag',
136 'rs_m1',
137 'rs_m2',
138 'rs_m3'
139 );
140  
141  
142 assert(keys %Data_Dict == @Data_Fields);
143  
144 # Turn the data dictionary into class data
145 __PACKAGE__->mk_classdata('Fields');
146 __PACKAGE__->mk_classdata('Dict');
147 __PACKAGE__->mk_classdata('Pack_Tmpl');
148  
149 __PACKAGE__->Dict(\%Data_Dict);
150 __PACKAGE__->Fields(\@Data_Fields);
151  
152 # Generate a pack template for parsing and turn it into class data.
153 my $pack_tmpl = join ' ', map { "A$_" } map { $_->{len} }
154 @Data_Dict{@Data_Fields};
155 __PACKAGE__->Pack_Tmpl($pack_tmpl);
156  
157 # Generate accessors for each data field
158 foreach my $def (@Data_Dict{@Data_Fields}) {
159 __PACKAGE__->mk_accessor($def);
160 }
161  
162  
163 =pod
164  
165 =head1 NAME
166  
167 Geo::TigerLine::Record::M - TIGER/Line 2006 Feature Spatial Metadata Record
168  
169 =head1 SYNOPSIS
170  
171 use Geo::TigerLine::Record::M;
172  
173 @records = Geo::TigerLine::Record::M->parse_file($fh);
174 @records = Geo::TigerLine::Record::M->parse_file($fh, \&callback);
175  
176 $record = Geo::TigerLine::Record::M->new(\%fields);
177  
178 $record->rt();
179 $record->version();
180 $record->tlid();
181 $record->rtsq();
182 $record->sourceid();
183 $record->id();
184 $record->idflag();
185 $record->rs_m1();
186 $record->rs_m2();
187 $record->rs_m3();
188  
189  
190 =head1 DESCRIPTION
191  
192 This is a class representing record type M of the TIGER/Line 2006
193 census geographic database. Each object is one record. It also
194 contains methods to parse TIGER/Line record type M files and turn them
195 into objects.
196  
197 This is intended as an intermediate format between pulling the raw
198 data out of the simplistic TIGER/Line data files into something more
199 sophisticated (a process you should only have to do once). As such,
200 it's not very fast, but its careful, easy to use and performs some
201 verifications on the data being read.
202  
203 As this class is autogenerated by mk_parsers, think before you modify this
204 file. It's OO, so consider sub-classing instead.
205  
206  
207 =head2 Accessors
208  
209 These are simple get/set accessors for each field of a record
210 generated from the TIGER/Line 2006 data dictionary. They perform some
211 data validation.
212  
213 =over 4
214  
215 =item B<rt>
216  
217 $data = $record->rt();
218 $record->rt($data);
219  
220 Record Type.
221  
222 Expects alphanumeric data of no more than 1 characters. $data cannot be blank
223 and should be left justified.
224  
225  
226 =item B<version>
227  
228 $data = $record->version();
229 $record->version($data);
230  
231 Version Number.
232  
233 Expects numeric data of no more than 4 characters. $data cannot be blank
234 and should be left justified.
235  
236  
237 =item B<tlid>
238  
239 $data = $record->tlid();
240 $record->tlid($data);
241  
242 TIGER/Line ID, Permanent 1-Cell Number.
243  
244 Expects numeric data of no more than 10 characters. $data cannot be blank
245 and should be right justified.
246  
247  
248 =item B<rtsq>
249  
250 $data = $record->rtsq();
251 $record->rtsq($data);
252  
253 Record Sequence Number.
254  
255 Expects numeric data of no more than 3 characters. $data cannot be blank
256 and should be right justified.
257  
258  
259 =item B<sourceid>
260  
261 $data = $record->sourceid();
262 $record->sourceid($data);
263  
264 TIGER 1-Cell Source Code.
265  
266 Expects alphanumeric data of no more than 10 characters. $data can be blank
267 and should be left justified.
268  
269  
270 =item B<id>
271  
272 $data = $record->id();
273 $record->id($data);
274  
275 Identification Code.
276  
277 Expects alphanumeric data of no more than 18 characters. $data can be blank
278 and should be left justified.
279  
280  
281 =item B<idflag>
282  
283 $data = $record->idflag();
284 $record->idflag($data);
285  
286 Identification Code Flag.
287  
288 Expects alphanumeric data of no more than 1 characters. $data can be blank
289 and should be right justified.
290  
291  
292 =item B<rs_m1>
293  
294 $data = $record->rs_m1();
295 $record->rs_m1($data);
296  
297 Reserved Space M1.
298  
299 Expects numeric data of no more than 18 characters. $data can be blank
300 and should be left justified.
301  
302  
303 =item B<rs_m2>
304  
305 $data = $record->rs_m2();
306 $record->rs_m2($data);
307  
308 Reserved Space M2.
309  
310 Expects alphanumeric data of no more than 2 characters. $data can be blank
311 and should be left justified.
312  
313  
314 =item B<rs_m3>
315  
316 $data = $record->rs_m3();
317 $record->rs_m3($data);
318  
319 Reserved Space M3.
320  
321 Expects numeric data of no more than 23 characters. $data can be blank
322 and should be left justified.
323  
324  
325  
326 =back
327  
328  
329 =head2 Data dictionary
330  
331 This is the original TIGER/Line 2006 data dictionary from which this
332 class was generated.
333  
334 Record Type M - Feature Spatial Metadata Record
335
336 Field BV Fmt Type Beg End Len Description
337 RT No L A 1 1 1 Record Type
338 VERSION No L N 2 5 4 Version Number
339 TLID No R N 6 15 10 TIGER/Line ID, Permanent 1-Cell Number
340 RTSQ No R N 16 18 3 Record Sequence Number
341 SOURCEID Yes L A 19 28 10 TIGER 1-Cell Source Code
342 ID Yes L A 29 46 18 Identification Code
343 IDFLAG Yes R A 47 47 1 Identification Code Flag
344 RS-M1 Yes L N 48 65 18 Reserved Space M1
345 RS-M2 Yes L A 66 67 2 Reserved Space M2
346 RS-M3 Yes L N 68 90 23 Reserved Space M3
347  
348  
349  
350 =head1 AUTHOR
351  
352 Michael G Schwern <schwern@pobox.com>
353  
354 =head1 SEE ALSO
355  
356 L<Geo::TigerLine>, L<mk_parsers>
357  
358 =cut
359  
360  
361 return 'Honey flash!';