1 : /******************************************************************************
2 : * $Id: ogr_dgn.h 25311 2012-12-15 12:48:14Z rouault $
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 :
46 : DGNHandle hDGN;
47 : int bUpdate;
48 :
49 : char *pszLinkFormat;
50 :
51 : OGRFeature *ElementToFeature( DGNElemCore * );
52 :
53 : void ConsiderBrush( DGNElemCore *, const char *pszPen,
54 : OGRFeature *poFeature );
55 :
56 : DGNElemCore **LineStringToElementGroup( OGRLineString *, int );
57 : DGNElemCore **TranslateLabel( OGRFeature * );
58 :
59 : int bHaveSimpleQuery;
60 : OGRFeature *poEvalFeature;
61 :
62 : OGRErr CreateFeatureWithGeom( OGRFeature *, OGRGeometry * );
63 :
64 : public:
65 : OGRDGNLayer( const char * pszName, DGNHandle hDGN,
66 : int bUpdate );
67 : ~OGRDGNLayer();
68 :
69 : void SetSpatialFilter( OGRGeometry * );
70 :
71 : void ResetReading();
72 : OGRFeature * GetNextFeature();
73 : OGRFeature * GetFeature( long nFeatureId );
74 :
75 : virtual int GetFeatureCount( int bForce = TRUE );
76 : virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
77 :
78 66 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
79 :
80 : int TestCapability( const char * );
81 :
82 : OGRErr CreateFeature( OGRFeature *poFeature );
83 :
84 : };
85 :
86 : /************************************************************************/
87 : /* OGRDGNDataSource */
88 : /************************************************************************/
89 :
90 : class OGRDGNDataSource : public OGRDataSource
91 : {
92 : OGRDGNLayer **papoLayers;
93 : int nLayers;
94 :
95 : char *pszName;
96 : DGNHandle hDGN;
97 :
98 : char **papszOptions;
99 :
100 : public:
101 : OGRDGNDataSource();
102 : ~OGRDGNDataSource();
103 :
104 : int Open( const char *, int bTestOpen, int bUpdate );
105 : int PreCreate( const char *, char ** );
106 :
107 : OGRLayer *CreateLayer( const char *,
108 : OGRSpatialReference * = NULL,
109 : OGRwkbGeometryType = wkbUnknown,
110 : char ** = NULL );
111 :
112 4 : const char *GetName() { return pszName; }
113 7 : int GetLayerCount() { return nLayers; }
114 : OGRLayer *GetLayer( int );
115 :
116 : int TestCapability( const char * );
117 : };
118 :
119 : /************************************************************************/
120 : /* OGRDGNDriver */
121 : /************************************************************************/
122 :
123 : class OGRDGNDriver : public OGRSFDriver
124 226 : {
125 : public:
126 : ~OGRDGNDriver();
127 :
128 : const char *GetName();
129 : OGRDataSource *Open( const char *, int );
130 : OGRDataSource *CreateDataSource( const char *, char ** );
131 :
132 : int TestCapability( const char * );
133 : };
134 :
135 :
136 : #endif /* ndef _OGR_DGN_H_INCLUDED */
|