| 1 | package Geo::TigerLine::Record::T; | ||
| 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 | 'source' => { | ||
| 16 | 'len' => 10, | ||
| 17 | 'beg' => 21, | ||
| 18 | 'bv' => 'Yes', | ||
| 19 | 'fieldnum' => 5, | ||
| 20 | 'type' => 'A', | ||
| 21 | 'description' => 'TIGER Zero-Cell Source Code (not filled)', | ||
| 22 | 'end' => 30, | ||
| 23 | 'fmt' => 'L', | ||
| 24 | 'field' => 'source' | ||
| 25 | }, | ||
| 26 | 'tzid' => { | ||
| 27 | 'len' => 10, | ||
| 28 | 'beg' => 11, | ||
| 29 | 'bv' => 'No', | ||
| 30 | 'fieldnum' => 4, | ||
| 31 | 'type' => 'N', | ||
| 32 | 'description' => 'TIGER Zero-Cell ID, Permanent Zero-Cell Number', | ||
| 33 | 'end' => 20, | ||
| 34 | 'fmt' => 'R', | ||
| 35 | 'field' => 'tzid' | ||
| 36 | }, | ||
| 37 | 'version' => { | ||
| 38 | 'len' => 4, | ||
| 39 | 'beg' => 2, | ||
| 40 | 'bv' => 'No', | ||
| 41 | 'fieldnum' => 2, | ||
| 42 | 'type' => 'N', | ||
| 43 | 'description' => 'Version Number', | ||
| 44 | 'end' => 5, | ||
| 45 | 'fmt' => 'L', | ||
| 46 | 'field' => 'version' | ||
| 47 | }, | ||
| 48 | 'file' => { | ||
| 49 | 'len' => 5, | ||
| 50 | 'beg' => 6, | ||
| 51 | 'bv' => 'No', | ||
| 52 | 'fieldnum' => 3, | ||
| 53 | 'type' => 'N', | ||
| 54 | 'description' => 'File Code', | ||
| 55 | 'end' => 10, | ||
| 56 | 'fmt' => 'L', | ||
| 57 | 'field' => 'file' | ||
| 58 | }, | ||
| 59 | 'rt' => { | ||
| 60 | 'len' => 1, | ||
| 61 | 'beg' => 1, | ||
| 62 | 'bv' => 'No', | ||
| 63 | 'fieldnum' => 1, | ||
| 64 | 'type' => 'A', | ||
| 65 | 'description' => 'Record Type', | ||
| 66 | 'end' => 1, | ||
| 67 | 'fmt' => 'L', | ||
| 68 | 'field' => 'rt' | ||
| 69 | }, | ||
| 70 | 'ftrp' => { | ||
| 71 | 'len' => 17, | ||
| 72 | 'beg' => 31, | ||
| 73 | 'bv' => 'Yes', | ||
| 74 | 'fieldnum' => 6, | ||
| 75 | 'type' => 'A', | ||
| 76 | 'description' => 'FTRP ID (AAAAA.O.XXXXXXXXX) (Authority-P-ID) FGDC Transportation ID Standard (not filled)', | ||
| 77 | 'end' => 47, | ||
| 78 | 'fmt' => 'L', | ||
| 79 | 'field' => 'ftrp' | ||
| 80 | } | ||
| 81 | ); | ||
| 82 | |||
| 83 | |||
| 84 | my @Data_Fields = ( | ||
| 85 | 'rt', | ||
| 86 | 'version', | ||
| 87 | 'file', | ||
| 88 | 'tzid', | ||
| 89 | 'source', | ||
| 90 | 'ftrp' | ||
| 91 | ); | ||
| 92 | |||
| 93 | |||
| 94 | assert(keys %Data_Dict == @Data_Fields); | ||
| 95 | |||
| 96 | # Turn the data dictionary into class data | ||
| 97 | __PACKAGE__->mk_classdata('Fields'); | ||
| 98 | __PACKAGE__->mk_classdata('Dict'); | ||
| 99 | __PACKAGE__->mk_classdata('Pack_Tmpl'); | ||
| 100 | |||
| 101 | __PACKAGE__->Dict(\%Data_Dict); | ||
| 102 | __PACKAGE__->Fields(\@Data_Fields); | ||
| 103 | |||
| 104 | # Generate a pack template for parsing and turn it into class data. | ||
| 105 | my $pack_tmpl = join ' ', map { "A$_" } map { $_->{len} } | ||
| 106 | @Data_Dict{@Data_Fields}; | ||
| 107 | __PACKAGE__->Pack_Tmpl($pack_tmpl); | ||
| 108 | |||
| 109 | # Generate accessors for each data field | ||
| 110 | foreach my $def (@Data_Dict{@Data_Fields}) { | ||
| 111 | __PACKAGE__->mk_accessor($def); | ||
| 112 | } | ||
| 113 | |||
| 114 | |||
| 115 | =pod | ||
| 116 | |||
| 117 | =head1 NAME | ||
| 118 | |||
| 119 | Geo::TigerLine::Record::T - TIGER/Line 2006 TIGER Zero-Cell ID | ||
| 120 | |||
| 121 | =head1 SYNOPSIS | ||
| 122 | |||
| 123 | use Geo::TigerLine::Record::T; | ||
| 124 | |||
| 125 | @records = Geo::TigerLine::Record::T->parse_file($fh); | ||
| 126 | @records = Geo::TigerLine::Record::T->parse_file($fh, \&callback); | ||
| 127 | |||
| 128 | $record = Geo::TigerLine::Record::T->new(\%fields); | ||
| 129 | |||
| 130 | $record->rt(); | ||
| 131 | $record->version(); | ||
| 132 | $record->file(); | ||
| 133 | $record->tzid(); | ||
| 134 | $record->source(); | ||
| 135 | $record->ftrp(); | ||
| 136 | |||
| 137 | |||
| 138 | =head1 DESCRIPTION | ||
| 139 | |||
| 140 | This is a class representing record type T of the TIGER/Line 2006 | ||
| 141 | census geographic database. Each object is one record. It also | ||
| 142 | contains methods to parse TIGER/Line record type T files and turn them | ||
| 143 | into objects. | ||
| 144 | |||
| 145 | This is intended as an intermediate format between pulling the raw | ||
| 146 | data out of the simplistic TIGER/Line data files into something more | ||
| 147 | sophisticated (a process you should only have to do once). As such, | ||
| 148 | it's not very fast, but its careful, easy to use and performs some | ||
| 149 | verifications on the data being read. | ||
| 150 | |||
| 151 | As this class is autogenerated by mk_parsers, think before you modify this | ||
| 152 | file. It's OO, so consider sub-classing instead. | ||
| 153 | |||
| 154 | |||
| 155 | =head2 Accessors | ||
| 156 | |||
| 157 | These are simple get/set accessors for each field of a record | ||
| 158 | generated from the TIGER/Line 2006 data dictionary. They perform some | ||
| 159 | data validation. | ||
| 160 | |||
| 161 | =over 4 | ||
| 162 | |||
| 163 | =item B<rt> | ||
| 164 | |||
| 165 | $data = $record->rt(); | ||
| 166 | $record->rt($data); | ||
| 167 | |||
| 168 | Record Type. | ||
| 169 | |||
| 170 | Expects alphanumeric data of no more than 1 characters. $data cannot be blank | ||
| 171 | and should be left justified. | ||
| 172 | |||
| 173 | |||
| 174 | =item B<version> | ||
| 175 | |||
| 176 | $data = $record->version(); | ||
| 177 | $record->version($data); | ||
| 178 | |||
| 179 | Version Number. | ||
| 180 | |||
| 181 | Expects numeric data of no more than 4 characters. $data cannot be blank | ||
| 182 | and should be left justified. | ||
| 183 | |||
| 184 | |||
| 185 | =item B<file> | ||
| 186 | |||
| 187 | $data = $record->file(); | ||
| 188 | $record->file($data); | ||
| 189 | |||
| 190 | File Code. | ||
| 191 | |||
| 192 | Expects numeric data of no more than 5 characters. $data cannot be blank | ||
| 193 | and should be left justified. | ||
| 194 | |||
| 195 | |||
| 196 | =item B<tzid> | ||
| 197 | |||
| 198 | $data = $record->tzid(); | ||
| 199 | $record->tzid($data); | ||
| 200 | |||
| 201 | TIGER Zero-Cell ID, Permanent Zero-Cell Number. | ||
| 202 | |||
| 203 | Expects numeric data of no more than 10 characters. $data cannot be blank | ||
| 204 | and should be right justified. | ||
| 205 | |||
| 206 | |||
| 207 | =item B<source> | ||
| 208 | |||
| 209 | $data = $record->source(); | ||
| 210 | $record->source($data); | ||
| 211 | |||
| 212 | TIGER Zero-Cell Source Code (not filled). | ||
| 213 | |||
| 214 | Expects alphanumeric data of no more than 10 characters. $data can be blank | ||
| 215 | and should be left justified. | ||
| 216 | |||
| 217 | |||
| 218 | =item B<ftrp> | ||
| 219 | |||
| 220 | $data = $record->ftrp(); | ||
| 221 | $record->ftrp($data); | ||
| 222 | |||
| 223 | FTRP ID (AAAAA.O.XXXXXXXXX) (Authority-P-ID) FGDC Transportation ID Standard (not filled). | ||
| 224 | |||
| 225 | Expects alphanumeric data of no more than 17 characters. $data can be blank | ||
| 226 | and should be left justified. | ||
| 227 | |||
| 228 | |||
| 229 | |||
| 230 | =back | ||
| 231 | |||
| 232 | |||
| 233 | =head2 Data dictionary | ||
| 234 | |||
| 235 | This is the original TIGER/Line 2006 data dictionary from which this | ||
| 236 | class was generated. | ||
| 237 | |||
| 238 | Record Type T - TIGER Zero-Cell ID | ||
| 239 | |||
| 240 | Field BV Fmt Type Beg End Len Description | ||
| 241 | RT No L A 1 1 1 Record Type | ||
| 242 | VERSION No L N 2 5 4 Version Number | ||
| 243 | FILE No L N 6 10 5 File Code | ||
| 244 | TZID No R N 11 20 10 TIGER Zero-Cell ID, Permanent Zero-Cell Number | ||
| 245 | SOURCE Yes L A 21 30 10 TIGER Zero-Cell Source Code (not filled) | ||
| 246 | FTRP Yes L A 31 47 17 FTRP ID (AAAAA.O.XXXXXXXXX) (Authority-P-ID) FGDC Transportation ID Standard (not filled) | ||
| 247 | |||
| 248 | |||
| 249 | |||
| 250 | =head1 AUTHOR | ||
| 251 | |||
| 252 | Michael G Schwern <schwern@pobox.com> | ||
| 253 | |||
| 254 | =head1 SEE ALSO | ||
| 255 | |||
| 256 | L<Geo::TigerLine>, L<mk_parsers> | ||
| 257 | |||
| 258 | =cut | ||
| 259 | |||
| 260 | |||
| 261 | return 'Honey flash!'; |