| 1 | package Geo::TigerLine::Record::Z; | ||
| 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 | 'tlid' => { | ||
| 16 | 'len' => 10, | ||
| 17 | 'beg' => 6, | ||
| 18 | 'bv' => 'No', | ||
| 19 | 'fieldnum' => 3, | ||
| 20 | 'type' => 'N', | ||
| 21 | 'description' => 'TIGER/Line ID, Permanent 1-Cell Number', | ||
| 22 | 'end' => 15, | ||
| 23 | 'fmt' => 'R', | ||
| 24 | 'field' => 'tlid' | ||
| 25 | }, | ||
| 26 | 'zip4r' => { | ||
| 27 | 'len' => 4, | ||
| 28 | 'beg' => 23, | ||
| 29 | 'bv' => 'Yes', | ||
| 30 | 'fieldnum' => 6, | ||
| 31 | 'type' => 'N', | ||
| 32 | 'description' => '+4 Postal Add-On Code, Right', | ||
| 33 | 'end' => 26, | ||
| 34 | 'fmt' => 'L', | ||
| 35 | 'field' => 'zip4r' | ||
| 36 | }, | ||
| 37 | 'zip4l' => { | ||
| 38 | 'len' => 4, | ||
| 39 | 'beg' => 19, | ||
| 40 | 'bv' => 'Yes', | ||
| 41 | 'fieldnum' => 5, | ||
| 42 | 'type' => 'N', | ||
| 43 | 'description' => '+4 Postal Add-On Code, Left', | ||
| 44 | 'end' => 22, | ||
| 45 | 'fmt' => 'L', | ||
| 46 | 'field' => 'zip4l' | ||
| 47 | }, | ||
| 48 | 'rtsq' => { | ||
| 49 | 'len' => 3, | ||
| 50 | 'beg' => 16, | ||
| 51 | 'bv' => 'No', | ||
| 52 | 'fieldnum' => 4, | ||
| 53 | 'type' => 'N', | ||
| 54 | 'description' => 'Record Sequence Number', | ||
| 55 | 'end' => 18, | ||
| 56 | 'fmt' => 'R', | ||
| 57 | 'field' => 'rtsq' | ||
| 58 | }, | ||
| 59 | 'version' => { | ||
| 60 | 'len' => 4, | ||
| 61 | 'beg' => 2, | ||
| 62 | 'bv' => 'No', | ||
| 63 | 'fieldnum' => 2, | ||
| 64 | 'type' => 'N', | ||
| 65 | 'description' => 'Version Number', | ||
| 66 | 'end' => 5, | ||
| 67 | 'fmt' => 'L', | ||
| 68 | 'field' => 'version' | ||
| 69 | }, | ||
| 70 | 'rt' => { | ||
| 71 | 'len' => 1, | ||
| 72 | 'beg' => 1, | ||
| 73 | 'bv' => 'No', | ||
| 74 | 'fieldnum' => 1, | ||
| 75 | 'type' => 'A', | ||
| 76 | 'description' => 'Record Type', | ||
| 77 | 'end' => 1, | ||
| 78 | 'fmt' => 'L', | ||
| 79 | 'field' => 'rt' | ||
| 80 | } | ||
| 81 | ); | ||
| 82 | |||
| 83 | |||
| 84 | my @Data_Fields = ( | ||
| 85 | 'rt', | ||
| 86 | 'version', | ||
| 87 | 'tlid', | ||
| 88 | 'rtsq', | ||
| 89 | 'zip4l', | ||
| 90 | 'zip4r' | ||
| 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::Z - TIGER/Line 2006 ZIP+4 Codes | ||
| 120 | |||
| 121 | =head1 SYNOPSIS | ||
| 122 | |||
| 123 | use Geo::TigerLine::Record::Z; | ||
| 124 | |||
| 125 | @records = Geo::TigerLine::Record::Z->parse_file($fh); | ||
| 126 | @records = Geo::TigerLine::Record::Z->parse_file($fh, \&callback); | ||
| 127 | |||
| 128 | $record = Geo::TigerLine::Record::Z->new(\%fields); | ||
| 129 | |||
| 130 | $record->rt(); | ||
| 131 | $record->version(); | ||
| 132 | $record->tlid(); | ||
| 133 | $record->rtsq(); | ||
| 134 | $record->zip4l(); | ||
| 135 | $record->zip4r(); | ||
| 136 | |||
| 137 | |||
| 138 | =head1 DESCRIPTION | ||
| 139 | |||
| 140 | This is a class representing record type Z 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 Z 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<tlid> | ||
| 186 | |||
| 187 | $data = $record->tlid(); | ||
| 188 | $record->tlid($data); | ||
| 189 | |||
| 190 | TIGER/Line ID, Permanent 1-Cell Number. | ||
| 191 | |||
| 192 | Expects numeric data of no more than 10 characters. $data cannot be blank | ||
| 193 | and should be right justified. | ||
| 194 | |||
| 195 | |||
| 196 | =item B<rtsq> | ||
| 197 | |||
| 198 | $data = $record->rtsq(); | ||
| 199 | $record->rtsq($data); | ||
| 200 | |||
| 201 | Record Sequence Number. | ||
| 202 | |||
| 203 | Expects numeric data of no more than 3 characters. $data cannot be blank | ||
| 204 | and should be right justified. | ||
| 205 | |||
| 206 | |||
| 207 | =item B<zip4l> | ||
| 208 | |||
| 209 | $data = $record->zip4l(); | ||
| 210 | $record->zip4l($data); | ||
| 211 | |||
| 212 | +4 Postal Add-On Code, Left. | ||
| 213 | |||
| 214 | Expects numeric data of no more than 4 characters. $data can be blank | ||
| 215 | and should be left justified. | ||
| 216 | |||
| 217 | |||
| 218 | =item B<zip4r> | ||
| 219 | |||
| 220 | $data = $record->zip4r(); | ||
| 221 | $record->zip4r($data); | ||
| 222 | |||
| 223 | +4 Postal Add-On Code, Right. | ||
| 224 | |||
| 225 | Expects numeric data of no more than 4 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 Z - ZIP+4 Codes | ||
| 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 | TLID No R N 6 15 10 TIGER/Line ID, Permanent 1-Cell Number | ||
| 244 | RTSQ No R N 16 18 3 Record Sequence Number | ||
| 245 | ZIP4L Yes L N 19 22 4 +4 Postal Add-On Code, Left | ||
| 246 | ZIP4R Yes L N 23 26 4 +4 Postal Add-On Code, Right | ||
| 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!'; |