svn-gvsig-desktop / tags / v2_0_Build_1217 / libraries / libjni-gdal-macosx / include / ogr_feature.h @ 40324
History | View | Annotate | Download (14.7 KB)
1 | 8219 | nacho | /******************************************************************************
|
---|---|---|---|
2 | * $Id$
|
||
3 | *
|
||
4 | * Project: OpenGIS Simple Features Reference Implementation
|
||
5 | * Purpose: Class for representing a whole feature, and layer schemas.
|
||
6 | * Author: Frank Warmerdam, warmerda@home.com
|
||
7 | *
|
||
8 | ******************************************************************************
|
||
9 | * Copyright (c) 1999, Les Technologies SoftMap Inc.
|
||
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 | * $Log$
|
||
31 | * Revision 1.1 2006-10-23 06:25:39 nacho
|
||
32 | * *** empty log message ***
|
||
33 | *
|
||
34 | * Revision 1.1 2006/06/29 16:23:27 nacho
|
||
35 | * *** empty log message ***
|
||
36 | *
|
||
37 | * Revision 1.2 2006/01/09 12:50:13 nacho
|
||
38 | * *** empty log message ***
|
||
39 | *
|
||
40 | * Revision 1.1 2005/07/27 08:22:55 igbrotru
|
||
41 | * *** empty log message ***
|
||
42 | *
|
||
43 | * Revision 1.1 2005/01/11 15:23:01 igbrotru
|
||
44 | * *** empty log message ***
|
||
45 | *
|
||
46 | * Revision 1.29 2004/02/23 21:47:23 warmerda
|
||
47 | * Added GetUsedFields() and GetSWGExpr() methods on OGRFeatureQuery class
|
||
48 | *
|
||
49 | * Revision 1.28 2003/05/28 19:16:42 warmerda
|
||
50 | * fixed up argument names and stuff for docs
|
||
51 | *
|
||
52 | * Revision 1.27 2003/04/08 20:57:28 warmerda
|
||
53 | * added RemapFields on OGRFeature
|
||
54 | *
|
||
55 | * Revision 1.26 2003/03/04 05:46:31 warmerda
|
||
56 | * added EvaluateAgainstIndices for OGRFeatureQuery
|
||
57 | *
|
||
58 | * Revision 1.25 2003/01/08 22:03:44 warmerda
|
||
59 | * added StealGeometry() method on OGRFeature
|
||
60 | *
|
||
61 | * Revision 1.24 2002/10/09 14:31:06 warmerda
|
||
62 | * dont permit negative widths to be assigned to field definition
|
||
63 | *
|
||
64 | * Revision 1.23 2002/09/26 18:13:17 warmerda
|
||
65 | * moved some defs to ogr_core.h for sharing with ogr_api.h
|
||
66 | *
|
||
67 | * Revision 1.22 2002/08/07 21:37:47 warmerda
|
||
68 | * added indirect OGRFeaturedefn constructor/destructor
|
||
69 | *
|
||
70 | * Revision 1.21 2001/11/01 16:54:16 warmerda
|
||
71 | * added DestroyFeature
|
||
72 | *
|
||
73 | * Revision 1.20 2001/07/19 18:25:07 warmerda
|
||
74 | * expanded tabs
|
||
75 | *
|
||
76 | * Revision 1.19 2001/06/19 15:48:36 warmerda
|
||
77 | * added feature attribute query support
|
||
78 | *
|
||
79 | * Revision 1.18 2001/06/01 14:33:00 warmerda
|
||
80 | * added CreateFeature factory method
|
||
81 | *
|
||
82 | * Revision 1.17 2001/02/06 17:10:28 warmerda
|
||
83 | * export entry points from DLL
|
||
84 | *
|
||
85 | * Revision 1.16 2001/01/19 21:10:47 warmerda
|
||
86 | * replaced tabs
|
||
87 | *
|
||
88 | * Revision 1.15 2000/12/07 03:40:13 danmo
|
||
89 | * Removed stray comma in OGRFieldType enum defn
|
||
90 | *
|
||
91 | * Revision 1.14 2000/10/03 19:19:56 danmo
|
||
92 | * Made m_pszStyleString protected (was private)
|
||
93 | *
|
||
94 | * Revision 1.13 2000/10/03 18:14:29 danmo
|
||
95 | * Made OGRFeature::Get/SetStyleString() virtual
|
||
96 | *
|
||
97 | * Revision 1.12 2000/08/18 21:26:53 svillene
|
||
98 | * Add representation
|
||
99 | *
|
||
100 | * Revision 1.11 1999/11/26 03:05:38 warmerda
|
||
101 | * added unset field support
|
||
102 | *
|
||
103 | * Revision 1.10 1999/11/18 19:02:20 warmerda
|
||
104 | * expanded tabs
|
||
105 | *
|
||
106 | * Revision 1.9 1999/11/04 21:05:49 warmerda
|
||
107 | * Added the Set() method on OGRFieldDefn to set all info in one call,
|
||
108 | * and the SetFrom() method on OGRFeature to copy the contents of one
|
||
109 | * feature to another, even if of a different OGRFeatureDefn.
|
||
110 | *
|
||
111 | * Revision 1.8 1999/10/01 14:47:05 warmerda
|
||
112 | * added full family of get/set field methods with field names
|
||
113 | *
|
||
114 | * Revision 1.7 1999/08/30 14:52:33 warmerda
|
||
115 | * added support for StringList fields
|
||
116 | *
|
||
117 | * Revision 1.6 1999/08/26 17:38:00 warmerda
|
||
118 | * added support for real and integer lists
|
||
119 | *
|
||
120 | * Revision 1.5 1999/07/27 00:47:37 warmerda
|
||
121 | * Added FID to OGRFeature class
|
||
122 | *
|
||
123 | * Revision 1.4 1999/07/07 04:23:07 danmo
|
||
124 | * Fixed typo in #define _OGR_..._H_INCLUDED line
|
||
125 | *
|
||
126 | * Revision 1.3 1999/07/05 17:18:39 warmerda
|
||
127 | * added docs
|
||
128 | *
|
||
129 | * Revision 1.2 1999/06/11 19:21:27 warmerda
|
||
130 | * Fleshed out operational definitions
|
||
131 | *
|
||
132 | * Revision 1.1 1999/05/31 17:14:53 warmerda
|
||
133 | * New
|
||
134 | *
|
||
135 | */
|
||
136 | |||
137 | #ifndef _OGR_FEATURE_H_INCLUDED
|
||
138 | #define _OGR_FEATURE_H_INCLUDED
|
||
139 | |||
140 | #include "ogr_geometry.h" |
||
141 | |||
142 | class OGRStyleTable; |
||
143 | |||
144 | /**
|
||
145 | * \file ogr_feature.h
|
||
146 | *
|
||
147 | * Simple feature classes.
|
||
148 | */
|
||
149 | |||
150 | /************************************************************************/
|
||
151 | /* OGRFieldDefn */
|
||
152 | /************************************************************************/
|
||
153 | |||
154 | /**
|
||
155 | * Definition of an attribute of an OGRFeatureDefn.
|
||
156 | */
|
||
157 | |||
158 | class CPL_DLL OGRFieldDefn |
||
159 | { |
||
160 | private:
|
||
161 | char *pszName;
|
||
162 | OGRFieldType eType; |
||
163 | OGRJustification eJustify; |
||
164 | int nWidth; /* zero is variable */ |
||
165 | int nPrecision;
|
||
166 | OGRField uDefault; |
||
167 | |||
168 | void Initialize( const char *, OGRFieldType ); |
||
169 | |||
170 | public:
|
||
171 | OGRFieldDefn( const char *, OGRFieldType ); |
||
172 | OGRFieldDefn( OGRFieldDefn * ); |
||
173 | ~OGRFieldDefn(); |
||
174 | |||
175 | void SetName( const char * ); |
||
176 | const char *GetNameRef() { return pszName; } |
||
177 | |||
178 | OGRFieldType GetType() { return eType; }
|
||
179 | void SetType( OGRFieldType eTypeIn ) { eType = eTypeIn;}
|
||
180 | static const char *GetFieldTypeName( OGRFieldType ); |
||
181 | |||
182 | OGRJustification GetJustify() { return eJustify; }
|
||
183 | void SetJustify( OGRJustification eJustifyIn )
|
||
184 | { eJustify = eJustifyIn; } |
||
185 | |||
186 | int GetWidth() { return nWidth; } |
||
187 | void SetWidth( int nWidthIn ) { nWidth = MAX(0,nWidthIn); } |
||
188 | |||
189 | int GetPrecision() { return nPrecision; } |
||
190 | void SetPrecision( int nPrecisionIn ) |
||
191 | { nPrecision = nPrecisionIn; } |
||
192 | |||
193 | void Set( const char *, OGRFieldType, int = 0, int = 0, |
||
194 | OGRJustification = OJUndefined ); |
||
195 | |||
196 | void SetDefault( const OGRField * ); |
||
197 | const OGRField *GetDefaultRef() { return &uDefault; } |
||
198 | }; |
||
199 | |||
200 | /************************************************************************/
|
||
201 | /* OGRFeatureDefn */
|
||
202 | /************************************************************************/
|
||
203 | |||
204 | /**
|
||
205 | * Definition of a feature class or feature layer.
|
||
206 | *
|
||
207 | * This object contains schema information for a set of OGRFeatures. In
|
||
208 | * table based systems, an OGRFeatureDefn is essentially a layer. In more
|
||
209 | * object oriented approaches (such as SF CORBA) this can represent a class
|
||
210 | * of features but doesn't necessarily relate to all of a layer, or just one
|
||
211 | * layer.
|
||
212 | *
|
||
213 | * This object also can contain some other information such as a name, the
|
||
214 | * base geometry type and potentially other metadata.
|
||
215 | *
|
||
216 | * It is reasonable for different translators to derive classes from
|
||
217 | * OGRFeatureDefn with additional translator specific information.
|
||
218 | */
|
||
219 | |||
220 | class CPL_DLL OGRFeatureDefn |
||
221 | { |
||
222 | private:
|
||
223 | int nRefCount;
|
||
224 | |||
225 | int nFieldCount;
|
||
226 | OGRFieldDefn **papoFieldDefn; |
||
227 | |||
228 | OGRwkbGeometryType eGeomType; |
||
229 | |||
230 | char *pszFeatureClassName;
|
||
231 | |||
232 | public:
|
||
233 | OGRFeatureDefn( const char * pszName = NULL ); |
||
234 | virtual ~OGRFeatureDefn(); |
||
235 | |||
236 | const char *GetName() { return pszFeatureClassName; } |
||
237 | |||
238 | int GetFieldCount() { return nFieldCount; } |
||
239 | OGRFieldDefn *GetFieldDefn( int i );
|
||
240 | int GetFieldIndex( const char * ); |
||
241 | |||
242 | void AddFieldDefn( OGRFieldDefn * );
|
||
243 | |||
244 | OGRwkbGeometryType GetGeomType() { return eGeomType; }
|
||
245 | void SetGeomType( OGRwkbGeometryType );
|
||
246 | |||
247 | OGRFeatureDefn *Clone(); |
||
248 | |||
249 | int Reference() { return ++nRefCount; } |
||
250 | int Dereference() { return --nRefCount; } |
||
251 | int GetReferenceCount() { return nRefCount; } |
||
252 | |||
253 | static OGRFeatureDefn *CreateFeatureDefn( const char *pszName = NULL ); |
||
254 | static void DestroyFeatureDefn( OGRFeatureDefn * ); |
||
255 | }; |
||
256 | |||
257 | /************************************************************************/
|
||
258 | /* OGRFeature */
|
||
259 | /************************************************************************/
|
||
260 | |||
261 | /**
|
||
262 | * A simple feature, including geometry and attributes.
|
||
263 | */
|
||
264 | |||
265 | class CPL_DLL OGRFeature |
||
266 | { |
||
267 | private:
|
||
268 | |||
269 | long nFID;
|
||
270 | OGRFeatureDefn *poDefn; |
||
271 | OGRGeometry *poGeometry; |
||
272 | OGRField *pauFields; |
||
273 | |||
274 | protected:
|
||
275 | char * m_pszStyleString;
|
||
276 | OGRStyleTable *m_poStyleTable; |
||
277 | |||
278 | |||
279 | public:
|
||
280 | OGRFeature( OGRFeatureDefn * ); |
||
281 | virtual ~OGRFeature(); |
||
282 | |||
283 | OGRFeatureDefn *GetDefnRef() { return poDefn; }
|
||
284 | |||
285 | OGRErr SetGeometryDirectly( OGRGeometry * ); |
||
286 | OGRErr SetGeometry( OGRGeometry * ); |
||
287 | OGRGeometry *GetGeometryRef() { return poGeometry; }
|
||
288 | OGRGeometry *StealGeometry(); |
||
289 | |||
290 | OGRFeature *Clone(); |
||
291 | virtual OGRBoolean Equal( OGRFeature * poFeature ); |
||
292 | |||
293 | int GetFieldCount() { return poDefn->GetFieldCount(); } |
||
294 | OGRFieldDefn *GetFieldDefnRef( int iField )
|
||
295 | { return poDefn->GetFieldDefn(iField); }
|
||
296 | int GetFieldIndex( const char * pszName) |
||
297 | { return poDefn->GetFieldIndex(pszName);}
|
||
298 | |||
299 | int IsFieldSet( int iField ) |
||
300 | { return
|
||
301 | pauFields[iField].Set.nMarker1 != OGRUnsetMarker |
||
302 | || pauFields[iField].Set.nMarker2 != OGRUnsetMarker; |
||
303 | } |
||
304 | |||
305 | void UnsetField( int iField ); |
||
306 | |||
307 | OGRField *GetRawFieldRef( int i ) { return pauFields + i; } |
||
308 | |||
309 | int GetFieldAsInteger( int i ); |
||
310 | double GetFieldAsDouble( int i ); |
||
311 | const char *GetFieldAsString( int i ); |
||
312 | const int *GetFieldAsIntegerList( int i, int *pnCount ); |
||
313 | const double *GetFieldAsDoubleList( int i, int *pnCount ); |
||
314 | char **GetFieldAsStringList( int i ); |
||
315 | |||
316 | int GetFieldAsInteger( const char *pszFName ) |
||
317 | { return GetFieldAsInteger( GetFieldIndex(pszFName) ); }
|
||
318 | double GetFieldAsDouble( const char *pszFName ) |
||
319 | { return GetFieldAsDouble( GetFieldIndex(pszFName) ); }
|
||
320 | const char *GetFieldAsString( const char *pszFName ) |
||
321 | { return GetFieldAsString( GetFieldIndex(pszFName) ); }
|
||
322 | const int *GetFieldAsIntegerList( const char *pszFName, |
||
323 | int *pnCount )
|
||
324 | { return GetFieldAsIntegerList( GetFieldIndex(pszFName),
|
||
325 | pnCount ); } |
||
326 | const double *GetFieldAsDoubleList( const char *pszFName, |
||
327 | int *pnCount )
|
||
328 | { return GetFieldAsDoubleList( GetFieldIndex(pszFName),
|
||
329 | pnCount ); } |
||
330 | char **GetFieldAsStringList( const char *pszFName ) |
||
331 | { return GetFieldAsStringList(GetFieldIndex(pszFName)); }
|
||
332 | |||
333 | void SetField( int i, int nValue ); |
||
334 | void SetField( int i, double dfValue ); |
||
335 | void SetField( int i, const char * pszValue ); |
||
336 | void SetField( int i, int nCount, int * panValues ); |
||
337 | void SetField( int i, int nCount, double * padfValues ); |
||
338 | void SetField( int i, char ** papszValues ); |
||
339 | void SetField( int i, OGRField * puValue ); |
||
340 | |||
341 | void SetField( const char *pszFName, int nValue ) |
||
342 | { SetField( GetFieldIndex(pszFName), nValue ); } |
||
343 | void SetField( const char *pszFName, double dfValue ) |
||
344 | { SetField( GetFieldIndex(pszFName), dfValue ); } |
||
345 | void SetField( const char *pszFName, const char * pszValue) |
||
346 | { SetField( GetFieldIndex(pszFName), pszValue ); } |
||
347 | void SetField( const char *pszFName, int nCount, |
||
348 | int * panValues )
|
||
349 | { SetField(GetFieldIndex(pszFName),nCount,panValues);} |
||
350 | void SetField( const char *pszFName, int nCount, |
||
351 | double * padfValues )
|
||
352 | {SetField(GetFieldIndex(pszFName),nCount,padfValues);} |
||
353 | void SetField( const char *pszFName, char ** papszValues ) |
||
354 | { SetField( GetFieldIndex(pszFName), papszValues); } |
||
355 | void SetField( const char *pszFName, OGRField * puValue ) |
||
356 | { SetField( GetFieldIndex(pszFName), puValue ); } |
||
357 | |||
358 | long GetFID() { return nFID; } |
||
359 | virtual OGRErr SetFID( long nFID );
|
||
360 | |||
361 | void DumpReadable( FILE * );
|
||
362 | |||
363 | OGRErr SetFrom( OGRFeature *, int = TRUE);
|
||
364 | |||
365 | OGRErr RemapFields( OGRFeatureDefn *poNewDefn, |
||
366 | int *panRemapSource );
|
||
367 | |||
368 | virtual const char *GetStyleString(); |
||
369 | virtual void SetStyleString(const char *); |
||
370 | virtual void SetStyleTable(OGRStyleTable *poStyleTable);
|
||
371 | |||
372 | static OGRFeature *CreateFeature( OGRFeatureDefn * );
|
||
373 | static void DestroyFeature( OGRFeature * ); |
||
374 | }; |
||
375 | |||
376 | /************************************************************************/
|
||
377 | /* OGRFeatureQuery */
|
||
378 | /************************************************************************/
|
||
379 | |||
380 | class OGRLayer; |
||
381 | |||
382 | class CPL_DLL OGRFeatureQuery |
||
383 | { |
||
384 | private:
|
||
385 | OGRFeatureDefn *poTargetDefn; |
||
386 | void *pSWQExpr;
|
||
387 | |||
388 | char **FieldCollector( void *, char ** ); |
||
389 | |||
390 | public:
|
||
391 | OGRFeatureQuery(); |
||
392 | ~OGRFeatureQuery(); |
||
393 | |||
394 | OGRErr Compile( OGRFeatureDefn *, const char * ); |
||
395 | int Evaluate( OGRFeature * );
|
||
396 | |||
397 | long *EvaluateAgainstIndices( OGRLayer *, OGRErr * );
|
||
398 | |||
399 | char **GetUsedFields();
|
||
400 | |||
401 | void *GetSWGExpr() { return pSWQExpr; } |
||
402 | }; |
||
403 | |||
404 | #endif /* ndef _OGR_FEATURE_H_INCLUDED */ |