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