| 1 | package Geo::TigerLine::Record::I; | ||
| 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 | 'polyidr' => { | ||
| 16 | 'len' => 10, | ||
| 17 | 'beg' => 61, | ||
| 18 | 'bv' => 'Yes', | ||
| 19 | 'fieldnum' => 10, | ||
| 20 | 'type' => 'N', | ||
| 21 | 'description' => 'Polygon Identification Code, Right', | ||
| 22 | 'end' => 70, | ||
| 23 | 'fmt' => 'R', | ||
| 24 | 'field' => 'polyidr' | ||
| 25 | }, | ||
| 26 | 'tzide' => { | ||
| 27 | 'len' => 10, | ||
| 28 | 'beg' => 31, | ||
| 29 | 'bv' => 'No', | ||
| 30 | 'fieldnum' => 6, | ||
| 31 | 'type' => 'N', | ||
| 32 | 'description' => 'TIGER ID, End, Permanent Zero-Cell Number', | ||
| 33 | 'end' => 40, | ||
| 34 | 'fmt' => 'R', | ||
| 35 | 'field' => 'tzide' | ||
| 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 | 'cenidr' => { | ||
| 60 | 'len' => 5, | ||
| 61 | 'beg' => 56, | ||
| 62 | 'bv' => 'Yes', | ||
| 63 | 'fieldnum' => 9, | ||
| 64 | 'type' => 'A', | ||
| 65 | 'description' => 'Census File Identification Code, Right', | ||
| 66 | 'end' => 60, | ||
| 67 | 'fmt' => 'L', | ||
| 68 | 'field' => 'cenidr' | ||
| 69 | }, | ||
| 70 | 'rs_i1' => { | ||
| 71 | 'len' => 10, | ||
| 72 | 'beg' => 98, | ||
| 73 | 'bv' => 'Yes', | ||
| 74 | 'fieldnum' => 13, | ||
| 75 | 'type' => 'A', | ||
| 76 | 'description' => 'Reserved Space I1', | ||
| 77 | 'end' => 107, | ||
| 78 | 'fmt' => 'L', | ||
| 79 | 'field' => 'rs_i1' | ||
| 80 | }, | ||
| 81 | 'cenidl' => { | ||
| 82 | 'len' => 5, | ||
| 83 | 'beg' => 41, | ||
| 84 | 'bv' => 'Yes', | ||
| 85 | 'fieldnum' => 7, | ||
| 86 | 'type' => 'A', | ||
| 87 | 'description' => 'Census File Identification Code, Left', | ||
| 88 | 'end' => 45, | ||
| 89 | 'fmt' => 'L', | ||
| 90 | 'field' => 'cenidl' | ||
| 91 | }, | ||
| 92 | 'ftseg' => { | ||
| 93 | 'len' => 17, | ||
| 94 | 'beg' => 81, | ||
| 95 | 'bv' => 'Yes', | ||
| 96 | 'fieldnum' => 12, | ||
| 97 | 'type' => 'A', | ||
| 98 | 'description' => 'FTSeg ID (AAAAA.O.XXXXXXXXX) (Authority-S-ID) FGDC Transportation ID Standard (not filled)', | ||
| 99 | 'end' => 97, | ||
| 100 | 'fmt' => 'L', | ||
| 101 | 'field' => 'ftseg' | ||
| 102 | }, | ||
| 103 | 'tlid' => { | ||
| 104 | 'len' => 10, | ||
| 105 | 'beg' => 11, | ||
| 106 | 'bv' => 'No', | ||
| 107 | 'fieldnum' => 4, | ||
| 108 | 'type' => 'N', | ||
| 109 | 'description' => 'TIGER/Line ID, Permanent 1-Cell Number', | ||
| 110 | 'end' => 20, | ||
| 111 | 'fmt' => 'R', | ||
| 112 | 'field' => 'tlid' | ||
| 113 | }, | ||
| 114 | 'rs_i3' => { | ||
| 115 | 'len' => 10, | ||
| 116 | 'beg' => 118, | ||
| 117 | 'bv' => 'Yes', | ||
| 118 | 'fieldnum' => 15, | ||
| 119 | 'type' => 'A', | ||
| 120 | 'description' => 'Reserved Space I3', | ||
| 121 | 'end' => 127, | ||
| 122 | 'fmt' => 'L', | ||
| 123 | 'field' => 'rs_i3' | ||
| 124 | }, | ||
| 125 | 'rs_i2' => { | ||
| 126 | 'len' => 10, | ||
| 127 | 'beg' => 108, | ||
| 128 | 'bv' => 'Yes', | ||
| 129 | 'fieldnum' => 14, | ||
| 130 | 'type' => 'A', | ||
| 131 | 'description' => 'Reserved Space I2', | ||
| 132 | 'end' => 117, | ||
| 133 | 'fmt' => 'L', | ||
| 134 | 'field' => 'rs_i2' | ||
| 135 | }, | ||
| 136 | 'rs_i4' => { | ||
| 137 | 'len' => 10, | ||
| 138 | 'beg' => 71, | ||
| 139 | 'bv' => 'Yes', | ||
| 140 | 'fieldnum' => 11, | ||
| 141 | 'type' => 'A', | ||
| 142 | 'description' => 'Reserved Space I-4', | ||
| 143 | 'end' => 80, | ||
| 144 | 'fmt' => 'L', | ||
| 145 | 'field' => 'rs_i4' | ||
| 146 | }, | ||
| 147 | 'tzids' => { | ||
| 148 | 'len' => 10, | ||
| 149 | 'beg' => 21, | ||
| 150 | 'bv' => 'No', | ||
| 151 | 'fieldnum' => 5, | ||
| 152 | 'type' => 'N', | ||
| 153 | 'description' => 'TIGER ID, Start, Permanent Zero-Cell Number', | ||
| 154 | 'end' => 30, | ||
| 155 | 'fmt' => 'R', | ||
| 156 | 'field' => 'tzids' | ||
| 157 | }, | ||
| 158 | 'rt' => { | ||
| 159 | 'len' => 1, | ||
| 160 | 'beg' => 1, | ||
| 161 | 'bv' => 'No', | ||
| 162 | 'fieldnum' => 1, | ||
| 163 | 'type' => 'A', | ||
| 164 | 'description' => 'Record Type', | ||
| 165 | 'end' => 1, | ||
| 166 | 'fmt' => 'L', | ||
| 167 | 'field' => 'rt' | ||
| 168 | }, | ||
| 169 | 'polyidl' => { | ||
| 170 | 'len' => 10, | ||
| 171 | 'beg' => 46, | ||
| 172 | 'bv' => 'Yes', | ||
| 173 | 'fieldnum' => 8, | ||
| 174 | 'type' => 'N', | ||
| 175 | 'description' => 'Polygon Identification Code, Left', | ||
| 176 | 'end' => 55, | ||
| 177 | 'fmt' => 'R', | ||
| 178 | 'field' => 'polyidl' | ||
| 179 | } | ||
| 180 | ); | ||
| 181 | |||
| 182 | |||
| 183 | my @Data_Fields = ( | ||
| 184 | 'rt', | ||
| 185 | 'version', | ||
| 186 | 'file', | ||
| 187 | 'tlid', | ||
| 188 | 'tzids', | ||
| 189 | 'tzide', | ||
| 190 | 'cenidl', | ||
| 191 | 'polyidl', | ||
| 192 | 'cenidr', | ||
| 193 | 'polyidr', | ||
| 194 | 'rs_i4', | ||
| 195 | 'ftseg', | ||
| 196 | 'rs_i1', | ||
| 197 | 'rs_i2', | ||
| 198 | 'rs_i3' | ||
| 199 | ); | ||
| 200 | |||
| 201 | |||
| 202 | assert(keys %Data_Dict == @Data_Fields); | ||
| 203 | |||
| 204 | # Turn the data dictionary into class data | ||
| 205 | __PACKAGE__->mk_classdata('Fields'); | ||
| 206 | __PACKAGE__->mk_classdata('Dict'); | ||
| 207 | __PACKAGE__->mk_classdata('Pack_Tmpl'); | ||
| 208 | |||
| 209 | __PACKAGE__->Dict(\%Data_Dict); | ||
| 210 | __PACKAGE__->Fields(\@Data_Fields); | ||
| 211 | |||
| 212 | # Generate a pack template for parsing and turn it into class data. | ||
| 213 | my $pack_tmpl = join ' ', map { "A$_" } map { $_->{len} } | ||
| 214 | @Data_Dict{@Data_Fields}; | ||
| 215 | __PACKAGE__->Pack_Tmpl($pack_tmpl); | ||
| 216 | |||
| 217 | # Generate accessors for each data field | ||
| 218 | foreach my $def (@Data_Dict{@Data_Fields}) { | ||
| 219 | __PACKAGE__->mk_accessor($def); | ||
| 220 | } | ||
| 221 | |||
| 222 | |||
| 223 | =pod | ||
| 224 | |||
| 225 | =head1 NAME | ||
| 226 | |||
| 227 | Geo::TigerLine::Record::I - TIGER/Line 2006 Link Between Complete Chains and Polygons | ||
| 228 | |||
| 229 | =head1 SYNOPSIS | ||
| 230 | |||
| 231 | use Geo::TigerLine::Record::I; | ||
| 232 | |||
| 233 | @records = Geo::TigerLine::Record::I->parse_file($fh); | ||
| 234 | @records = Geo::TigerLine::Record::I->parse_file($fh, \&callback); | ||
| 235 | |||
| 236 | $record = Geo::TigerLine::Record::I->new(\%fields); | ||
| 237 | |||
| 238 | $record->rt(); | ||
| 239 | $record->version(); | ||
| 240 | $record->file(); | ||
| 241 | $record->tlid(); | ||
| 242 | $record->tzids(); | ||
| 243 | $record->tzide(); | ||
| 244 | $record->cenidl(); | ||
| 245 | $record->polyidl(); | ||
| 246 | $record->cenidr(); | ||
| 247 | $record->polyidr(); | ||
| 248 | $record->rs_i4(); | ||
| 249 | $record->ftseg(); | ||
| 250 | $record->rs_i1(); | ||
| 251 | $record->rs_i2(); | ||
| 252 | $record->rs_i3(); | ||
| 253 | |||
| 254 | |||
| 255 | =head1 DESCRIPTION | ||
| 256 | |||
| 257 | This is a class representing record type I of the TIGER/Line 2006 | ||
| 258 | census geographic database. Each object is one record. It also | ||
| 259 | contains methods to parse TIGER/Line record type I files and turn them | ||
| 260 | into objects. | ||
| 261 | |||
| 262 | This is intended as an intermediate format between pulling the raw | ||
| 263 | data out of the simplistic TIGER/Line data files into something more | ||
| 264 | sophisticated (a process you should only have to do once). As such, | ||
| 265 | it's not very fast, but its careful, easy to use and performs some | ||
| 266 | verifications on the data being read. | ||
| 267 | |||
| 268 | As this class is autogenerated by mk_parsers, think before you modify this | ||
| 269 | file. It's OO, so consider sub-classing instead. | ||
| 270 | |||
| 271 | |||
| 272 | =head2 Accessors | ||
| 273 | |||
| 274 | These are simple get/set accessors for each field of a record | ||
| 275 | generated from the TIGER/Line 2006 data dictionary. They perform some | ||
| 276 | data validation. | ||
| 277 | |||
| 278 | =over 4 | ||
| 279 | |||
| 280 | =item B<rt> | ||
| 281 | |||
| 282 | $data = $record->rt(); | ||
| 283 | $record->rt($data); | ||
| 284 | |||
| 285 | Record Type. | ||
| 286 | |||
| 287 | Expects alphanumeric data of no more than 1 characters. $data cannot be blank | ||
| 288 | and should be left justified. | ||
| 289 | |||
| 290 | |||
| 291 | =item B<version> | ||
| 292 | |||
| 293 | $data = $record->version(); | ||
| 294 | $record->version($data); | ||
| 295 | |||
| 296 | Version Number. | ||
| 297 | |||
| 298 | Expects numeric data of no more than 4 characters. $data cannot be blank | ||
| 299 | and should be left justified. | ||
| 300 | |||
| 301 | |||
| 302 | =item B<file> | ||
| 303 | |||
| 304 | $data = $record->file(); | ||
| 305 | $record->file($data); | ||
| 306 | |||
| 307 | File Code. | ||
| 308 | |||
| 309 | Expects numeric data of no more than 5 characters. $data cannot be blank | ||
| 310 | and should be left justified. | ||
| 311 | |||
| 312 | |||
| 313 | =item B<tlid> | ||
| 314 | |||
| 315 | $data = $record->tlid(); | ||
| 316 | $record->tlid($data); | ||
| 317 | |||
| 318 | TIGER/Line ID, Permanent 1-Cell Number. | ||
| 319 | |||
| 320 | Expects numeric data of no more than 10 characters. $data cannot be blank | ||
| 321 | and should be right justified. | ||
| 322 | |||
| 323 | |||
| 324 | =item B<tzids> | ||
| 325 | |||
| 326 | $data = $record->tzids(); | ||
| 327 | $record->tzids($data); | ||
| 328 | |||
| 329 | TIGER ID, Start, Permanent Zero-Cell Number. | ||
| 330 | |||
| 331 | Expects numeric data of no more than 10 characters. $data cannot be blank | ||
| 332 | and should be right justified. | ||
| 333 | |||
| 334 | |||
| 335 | =item B<tzide> | ||
| 336 | |||
| 337 | $data = $record->tzide(); | ||
| 338 | $record->tzide($data); | ||
| 339 | |||
| 340 | TIGER ID, End, Permanent Zero-Cell Number. | ||
| 341 | |||
| 342 | Expects numeric data of no more than 10 characters. $data cannot be blank | ||
| 343 | and should be right justified. | ||
| 344 | |||
| 345 | |||
| 346 | =item B<cenidl> | ||
| 347 | |||
| 348 | $data = $record->cenidl(); | ||
| 349 | $record->cenidl($data); | ||
| 350 | |||
| 351 | Census File Identification Code, Left. | ||
| 352 | |||
| 353 | Expects alphanumeric data of no more than 5 characters. $data can be blank | ||
| 354 | and should be left justified. | ||
| 355 | |||
| 356 | |||
| 357 | =item B<polyidl> | ||
| 358 | |||
| 359 | $data = $record->polyidl(); | ||
| 360 | $record->polyidl($data); | ||
| 361 | |||
| 362 | Polygon Identification Code, Left. | ||
| 363 | |||
| 364 | Expects numeric data of no more than 10 characters. $data can be blank | ||
| 365 | and should be right justified. | ||
| 366 | |||
| 367 | |||
| 368 | =item B<cenidr> | ||
| 369 | |||
| 370 | $data = $record->cenidr(); | ||
| 371 | $record->cenidr($data); | ||
| 372 | |||
| 373 | Census File Identification Code, Right. | ||
| 374 | |||
| 375 | Expects alphanumeric data of no more than 5 characters. $data can be blank | ||
| 376 | and should be left justified. | ||
| 377 | |||
| 378 | |||
| 379 | =item B<polyidr> | ||
| 380 | |||
| 381 | $data = $record->polyidr(); | ||
| 382 | $record->polyidr($data); | ||
| 383 | |||
| 384 | Polygon Identification Code, Right. | ||
| 385 | |||
| 386 | Expects numeric data of no more than 10 characters. $data can be blank | ||
| 387 | and should be right justified. | ||
| 388 | |||
| 389 | |||
| 390 | =item B<rs_i4> | ||
| 391 | |||
| 392 | $data = $record->rs_i4(); | ||
| 393 | $record->rs_i4($data); | ||
| 394 | |||
| 395 | Reserved Space I-4. | ||
| 396 | |||
| 397 | Expects alphanumeric data of no more than 10 characters. $data can be blank | ||
| 398 | and should be left justified. | ||
| 399 | |||
| 400 | |||
| 401 | =item B<ftseg> | ||
| 402 | |||
| 403 | $data = $record->ftseg(); | ||
| 404 | $record->ftseg($data); | ||
| 405 | |||
| 406 | FTSeg ID (AAAAA.O.XXXXXXXXX) (Authority-S-ID) FGDC Transportation ID Standard (not filled). | ||
| 407 | |||
| 408 | Expects alphanumeric data of no more than 17 characters. $data can be blank | ||
| 409 | and should be left justified. | ||
| 410 | |||
| 411 | |||
| 412 | =item B<rs_i1> | ||
| 413 | |||
| 414 | $data = $record->rs_i1(); | ||
| 415 | $record->rs_i1($data); | ||
| 416 | |||
| 417 | Reserved Space I1. | ||
| 418 | |||
| 419 | Expects alphanumeric data of no more than 10 characters. $data can be blank | ||
| 420 | and should be left justified. | ||
| 421 | |||
| 422 | |||
| 423 | =item B<rs_i2> | ||
| 424 | |||
| 425 | $data = $record->rs_i2(); | ||
| 426 | $record->rs_i2($data); | ||
| 427 | |||
| 428 | Reserved Space I2. | ||
| 429 | |||
| 430 | Expects alphanumeric data of no more than 10 characters. $data can be blank | ||
| 431 | and should be left justified. | ||
| 432 | |||
| 433 | |||
| 434 | =item B<rs_i3> | ||
| 435 | |||
| 436 | $data = $record->rs_i3(); | ||
| 437 | $record->rs_i3($data); | ||
| 438 | |||
| 439 | Reserved Space I3. | ||
| 440 | |||
| 441 | Expects alphanumeric data of no more than 10 characters. $data can be blank | ||
| 442 | and should be left justified. | ||
| 443 | |||
| 444 | |||
| 445 | |||
| 446 | =back | ||
| 447 | |||
| 448 | |||
| 449 | =head2 Data dictionary | ||
| 450 | |||
| 451 | This is the original TIGER/Line 2006 data dictionary from which this | ||
| 452 | class was generated. | ||
| 453 | |||
| 454 | Record Type I - Link Between Complete Chains and Polygons | ||
| 455 | |||
| 456 | Field BV Fmt Type Beg End Len Description | ||
| 457 | RT No L A 1 1 1 Record Type | ||
| 458 | VERSION No L N 2 5 4 Version Number | ||
| 459 | FILE No L N 6 10 5 File Code | ||
| 460 | TLID No R N 11 20 10 TIGER/Line ID, Permanent 1-Cell Number | ||
| 461 | TZIDS No R N 21 30 10 TIGER ID, Start, Permanent Zero-Cell Number | ||
| 462 | TZIDE No R N 31 40 10 TIGER ID, End, Permanent Zero-Cell Number | ||
| 463 | CENIDL Yes L A 41 45 5 Census File Identification Code, Left | ||
| 464 | POLYIDL Yes R N 46 55 10 Polygon Identification Code, Left | ||
| 465 | CENIDR Yes L A 56 60 5 Census File Identification Code, Right | ||
| 466 | POLYIDR Yes R N 61 70 10 Polygon Identification Code, Right | ||
| 467 | RS-I4 Yes L A 71 80 10 Reserved Space I-4 | ||
| 468 | FTSEG Yes L A 81 97 17 FTSeg ID (AAAAA.O.XXXXXXXXX) (Authority-S-ID) FGDC Transportation ID Standard (not filled) | ||
| 469 | RS-I1 Yes L A 98 107 10 Reserved Space I1 | ||
| 470 | RS-I2 Yes L A 108 117 10 Reserved Space I2 | ||
| 471 | RS-I3 Yes L A 118 127 10 Reserved Space I3 | ||
| 472 | |||
| 473 | |||
| 474 | |||
| 475 | =head1 AUTHOR | ||
| 476 | |||
| 477 | Michael G Schwern <schwern@pobox.com> | ||
| 478 | |||
| 479 | =head1 SEE ALSO | ||
| 480 | |||
| 481 | L<Geo::TigerLine>, L<mk_parsers> | ||
| 482 | |||
| 483 | =cut | ||
| 484 | |||
| 485 | |||
| 486 | return 'Honey flash!'; |