| 1 | package Geo::TigerLine::Record::U; | ||
| 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 | 'tlidov1' => { | ||
| 16 | 'len' => 10, | ||
| 17 | 'beg' => 22, | ||
| 18 | 'bv' => 'Yes', | ||
| 19 | 'fieldnum' => 6, | ||
| 20 | 'type' => 'N', | ||
| 21 | 'description' => 'TIGER/Line ID, First Overpass 1-Cell Number', | ||
| 22 | 'end' => 31, | ||
| 23 | 'fmt' => 'R', | ||
| 24 | 'field' => 'tlidov1' | ||
| 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 | 'tlidun1' => { | ||
| 49 | 'len' => 10, | ||
| 50 | 'beg' => 42, | ||
| 51 | 'bv' => 'Yes', | ||
| 52 | 'fieldnum' => 8, | ||
| 53 | 'type' => 'N', | ||
| 54 | 'description' => 'TIGER/Line ID, First Underpass 1-Cell Number', | ||
| 55 | 'end' => 51, | ||
| 56 | 'fmt' => 'R', | ||
| 57 | 'field' => 'tlidun1' | ||
| 58 | }, | ||
| 59 | 'tlidov2' => { | ||
| 60 | 'len' => 10, | ||
| 61 | 'beg' => 32, | ||
| 62 | 'bv' => 'Yes', | ||
| 63 | 'fieldnum' => 7, | ||
| 64 | 'type' => 'N', | ||
| 65 | 'description' => 'TIGER/Line ID, Second Overpass 1-Cell Number', | ||
| 66 | 'end' => 41, | ||
| 67 | 'fmt' => 'R', | ||
| 68 | 'field' => 'tlidov2' | ||
| 69 | }, | ||
| 70 | 'tzid' => { | ||
| 71 | 'len' => 10, | ||
| 72 | 'beg' => 11, | ||
| 73 | 'bv' => 'No', | ||
| 74 | 'fieldnum' => 4, | ||
| 75 | 'type' => 'N', | ||
| 76 | 'description' => 'TIGER Zero-Cell ID, Permanent Zero-Cell Number', | ||
| 77 | 'end' => 20, | ||
| 78 | 'fmt' => 'R', | ||
| 79 | 'field' => 'tzid' | ||
| 80 | }, | ||
| 81 | 'frlat' => { | ||
| 82 | 'len' => 9, | ||
| 83 | 'beg' => 72, | ||
| 84 | 'bv' => 'No', | ||
| 85 | 'fieldnum' => 11, | ||
| 86 | 'type' => 'N', | ||
| 87 | 'description' => 'TZID Latitude', | ||
| 88 | 'end' => 80, | ||
| 89 | 'fmt' => 'R', | ||
| 90 | 'field' => 'frlat' | ||
| 91 | }, | ||
| 92 | 'rtsq' => { | ||
| 93 | 'len' => 1, | ||
| 94 | 'beg' => 21, | ||
| 95 | 'bv' => 'No', | ||
| 96 | 'fieldnum' => 5, | ||
| 97 | 'type' => 'N', | ||
| 98 | 'description' => 'Record Sequence Number', | ||
| 99 | 'end' => 21, | ||
| 100 | 'fmt' => 'R', | ||
| 101 | 'field' => 'rtsq' | ||
| 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 | 'tlidun2' => { | ||
| 115 | 'len' => 10, | ||
| 116 | 'beg' => 52, | ||
| 117 | 'bv' => 'Yes', | ||
| 118 | 'fieldnum' => 9, | ||
| 119 | 'type' => 'N', | ||
| 120 | 'description' => 'TIGER/Line ID, Second Underpass 1-Cell Number', | ||
| 121 | 'end' => 61, | ||
| 122 | 'fmt' => 'R', | ||
| 123 | 'field' => 'tlidun2' | ||
| 124 | }, | ||
| 125 | 'frlong' => { | ||
| 126 | 'len' => 10, | ||
| 127 | 'beg' => 62, | ||
| 128 | 'bv' => 'No', | ||
| 129 | 'fieldnum' => 10, | ||
| 130 | 'type' => 'N', | ||
| 131 | 'description' => 'TZID Longitude', | ||
| 132 | 'end' => 71, | ||
| 133 | 'fmt' => 'R', | ||
| 134 | 'field' => 'frlong' | ||
| 135 | } | ||
| 136 | ); | ||
| 137 | |||
| 138 | |||
| 139 | my @Data_Fields = ( | ||
| 140 | 'rt', | ||
| 141 | 'version', | ||
| 142 | 'file', | ||
| 143 | 'tzid', | ||
| 144 | 'rtsq', | ||
| 145 | 'tlidov1', | ||
| 146 | 'tlidov2', | ||
| 147 | 'tlidun1', | ||
| 148 | 'tlidun2', | ||
| 149 | 'frlong', | ||
| 150 | 'frlat' | ||
| 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::U - TIGER/Line 2006 TIGER/Line ID Overpass/Underpass Identification | ||
| 180 | |||
| 181 | =head1 SYNOPSIS | ||
| 182 | |||
| 183 | use Geo::TigerLine::Record::U; | ||
| 184 | |||
| 185 | @records = Geo::TigerLine::Record::U->parse_file($fh); | ||
| 186 | @records = Geo::TigerLine::Record::U->parse_file($fh, \&callback); | ||
| 187 | |||
| 188 | $record = Geo::TigerLine::Record::U->new(\%fields); | ||
| 189 | |||
| 190 | $record->rt(); | ||
| 191 | $record->version(); | ||
| 192 | $record->file(); | ||
| 193 | $record->tzid(); | ||
| 194 | $record->rtsq(); | ||
| 195 | $record->tlidov1(); | ||
| 196 | $record->tlidov2(); | ||
| 197 | $record->tlidun1(); | ||
| 198 | $record->tlidun2(); | ||
| 199 | $record->frlong(); | ||
| 200 | $record->frlat(); | ||
| 201 | |||
| 202 | |||
| 203 | =head1 DESCRIPTION | ||
| 204 | |||
| 205 | This is a class representing record type U 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 U 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<tzid> | ||
| 262 | |||
| 263 | $data = $record->tzid(); | ||
| 264 | $record->tzid($data); | ||
| 265 | |||
| 266 | TIGER Zero-Cell ID, Permanent Zero-Cell Number. | ||
| 267 | |||
| 268 | Expects numeric data of no more than 10 characters. $data cannot be blank | ||
| 269 | and should be right justified. | ||
| 270 | |||
| 271 | |||
| 272 | =item B<rtsq> | ||
| 273 | |||
| 274 | $data = $record->rtsq(); | ||
| 275 | $record->rtsq($data); | ||
| 276 | |||
| 277 | Record Sequence Number. | ||
| 278 | |||
| 279 | Expects numeric data of no more than 1 characters. $data cannot be blank | ||
| 280 | and should be right justified. | ||
| 281 | |||
| 282 | |||
| 283 | =item B<tlidov1> | ||
| 284 | |||
| 285 | $data = $record->tlidov1(); | ||
| 286 | $record->tlidov1($data); | ||
| 287 | |||
| 288 | TIGER/Line ID, First Overpass 1-Cell Number. | ||
| 289 | |||
| 290 | Expects numeric data of no more than 10 characters. $data can be blank | ||
| 291 | and should be right justified. | ||
| 292 | |||
| 293 | |||
| 294 | =item B<tlidov2> | ||
| 295 | |||
| 296 | $data = $record->tlidov2(); | ||
| 297 | $record->tlidov2($data); | ||
| 298 | |||
| 299 | TIGER/Line ID, Second Overpass 1-Cell Number. | ||
| 300 | |||
| 301 | Expects numeric data of no more than 10 characters. $data can be blank | ||
| 302 | and should be right justified. | ||
| 303 | |||
| 304 | |||
| 305 | =item B<tlidun1> | ||
| 306 | |||
| 307 | $data = $record->tlidun1(); | ||
| 308 | $record->tlidun1($data); | ||
| 309 | |||
| 310 | TIGER/Line ID, First Underpass 1-Cell Number. | ||
| 311 | |||
| 312 | Expects numeric data of no more than 10 characters. $data can be blank | ||
| 313 | and should be right justified. | ||
| 314 | |||
| 315 | |||
| 316 | =item B<tlidun2> | ||
| 317 | |||
| 318 | $data = $record->tlidun2(); | ||
| 319 | $record->tlidun2($data); | ||
| 320 | |||
| 321 | TIGER/Line ID, Second Underpass 1-Cell Number. | ||
| 322 | |||
| 323 | Expects numeric data of no more than 10 characters. $data can be blank | ||
| 324 | and should be right justified. | ||
| 325 | |||
| 326 | |||
| 327 | =item B<frlong> | ||
| 328 | |||
| 329 | $data = $record->frlong(); | ||
| 330 | $record->frlong($data); | ||
| 331 | |||
| 332 | TZID Longitude. | ||
| 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<frlat> | ||
| 339 | |||
| 340 | $data = $record->frlat(); | ||
| 341 | $record->frlat($data); | ||
| 342 | |||
| 343 | TZID Latitude. | ||
| 344 | |||
| 345 | Expects numeric data of no more than 9 characters. $data cannot be blank | ||
| 346 | and should be right 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 U - TIGER/Line ID Overpass/Underpass Identification | ||
| 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 | TZID No R N 11 20 10 TIGER Zero-Cell ID, Permanent Zero-Cell Number | ||
| 365 | RTSQ No R N 21 21 1 Record Sequence Number | ||
| 366 | TLIDOV1 Yes R N 22 31 10 TIGER/Line ID, First Overpass 1-Cell Number | ||
| 367 | TLIDOV2 Yes R N 32 41 10 TIGER/Line ID, Second Overpass 1-Cell Number | ||
| 368 | TLIDUN1 Yes R N 42 51 10 TIGER/Line ID, First Underpass 1-Cell Number | ||
| 369 | TLIDUN2 Yes R N 52 61 10 TIGER/Line ID, Second Underpass 1-Cell Number | ||
| 370 | FRLONG No R N 62 71 10 TZID Longitude | ||
| 371 | FRLAT No R N 72 80 9 TZID Latitude | ||
| 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!'; |