TigerLine/Record/2.pm untested

filter: Statementstmt 0.0% 0 / 52 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 56 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::2;
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 'long1' => {
16 'len' => 10,
17 'beg' => 19,
18 'bv' => 'No',
19 'fieldnum' => 5,
20 'type' => 'N',
21 'description' => 'Point 1, Longitude',
22 'end' => 28,
23 'fmt' => 'R',
24 'field' => 'long1'
25 },
26 'long8' => {
27 'len' => 10,
28 'beg' => 152,
29 'bv' => 'Yes',
30 'fieldnum' => 19,
31 'type' => 'N',
32 'description' => 'Point 8, Longitude',
33 'end' => 161,
34 'fmt' => 'R',
35 'field' => 'long8'
36 },
37 'long4' => {
38 'len' => 10,
39 'beg' => 76,
40 'bv' => 'Yes',
41 'fieldnum' => 11,
42 'type' => 'N',
43 'description' => 'Point 4, Longitude',
44 'end' => 85,
45 'fmt' => 'R',
46 'field' => 'long4'
47 },
48 'lat5' => {
49 'len' => 9,
50 'beg' => 105,
51 'bv' => 'Yes',
52 'fieldnum' => 14,
53 'type' => 'N',
54 'description' => 'Point 5, Latitude',
55 'end' => 113,
56 'fmt' => 'R',
57 'field' => 'lat5'
58 },
59 'long9' => {
60 'len' => 10,
61 'beg' => 171,
62 'bv' => 'Yes',
63 'fieldnum' => 21,
64 'type' => 'N',
65 'description' => 'Point 9, Longitude',
66 'end' => 180,
67 'fmt' => 'R',
68 'field' => 'long9'
69 },
70 'lat8' => {
71 'len' => 9,
72 'beg' => 162,
73 'bv' => 'Yes',
74 'fieldnum' => 20,
75 'type' => 'N',
76 'description' => 'Point 8, Latitude',
77 'end' => 170,
78 'fmt' => 'R',
79 'field' => 'lat8'
80 },
81 'long7' => {
82 'len' => 10,
83 'beg' => 133,
84 'bv' => 'Yes',
85 'fieldnum' => 17,
86 'type' => 'N',
87 'description' => 'Point 7, Longitude',
88 'end' => 142,
89 'fmt' => 'R',
90 'field' => 'long7'
91 },
92 'lat4' => {
93 'len' => 9,
94 'beg' => 86,
95 'bv' => 'Yes',
96 'fieldnum' => 12,
97 'type' => 'N',
98 'description' => 'Point 4, Latitude',
99 'end' => 94,
100 'fmt' => 'R',
101 'field' => 'lat4'
102 },
103 'rt' => {
104 'len' => 1,
105 'beg' => 1,
106 'bv' => 'No',
107 'fieldnum' => 1,
108 'type' => 'A',
109 'description' => 'Record Type',
110 'end' => 1,
111 'fmt' => 'L',
112 'field' => 'rt'
113 },
114 'lat6' => {
115 'len' => 9,
116 'beg' => 124,
117 'bv' => 'Yes',
118 'fieldnum' => 16,
119 'type' => 'N',
120 'description' => 'Point 6, Latitude',
121 'end' => 132,
122 'fmt' => 'R',
123 'field' => 'lat6'
124 },
125 'lat7' => {
126 'len' => 9,
127 'beg' => 143,
128 'bv' => 'Yes',
129 'fieldnum' => 18,
130 'type' => 'N',
131 'description' => 'Point 7, Latitude',
132 'end' => 151,
133 'fmt' => 'R',
134 'field' => 'lat7'
135 },
136 'long6' => {
137 'len' => 10,
138 'beg' => 114,
139 'bv' => 'Yes',
140 'fieldnum' => 15,
141 'type' => 'N',
142 'description' => 'Point 6, Longitude',
143 'end' => 123,
144 'fmt' => 'R',
145 'field' => 'long6'
146 },
147 'long5' => {
148 'len' => 10,
149 'beg' => 95,
150 'bv' => 'Yes',
151 'fieldnum' => 13,
152 'type' => 'N',
153 'description' => 'Point 5, Longitude',
154 'end' => 104,
155 'fmt' => 'R',
156 'field' => 'long5'
157 },
158 'version' => {
159 'len' => 4,
160 'beg' => 2,
161 'bv' => 'No',
162 'fieldnum' => 2,
163 'type' => 'N',
164 'description' => 'Version Number',
165 'end' => 5,
166 'fmt' => 'L',
167 'field' => 'version'
168 },
169 'lat2' => {
170 'len' => 9,
171 'beg' => 48,
172 'bv' => 'Yes',
173 'fieldnum' => 8,
174 'type' => 'N',
175 'description' => 'Point 2, Latitude',
176 'end' => 56,
177 'fmt' => 'R',
178 'field' => 'lat2'
179 },
180 'long10' => {
181 'len' => 10,
182 'beg' => 190,
183 'bv' => 'Yes',
184 'fieldnum' => 23,
185 'type' => 'N',
186 'description' => 'Point 10, Longitude',
187 'end' => 199,
188 'fmt' => 'R',
189 'field' => 'long10'
190 },
191 'lat9' => {
192 'len' => 9,
193 'beg' => 181,
194 'bv' => 'Yes',
195 'fieldnum' => 22,
196 'type' => 'N',
197 'description' => 'Point 9, Latitude',
198 'end' => 189,
199 'fmt' => 'R',
200 'field' => 'lat9'
201 },
202 'lat10' => {
203 'len' => 9,
204 'beg' => 200,
205 'bv' => 'Yes',
206 'fieldnum' => 24,
207 'type' => 'N',
208 'description' => 'Point 10, Latitude',
209 'end' => 208,
210 'fmt' => 'R',
211 'field' => 'lat10'
212 },
213 'long2' => {
214 'len' => 10,
215 'beg' => 38,
216 'bv' => 'Yes',
217 'fieldnum' => 7,
218 'type' => 'N',
219 'description' => 'Point 2, Longitude',
220 'end' => 47,
221 'fmt' => 'R',
222 'field' => 'long2'
223 },
224 'lat1' => {
225 'len' => 9,
226 'beg' => 29,
227 'bv' => 'No',
228 'fieldnum' => 6,
229 'type' => 'N',
230 'description' => 'Point 1, Latitude',
231 'end' => 37,
232 'fmt' => 'R',
233 'field' => 'lat1'
234 },
235 'tlid' => {
236 'len' => 10,
237 'beg' => 6,
238 'bv' => 'No',
239 'fieldnum' => 3,
240 'type' => 'N',
241 'description' => 'TIGER/Line ID, Permanent 1-Cell Number',
242 'end' => 15,
243 'fmt' => 'R',
244 'field' => 'tlid'
245 },
246 'rtsq' => {
247 'len' => 3,
248 'beg' => 16,
249 'bv' => 'No',
250 'fieldnum' => 4,
251 'type' => 'N',
252 'description' => 'Record Sequence Number',
253 'end' => 18,
254 'fmt' => 'R',
255 'field' => 'rtsq'
256 },
257 'lat3' => {
258 'len' => 9,
259 'beg' => 67,
260 'bv' => 'Yes',
261 'fieldnum' => 10,
262 'type' => 'N',
263 'description' => 'Point 3, Latitude',
264 'end' => 75,
265 'fmt' => 'R',
266 'field' => 'lat3'
267 },
268 'long3' => {
269 'len' => 10,
270 'beg' => 57,
271 'bv' => 'Yes',
272 'fieldnum' => 9,
273 'type' => 'N',
274 'description' => 'Point 3, Longitude',
275 'end' => 66,
276 'fmt' => 'R',
277 'field' => 'long3'
278 }
279 );
280  
281  
282 my @Data_Fields = (
283 'rt',
284 'version',
285 'tlid',
286 'rtsq',
287 'long1',
288 'lat1',
289 'long2',
290 'lat2',
291 'long3',
292 'lat3',
293 'long4',
294 'lat4',
295 'long5',
296 'lat5',
297 'long6',
298 'lat6',
299 'long7',
300 'lat7',
301 'long8',
302 'lat8',
303 'long9',
304 'lat9',
305 'long10',
306 'lat10'
307 );
308  
309  
310 assert(keys %Data_Dict == @Data_Fields);
311  
312 # Turn the data dictionary into class data
313 __PACKAGE__->mk_classdata('Fields');
314 __PACKAGE__->mk_classdata('Dict');
315 __PACKAGE__->mk_classdata('Pack_Tmpl');
316  
317 __PACKAGE__->Dict(\%Data_Dict);
318 __PACKAGE__->Fields(\@Data_Fields);
319  
320 # Generate a pack template for parsing and turn it into class data.
321 my $pack_tmpl = join ' ', map { "A$_" } map { $_->{len} }
322 @Data_Dict{@Data_Fields};
323 __PACKAGE__->Pack_Tmpl($pack_tmpl);
324  
325 # Generate accessors for each data field
326 foreach my $def (@Data_Dict{@Data_Fields}) {
327 __PACKAGE__->mk_accessor($def);
328 }
329  
330  
331 =pod
332  
333 =head1 NAME
334  
335 Geo::TigerLine::Record::2 - TIGER/Line 2006 Complete Chain Shape Coordinates
336  
337 =head1 SYNOPSIS
338  
339 use Geo::TigerLine::Record::2;
340  
341 @records = Geo::TigerLine::Record::2->parse_file($fh);
342 @records = Geo::TigerLine::Record::2->parse_file($fh, \&callback);
343  
344 $record = Geo::TigerLine::Record::2->new(\%fields);
345  
346 $record->rt();
347 $record->version();
348 $record->tlid();
349 $record->rtsq();
350 $record->long1();
351 $record->lat1();
352 $record->long2();
353 $record->lat2();
354 $record->long3();
355 $record->lat3();
356 $record->long4();
357 $record->lat4();
358 $record->long5();
359 $record->lat5();
360 $record->long6();
361 $record->lat6();
362 $record->long7();
363 $record->lat7();
364 $record->long8();
365 $record->lat8();
366 $record->long9();
367 $record->lat9();
368 $record->long10();
369 $record->lat10();
370  
371  
372 =head1 DESCRIPTION
373  
374 This is a class representing record type 2 of the TIGER/Line 2006
375 census geographic database. Each object is one record. It also
376 contains methods to parse TIGER/Line record type 2 files and turn them
377 into objects.
378  
379 This is intended as an intermediate format between pulling the raw
380 data out of the simplistic TIGER/Line data files into something more
381 sophisticated (a process you should only have to do once). As such,
382 it's not very fast, but its careful, easy to use and performs some
383 verifications on the data being read.
384  
385 As this class is autogenerated by mk_parsers, think before you modify this
386 file. It's OO, so consider sub-classing instead.
387  
388  
389 =head2 Accessors
390  
391 These are simple get/set accessors for each field of a record
392 generated from the TIGER/Line 2006 data dictionary. They perform some
393 data validation.
394  
395 =over 4
396  
397 =item B<rt>
398  
399 $data = $record->rt();
400 $record->rt($data);
401  
402 Record Type.
403  
404 Expects alphanumeric data of no more than 1 characters. $data cannot be blank
405 and should be left justified.
406  
407  
408 =item B<version>
409  
410 $data = $record->version();
411 $record->version($data);
412  
413 Version Number.
414  
415 Expects numeric data of no more than 4 characters. $data cannot be blank
416 and should be left justified.
417  
418  
419 =item B<tlid>
420  
421 $data = $record->tlid();
422 $record->tlid($data);
423  
424 TIGER/Line ID, Permanent 1-Cell Number.
425  
426 Expects numeric data of no more than 10 characters. $data cannot be blank
427 and should be right justified.
428  
429  
430 =item B<rtsq>
431  
432 $data = $record->rtsq();
433 $record->rtsq($data);
434  
435 Record Sequence Number.
436  
437 Expects numeric data of no more than 3 characters. $data cannot be blank
438 and should be right justified.
439  
440  
441 =item B<long1>
442  
443 $data = $record->long1();
444 $record->long1($data);
445  
446 Point 1, Longitude.
447  
448 Expects numeric data of no more than 10 characters. $data cannot be blank
449 and should be right justified.
450  
451  
452 =item B<lat1>
453  
454 $data = $record->lat1();
455 $record->lat1($data);
456  
457 Point 1, Latitude.
458  
459 Expects numeric data of no more than 9 characters. $data cannot be blank
460 and should be right justified.
461  
462  
463 =item B<long2>
464  
465 $data = $record->long2();
466 $record->long2($data);
467  
468 Point 2, Longitude.
469  
470 Expects numeric data of no more than 10 characters. $data can be blank
471 and should be right justified.
472  
473  
474 =item B<lat2>
475  
476 $data = $record->lat2();
477 $record->lat2($data);
478  
479 Point 2, Latitude.
480  
481 Expects numeric data of no more than 9 characters. $data can be blank
482 and should be right justified.
483  
484  
485 =item B<long3>
486  
487 $data = $record->long3();
488 $record->long3($data);
489  
490 Point 3, Longitude.
491  
492 Expects numeric data of no more than 10 characters. $data can be blank
493 and should be right justified.
494  
495  
496 =item B<lat3>
497  
498 $data = $record->lat3();
499 $record->lat3($data);
500  
501 Point 3, Latitude.
502  
503 Expects numeric data of no more than 9 characters. $data can be blank
504 and should be right justified.
505  
506  
507 =item B<long4>
508  
509 $data = $record->long4();
510 $record->long4($data);
511  
512 Point 4, Longitude.
513  
514 Expects numeric data of no more than 10 characters. $data can be blank
515 and should be right justified.
516  
517  
518 =item B<lat4>
519  
520 $data = $record->lat4();
521 $record->lat4($data);
522  
523 Point 4, Latitude.
524  
525 Expects numeric data of no more than 9 characters. $data can be blank
526 and should be right justified.
527  
528  
529 =item B<long5>
530  
531 $data = $record->long5();
532 $record->long5($data);
533  
534 Point 5, Longitude.
535  
536 Expects numeric data of no more than 10 characters. $data can be blank
537 and should be right justified.
538  
539  
540 =item B<lat5>
541  
542 $data = $record->lat5();
543 $record->lat5($data);
544  
545 Point 5, Latitude.
546  
547 Expects numeric data of no more than 9 characters. $data can be blank
548 and should be right justified.
549  
550  
551 =item B<long6>
552  
553 $data = $record->long6();
554 $record->long6($data);
555  
556 Point 6, Longitude.
557  
558 Expects numeric data of no more than 10 characters. $data can be blank
559 and should be right justified.
560  
561  
562 =item B<lat6>
563  
564 $data = $record->lat6();
565 $record->lat6($data);
566  
567 Point 6, Latitude.
568  
569 Expects numeric data of no more than 9 characters. $data can be blank
570 and should be right justified.
571  
572  
573 =item B<long7>
574  
575 $data = $record->long7();
576 $record->long7($data);
577  
578 Point 7, Longitude.
579  
580 Expects numeric data of no more than 10 characters. $data can be blank
581 and should be right justified.
582  
583  
584 =item B<lat7>
585  
586 $data = $record->lat7();
587 $record->lat7($data);
588  
589 Point 7, Latitude.
590  
591 Expects numeric data of no more than 9 characters. $data can be blank
592 and should be right justified.
593  
594  
595 =item B<long8>
596  
597 $data = $record->long8();
598 $record->long8($data);
599  
600 Point 8, Longitude.
601  
602 Expects numeric data of no more than 10 characters. $data can be blank
603 and should be right justified.
604  
605  
606 =item B<lat8>
607  
608 $data = $record->lat8();
609 $record->lat8($data);
610  
611 Point 8, Latitude.
612  
613 Expects numeric data of no more than 9 characters. $data can be blank
614 and should be right justified.
615  
616  
617 =item B<long9>
618  
619 $data = $record->long9();
620 $record->long9($data);
621  
622 Point 9, Longitude.
623  
624 Expects numeric data of no more than 10 characters. $data can be blank
625 and should be right justified.
626  
627  
628 =item B<lat9>
629  
630 $data = $record->lat9();
631 $record->lat9($data);
632  
633 Point 9, Latitude.
634  
635 Expects numeric data of no more than 9 characters. $data can be blank
636 and should be right justified.
637  
638  
639 =item B<long10>
640  
641 $data = $record->long10();
642 $record->long10($data);
643  
644 Point 10, Longitude.
645  
646 Expects numeric data of no more than 10 characters. $data can be blank
647 and should be right justified.
648  
649  
650 =item B<lat10>
651  
652 $data = $record->lat10();
653 $record->lat10($data);
654  
655 Point 10, Latitude.
656  
657 Expects numeric data of no more than 9 characters. $data can be blank
658 and should be right justified.
659  
660  
661  
662 =back
663  
664  
665 =head2 Data dictionary
666  
667 This is the original TIGER/Line 2006 data dictionary from which this
668 class was generated.
669  
670 Record Type 2 - Complete Chain Shape Coordinates
671
672 Field BV Fmt Type Beg End Len Description
673 RT No L A 1 1 1 Record Type
674 VERSION No L N 2 5 4 Version Number
675 TLID No R N 6 15 10 TIGER/Line ID, Permanent 1-Cell Number
676 RTSQ No R N 16 18 3 Record Sequence Number
677 LONG1 No R N 19 28 10 Point 1, Longitude
678 LAT1 No R N 29 37 9 Point 1, Latitude
679 LONG2 Yes R N 38 47 10 Point 2, Longitude
680 LAT2 Yes R N 48 56 9 Point 2, Latitude
681 LONG3 Yes R N 57 66 10 Point 3, Longitude
682 LAT3 Yes R N 67 75 9 Point 3, Latitude
683 LONG4 Yes R N 76 85 10 Point 4, Longitude
684 LAT4 Yes R N 86 94 9 Point 4, Latitude
685 LONG5 Yes R N 95 104 10 Point 5, Longitude
686 LAT5 Yes R N 105 113 9 Point 5, Latitude
687 LONG6 Yes R N 114 123 10 Point 6, Longitude
688 LAT6 Yes R N 124 132 9 Point 6, Latitude
689 LONG7 Yes R N 133 142 10 Point 7, Longitude
690 LAT7 Yes R N 143 151 9 Point 7, Latitude
691 LONG8 Yes R N 152 161 10 Point 8, Longitude
692 LAT8 Yes R N 162 170 9 Point 8, Latitude
693 LONG9 Yes R N 171 180 10 Point 9, Longitude
694 LAT9 Yes R N 181 189 9 Point 9, Latitude
695 LONG10 Yes R N 190 199 10 Point 10, Longitude
696 LAT10 Yes R N 200 208 9 Point 10, Latitude
697
698  
699  
700  
701 =head1 AUTHOR
702  
703 Michael G Schwern <schwern@pobox.com>
704  
705 =head1 SEE ALSO
706  
707 L<Geo::TigerLine>, L<mk_parsers>
708  
709 =cut
710  
711  
712 return 'Honey flash!';