Line data Source code
1 : /******************************************************************************
2 : *
3 : * Project: TIGER/Line Translator
4 : * Purpose: Implements TigerPolyChainLink, providing access to .RTI files.
5 : * Author: Frank Warmerdam, warmerdam@pobox.com
6 : *
7 : ******************************************************************************
8 : * Copyright (c) 1999, Frank Warmerdam
9 : *
10 : * Permission is hereby granted, free of charge, to any person obtaining a
11 : * copy of this software and associated documentation files (the "Software"),
12 : * to deal in the Software without restriction, including without limitation
13 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 : * and/or sell copies of the Software, and to permit persons to whom the
15 : * Software is furnished to do so, subject to the following conditions:
16 : *
17 : * The above copyright notice and this permission notice shall be included
18 : * in all copies or substantial portions of the Software.
19 : *
20 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 : * DEALINGS IN THE SOFTWARE.
27 : ****************************************************************************/
28 :
29 : #include "ogr_tiger.h"
30 : #include "cpl_conv.h"
31 :
32 : static const char I_FILE_CODE[] = "I";
33 :
34 : static const TigerFieldInfo rtI_2002_fields[] = {
35 : // fieldname fmt type OFTType beg end len bDefine bSet
36 : {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0},
37 : {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1},
38 : {"TLID", 'R', 'N', OFTInteger, 11, 20, 10, 1, 1},
39 : {"TZIDS", 'R', 'N', OFTInteger, 21, 30, 10, 1, 1},
40 : {"TZIDE", 'R', 'N', OFTInteger, 31, 40, 10, 1, 1},
41 : {"CENIDL", 'L', 'A', OFTString, 41, 45, 5, 1, 1},
42 : {"POLYIDL", 'R', 'N', OFTInteger, 46, 55, 10, 1, 1},
43 : {"CENIDR", 'L', 'A', OFTString, 56, 60, 5, 1, 1},
44 : {"POLYIDR", 'R', 'N', OFTInteger, 61, 70, 10, 1, 1},
45 : {"SOURCE", 'L', 'A', OFTString, 71, 80, 10, 1, 1},
46 : {"FTSEG", 'L', 'A', OFTString, 81, 97, 17, 1, 1},
47 : {"RS_I1", 'L', 'A', OFTString, 98, 107, 10, 1, 1},
48 : {"RS_I2", 'L', 'A', OFTString, 108, 117, 10, 1, 1},
49 : {"RS_I3", 'L', 'A', OFTString, 118, 127, 10, 1, 1},
50 : };
51 : static const TigerRecordInfo rtI_2002_info = {
52 : rtI_2002_fields, sizeof(rtI_2002_fields) / sizeof(TigerFieldInfo), 127};
53 :
54 : static const TigerFieldInfo rtI_fields[] = {
55 : // fieldname fmt type OFTType beg end len bDefine bSet
56 : {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0},
57 : {"TLID", 'R', 'N', OFTInteger, 6, 15, 10, 1, 1},
58 : {"FILE", 'L', 'N', OFTString, 16, 20, 5, 1, 1},
59 : {"STATE", 'L', 'N', OFTInteger, 16, 17, 2, 1, 1},
60 : {"COUNTY", 'L', 'N', OFTInteger, 18, 20, 3, 1, 1},
61 : {"RTLINK", 'L', 'A', OFTString, 21, 21, 1, 1, 1},
62 : {"CENIDL", 'L', 'A', OFTString, 22, 26, 5, 1, 1},
63 : {"POLYIDL", 'R', 'N', OFTInteger, 27, 36, 10, 1, 1},
64 : {"CENIDR", 'L', 'A', OFTString, 37, 41, 5, 1, 1},
65 : {"POLYIDR", 'R', 'N', OFTInteger, 42, 51, 10, 1, 1}};
66 : static const TigerRecordInfo rtI_info = {
67 : rtI_fields, sizeof(rtI_fields) / sizeof(TigerFieldInfo), 52};
68 :
69 : /************************************************************************/
70 : /* TigerPolyChainLink() */
71 : /************************************************************************/
72 :
73 0 : TigerPolyChainLink::TigerPolyChainLink(
74 0 : OGRTigerDataSource *poDSIn, CPL_UNUSED const char *pszPrototypeModule)
75 0 : : TigerFileBase(nullptr, I_FILE_CODE)
76 : {
77 0 : OGRFieldDefn oField("", OFTInteger);
78 :
79 0 : poDS = poDSIn;
80 0 : poFeatureDefn = new OGRFeatureDefn("PolyChainLink");
81 0 : poFeatureDefn->Reference();
82 0 : poFeatureDefn->SetGeomType(wkbNone);
83 :
84 0 : if (poDS->GetVersion() >= TIGER_2002)
85 : {
86 0 : psRTInfo = &rtI_2002_info;
87 : }
88 : else
89 : {
90 0 : psRTInfo = &rtI_info;
91 : }
92 :
93 : /* -------------------------------------------------------------------- */
94 : /* Fields from type I record. */
95 : /* -------------------------------------------------------------------- */
96 :
97 0 : AddFieldDefns(psRTInfo, poFeatureDefn);
98 0 : }
|