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