/src/gdal/ogr/ogrsf_frmts/tiger/tigerpip.cpp
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: TIGER/Line Translator |
4 | | * Purpose: Implements TigerPIP, providing access to .RTP files. |
5 | | * Author: Frank Warmerdam, warmerdam@pobox.com |
6 | | * |
7 | | ****************************************************************************** |
8 | | * Copyright (c) 1999, Frank Warmerdam |
9 | | * |
10 | | * SPDX-License-Identifier: MIT |
11 | | ****************************************************************************/ |
12 | | |
13 | | #include "ogr_tiger.h" |
14 | | #include "cpl_conv.h" |
15 | | |
16 | | static const char P_FILE_CODE[] = "P"; |
17 | | |
18 | | static const TigerFieldInfo rtP_2002_fields[] = { |
19 | | // fieldname fmt type OFTType beg end len bDefine bSet |
20 | | {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, |
21 | | {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1}, |
22 | | {"CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1}, |
23 | | {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1}, |
24 | | {"POLYLONG", 'R', 'N', OFTInteger, 26, 35, 10, 1, 1}, |
25 | | {"POLYLAT", 'R', 'N', OFTInteger, 36, 44, 9, 1, 1}, |
26 | | {"WATER", 'L', 'N', OFTInteger, 45, 45, 1, 1, 1}, |
27 | | }; |
28 | | static const TigerRecordInfo rtP_2002_info = { |
29 | | rtP_2002_fields, sizeof(rtP_2002_fields) / sizeof(TigerFieldInfo), 45}; |
30 | | |
31 | | static const TigerFieldInfo rtP_fields[] = { |
32 | | // fieldname fmt type OFTType beg end len bDefine bSet |
33 | | {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, |
34 | | {"FILE", 'L', 'N', OFTString, 6, 10, 5, 1, 1}, |
35 | | {"STATE", 'L', 'N', OFTInteger, 6, 7, 2, 1, 1}, |
36 | | {"COUNTY", 'L', 'N', OFTInteger, 8, 10, 3, 1, 1}, |
37 | | {"CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1}, |
38 | | {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1}}; |
39 | | static const TigerRecordInfo rtP_info = { |
40 | | rtP_fields, sizeof(rtP_fields) / sizeof(TigerFieldInfo), 44}; |
41 | | |
42 | | /************************************************************************/ |
43 | | /* TigerPIP() */ |
44 | | /************************************************************************/ |
45 | | |
46 | | TigerPIP::TigerPIP(OGRTigerDataSource *poDSIn, |
47 | | CPL_UNUSED const char *pszPrototypeModule) |
48 | 150 | : TigerPoint(nullptr, P_FILE_CODE) |
49 | 150 | { |
50 | 150 | poDS = poDSIn; |
51 | 150 | poFeatureDefn = new OGRFeatureDefn("PIP"); |
52 | 150 | poFeatureDefn->Reference(); |
53 | 150 | poFeatureDefn->SetGeomType(wkbPoint); |
54 | | |
55 | 150 | if (poDS->GetVersion() >= TIGER_2002) |
56 | 141 | { |
57 | 141 | psRTInfo = &rtP_2002_info; |
58 | 141 | } |
59 | 9 | else |
60 | 9 | { |
61 | 9 | psRTInfo = &rtP_info; |
62 | 9 | } |
63 | 150 | AddFieldDefns(psRTInfo, poFeatureDefn); |
64 | 150 | } |
65 | | |
66 | | OGRFeature *TigerPIP::GetFeature(int nRecordId) |
67 | 0 | { |
68 | 0 | return TigerPoint::GetFeature(nRecordId, 26, 35, 36, 44); |
69 | 0 | } |