1 : /******************************************************************************
2 : * $Id: tigerlandmarks.cpp 10645 2007-01-18 02:22:39Z warmerdam $
3 : *
4 : * Project: TIGER/Line Translator
5 : * Purpose: Implements TigerLandmarks, providing access to .RT7 files.
6 : * Author: Frank Warmerdam, warmerdam@pobox.com
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 1999, Frank Warmerdam
10 : *
11 : * Permission is hereby granted, free of charge, to any person obtaining a
12 : * copy of this software and associated documentation files (the "Software"),
13 : * to deal in the Software without restriction, including without limitation
14 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 : * and/or sell copies of the Software, and to permit persons to whom the
16 : * Software is furnished to do so, subject to the following conditions:
17 : *
18 : * The above copyright notice and this permission notice shall be included
19 : * in all copies or substantial portions of the Software.
20 : *
21 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 : * DEALINGS IN THE SOFTWARE.
28 : ****************************************************************************/
29 :
30 : #include "ogr_tiger.h"
31 : #include "cpl_conv.h"
32 :
33 : CPL_CVSID("$Id: tigerlandmarks.cpp 10645 2007-01-18 02:22:39Z warmerdam $");
34 :
35 : #define FILE_CODE "7"
36 :
37 : static TigerFieldInfo rt7_2002_fields[] = {
38 : // fieldname fmt type OFTType beg end len bDefine bSet bWrite
39 : { "MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0, 0 },
40 : { "FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1, 1 },
41 : { "LAND", 'R', 'N', OFTInteger, 11, 20, 10, 1, 1, 1 },
42 : { "SOURCE", 'L', 'A', OFTString, 21, 21, 1, 1, 1, 1 },
43 : { "CFCC", 'L', 'A', OFTString, 22, 24, 3, 1, 1, 1 },
44 : { "LANAME", 'L', 'A', OFTString, 25, 54, 30, 1, 1, 1 },
45 : { "LALONG", 'R', 'N', OFTInteger, 55, 64, 10, 1, 1, 1 },
46 : { "LALAT", 'R', 'N', OFTInteger, 65, 73, 9, 1, 1, 1 },
47 : { "FILLER", 'L', 'A', OFTString, 74, 74, 1, 1, 1, 1 },
48 : };
49 : static TigerRecordInfo rt7_2002_info =
50 : {
51 : rt7_2002_fields,
52 : sizeof(rt7_2002_fields) / sizeof(TigerFieldInfo),
53 : 74
54 : };
55 :
56 : static TigerFieldInfo rt7_fields[] = {
57 : // fieldname fmt type OFTType beg end len bDefine bSet bWrite
58 : { "MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0, 0 },
59 : { "FILE", 'L', 'N', OFTString, 6, 10, 5, 1, 0, 1 },
60 : { "STATE", 'L', 'N', OFTInteger, 6, 7, 2, 1, 1, 1 },
61 : { "COUNTY", 'L', 'N', OFTInteger, 8, 10, 3, 1, 1, 1 },
62 : { "LAND", 'R', 'N', OFTInteger, 11, 20, 10, 1, 1, 1 },
63 : { "SOURCE", 'L', 'A', OFTString, 21, 21, 1, 1, 1, 1 },
64 : { "CFCC", 'L', 'A', OFTString, 22, 24, 3, 1, 1, 1 },
65 : { "LANAME", 'L', 'A', OFTString, 25, 54, 30, 1, 1, 1 }
66 : };
67 : static TigerRecordInfo rt7_info =
68 : {
69 : rt7_fields,
70 : sizeof(rt7_fields) / sizeof(TigerFieldInfo),
71 : 74
72 : };
73 :
74 : /************************************************************************/
75 : /* TigerLandmarks() */
76 : /************************************************************************/
77 :
78 : TigerLandmarks::TigerLandmarks( OGRTigerDataSource * poDSIn,
79 0 : const char * pszPrototypeModule )
80 0 : : TigerPoint(FALSE)
81 : {
82 0 : poDS = poDSIn;
83 0 : poFeatureDefn = new OGRFeatureDefn( "Landmarks" );
84 0 : poFeatureDefn->Reference();
85 0 : poFeatureDefn->SetGeomType( wkbPoint );
86 :
87 0 : if (poDS->GetVersion() >= TIGER_2002) {
88 0 : psRT7Info = &rt7_2002_info;
89 : } else {
90 0 : psRT7Info = &rt7_info;
91 : }
92 :
93 0 : AddFieldDefns( psRT7Info, poFeatureDefn );
94 0 : }
95 :
96 0 : TigerLandmarks::~TigerLandmarks()
97 0 : {}
98 :
99 :
100 0 : int TigerLandmarks::SetModule( const char * pszModule )
101 : {
102 0 : return TigerPoint::SetModule( pszModule, FILE_CODE );
103 : }
104 :
105 0 : OGRFeature *TigerLandmarks::GetFeature( int nRecordId )
106 : {
107 : return TigerPoint::GetFeature( nRecordId,
108 : psRT7Info,
109 : 55, 64,
110 0 : 65, 73 );
111 : }
112 :
113 0 : OGRErr TigerLandmarks::CreateFeature( OGRFeature *poFeature )
114 : {
115 : return TigerPoint::CreateFeature( poFeature,
116 : psRT7Info,
117 : 55,
118 0 : FILE_CODE );
119 : }
|