1 : /******************************************************************************
2 : * $Id: ogr_dgn.h 15583 2008-10-23 00:04:33Z warmerdam $
3 : *
4 : * Project: OpenGIS Simple Features Reference Implementation
5 : * Purpose: OGR Driver for DGN Reader.
6 : * Author: Frank Warmerdam, warmerdam@pobox.com
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2000, Frank Warmerdam (warmerdam@pobox.com)
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 : #ifndef _OGR_DGN_H_INCLUDED
31 : #define _OGR_DGN_H_INCLUDED
32 :
33 : #include "dgnlib.h"
34 : #include "ogrsf_frmts.h"
35 :
36 : /************************************************************************/
37 : /* OGRDGNLayer */
38 : /************************************************************************/
39 :
40 : class OGRDGNLayer : public OGRLayer
41 : {
42 : OGRFeatureDefn *poFeatureDefn;
43 :
44 : int iNextShapeId;
45 : int nTotalShapeCount;
46 :
47 : DGNHandle hDGN;
48 : int bUpdate;
49 :
50 : char *pszLinkFormat;
51 :
52 : OGRFeature *ElementToFeature( DGNElemCore * );
53 :
54 : void ConsiderBrush( DGNElemCore *, const char *pszPen,
55 : OGRFeature *poFeature );
56 :
57 : DGNElemCore **LineStringToElementGroup( OGRLineString *, int );
58 : DGNElemCore **TranslateLabel( OGRFeature * );
59 :
60 : int bHaveSimpleQuery;
61 : OGRFeature *poEvalFeature;
62 :
63 : OGRErr CreateFeatureWithGeom( OGRFeature *, OGRGeometry * );
64 :
65 : public:
66 : OGRDGNLayer( const char * pszName, DGNHandle hDGN,
67 : int bUpdate );
68 : ~OGRDGNLayer();
69 :
70 : void SetSpatialFilter( OGRGeometry * );
71 :
72 : void ResetReading();
73 : OGRFeature * GetNextFeature();
74 : OGRFeature * GetFeature( long nFeatureId );
75 :
76 : virtual int GetFeatureCount( int bForce = TRUE );
77 : virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
78 :
79 66 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
80 :
81 : int TestCapability( const char * );
82 :
83 : OGRErr CreateFeature( OGRFeature *poFeature );
84 :
85 : };
86 :
87 : /************************************************************************/
88 : /* OGRDGNDataSource */
89 : /************************************************************************/
90 :
91 : class OGRDGNDataSource : public OGRDataSource
92 : {
93 : OGRDGNLayer **papoLayers;
94 : int nLayers;
95 :
96 : char *pszName;
97 : DGNHandle hDGN;
98 :
99 : char **papszOptions;
100 :
101 : public:
102 : OGRDGNDataSource();
103 : ~OGRDGNDataSource();
104 :
105 : int Open( const char *, int bTestOpen, int bUpdate );
106 : int PreCreate( const char *, char ** );
107 :
108 : OGRLayer *CreateLayer( const char *,
109 : OGRSpatialReference * = NULL,
110 : OGRwkbGeometryType = wkbUnknown,
111 : char ** = NULL );
112 :
113 4 : const char *GetName() { return pszName; }
114 7 : int GetLayerCount() { return nLayers; }
115 : OGRLayer *GetLayer( int );
116 :
117 : int TestCapability( const char * );
118 : };
119 :
120 : /************************************************************************/
121 : /* OGRDGNDriver */
122 : /************************************************************************/
123 :
124 : class OGRDGNDriver : public OGRSFDriver
125 178 : {
126 : public:
127 : ~OGRDGNDriver();
128 :
129 : const char *GetName();
130 : OGRDataSource *Open( const char *, int );
131 : OGRDataSource *CreateDataSource( const char *, char ** );
132 :
133 : int TestCapability( const char * );
134 : };
135 :
136 :
137 : #endif /* ndef _OGR_DGN_H_INCLUDED */
|