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