GDAL

- Main Page
- Related Pages
- Classes
- Files
- Download
- Issue Tracker

- File List
- File Members

ogr_feature.h
Go to the documentation of this file.
1 /******************************************************************************
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, warmerdam@pobox.com
7 *
8 ******************************************************************************
9 * Copyright (c) 1999, Les Technologies SoftMap Inc.
10 * Copyright (c) 2008-2013, Even Rouault <even dot rouault at mines-paris dot org>
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
29 ****************************************************************************/
30
31 #ifndef OGR_FEATURE_H_INCLUDED
32 #define OGR_FEATURE_H_INCLUDED
33
34 #include "cpl_atomic_ops.h"
35 #include "ogr_featurestyle.h"
36 #include "ogr_geometry.h"
37
38 #include <exception>
39 #include <memory>
40 #include <string>
41 #include <vector>
42
49 #ifndef DEFINE_OGRFeatureH
50
51 #define DEFINE_OGRFeatureH
52
53 #ifdef DEBUG
54 typedef struct OGRFieldDefnHS *OGRFieldDefnH;
55 typedef struct OGRFeatureDefnHS *OGRFeatureDefnH;
56 typedef struct OGRFeatureHS *OGRFeatureH;
57 typedef struct OGRStyleTableHS *OGRStyleTableH;
58 #else
59
60 typedef void *OGRFieldDefnH;
62 typedef void *OGRFeatureDefnH;
64 typedef void *OGRFeatureH;
66 typedef void *OGRStyleTableH;
67 #endif
68
69 typedef struct OGRGeomFieldDefnHS *OGRGeomFieldDefnH;
70 #endif /* DEFINE_OGRFeatureH */
71
72 class OGRStyleTable;
73
74 /************************************************************************/
75 /* OGRFieldDefn */
76 /************************************************************************/
77
92 class CPL_DLL OGRFieldDefn
93 {
94 private:
95 char *pszName;
96 OGRFieldType eType;
97 OGRJustification eJustify;
98 int nWidth; // Zero is variable.
99 int nPrecision;
100 char *pszDefault;
101
102 int bIgnore;
103 OGRFieldSubType eSubType;
104
105 int bNullable;
106
107 public:
108 OGRFieldDefn( const char *, OGRFieldType );
109 explicit OGRFieldDefn( const OGRFieldDefn * );
110 ~OGRFieldDefn();
111
112 void SetName( const char * );
113 const char *GetNameRef() const { return pszName; }
114
115 OGRFieldType GetType() const { return eType; }
116 void SetType( OGRFieldType eTypeIn );
117 static const char *GetFieldTypeName( OGRFieldType );
118
119 OGRFieldSubType GetSubType() const { return eSubType; }
120 void SetSubType( OGRFieldSubType eSubTypeIn );
121 static const char *GetFieldSubTypeName( OGRFieldSubType );
122
123 OGRJustification GetJustify() const { return eJustify; }
124 void SetJustify( OGRJustification eJustifyIn )
125 { eJustify = eJustifyIn; }
126
127 int GetWidth() const { return nWidth; }
128 void SetWidth( int nWidthIn ) { nWidth = MAX(0,nWidthIn); }
129
130 int GetPrecision() const { return nPrecision; }
131 void SetPrecision( int nPrecisionIn )
132 { nPrecision = nPrecisionIn; }
133
134 void Set( const char *, OGRFieldType, int = 0, int = 0,
135 OGRJustification = OJUndefined );
136
137 void SetDefault( const char* );
138 const char *GetDefault() const;
139 int IsDefaultDriverSpecific() const;
140
141 int IsIgnored() const { return bIgnore; }
142 void SetIgnored( int bIgnoreIn ) { bIgnore = bIgnoreIn; }
143
144 int IsNullable() const { return bNullable; }
145 void SetNullable( int bNullableIn ) { bNullable = bNullableIn; }
146
147 int IsSame( const OGRFieldDefn * ) const;
148
152 static inline OGRFieldDefnH ToHandle(OGRFieldDefn* poFieldDefn)
153 { return reinterpret_cast<OGRFieldDefnH>(poFieldDefn); }
154
158 static inline OGRFieldDefn* FromHandle(OGRFieldDefnH hFieldDefn)
159 { return reinterpret_cast<OGRFieldDefn*>(hFieldDefn); }
160 private:
161 CPL_DISALLOW_COPY_ASSIGN(OGRFieldDefn)
162 };
163
164 /************************************************************************/
165 /* OGRGeomFieldDefn */
166 /************************************************************************/
167
182 class CPL_DLL OGRGeomFieldDefn
183 {
184 protected:
186 char *pszName;
187 OGRwkbGeometryType eGeomType; /* all values possible except wkbNone */
188 mutable OGRSpatialReference* poSRS;
189
190 int bIgnore;
191 mutable int bNullable;
192
193 void Initialize( const char *, OGRwkbGeometryType );
195
196 public:
197 OGRGeomFieldDefn( const char *pszNameIn,
198 OGRwkbGeometryType eGeomTypeIn );
199 explicit OGRGeomFieldDefn( const OGRGeomFieldDefn * );
200 virtual ~OGRGeomFieldDefn();
201
202 void SetName( const char * );
203 const char *GetNameRef() const { return pszName; }
204
205 OGRwkbGeometryType GetType() const { return eGeomType; }
206 void SetType( OGRwkbGeometryType eTypeIn );
207
208 virtual OGRSpatialReference* GetSpatialRef() const;
209 void SetSpatialRef( OGRSpatialReference* poSRSIn );
210
211 int IsIgnored() const { return bIgnore; }
212 void SetIgnored( int bIgnoreIn ) { bIgnore = bIgnoreIn; }
213
214 int IsNullable() const { return bNullable; }
215 void SetNullable( int bNullableIn )
216 { bNullable = bNullableIn; }
217
218 int IsSame( const OGRGeomFieldDefn * ) const;
219
223 static inline OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn* poGeomFieldDefn)
224 { return reinterpret_cast<OGRGeomFieldDefnH>(poGeomFieldDefn); }
225
229 static inline OGRGeomFieldDefn* FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
230 { return reinterpret_cast<OGRGeomFieldDefn*>(hGeomFieldDefn); }
231 private:
232 CPL_DISALLOW_COPY_ASSIGN(OGRGeomFieldDefn)
233 };
234
235 /************************************************************************/
236 /* OGRFeatureDefn */
237 /************************************************************************/
238
259 class CPL_DLL OGRFeatureDefn
260 {
261 protected:
263 volatile int nRefCount;
264
265 mutable int nFieldCount;
266 mutable OGRFieldDefn **papoFieldDefn;
267
268 mutable int nGeomFieldCount;
269 mutable OGRGeomFieldDefn **papoGeomFieldDefn;
270
271 char *pszFeatureClassName;
272
273 int bIgnoreStyle;
275
276 public:
277 explicit OGRFeatureDefn( const char * pszName = nullptr );
278 virtual ~OGRFeatureDefn();
279
280 void SetName( const char* pszName );
281 virtual const char *GetName() const;
282
283 virtual int GetFieldCount() const;
284 virtual OGRFieldDefn *GetFieldDefn( int i );
285 virtual const OGRFieldDefn *GetFieldDefn( int i ) const;
286 virtual int GetFieldIndex( const char * ) const;
287
288 virtual void AddFieldDefn( OGRFieldDefn * );
289 virtual OGRErr DeleteFieldDefn( int iField );
290 virtual OGRErr ReorderFieldDefns( int* panMap );
291
292 virtual int GetGeomFieldCount() const;
293 virtual OGRGeomFieldDefn *GetGeomFieldDefn( int i );
294 virtual const OGRGeomFieldDefn *GetGeomFieldDefn( int i ) const;
295 virtual int GetGeomFieldIndex( const char * ) const;
296
297 virtual void AddGeomFieldDefn( OGRGeomFieldDefn *,
298 int bCopy = TRUE );
299 virtual OGRErr DeleteGeomFieldDefn( int iGeomField );
300
301 virtual OGRwkbGeometryType GetGeomType() const;
302 virtual void SetGeomType( OGRwkbGeometryType );
303
304 virtual OGRFeatureDefn *Clone() const;
305
306 int Reference() { return CPLAtomicInc(&nRefCount); }
307 int Dereference() { return CPLAtomicDec(&nRefCount); }
308 int GetReferenceCount() const { return nRefCount; }
309 void Release();
310
311 virtual int IsGeometryIgnored() const;
312 virtual void SetGeometryIgnored( int bIgnore );
313 virtual int IsStyleIgnored() const { return bIgnoreStyle; }
314 virtual void SetStyleIgnored( int bIgnore )
315 { bIgnoreStyle = bIgnore; }
316
317 virtual int IsSame( const OGRFeatureDefn * poOtherFeatureDefn ) const;
318
320 void ReserveSpaceForFields(int nFieldCountIn);
322
323 std::vector<int> ComputeMapForSetFrom( const OGRFeatureDefn* poSrcFDefn,
324 bool bForgiving = true ) const;
325
326 static OGRFeatureDefn *CreateFeatureDefn( const char *pszName = nullptr );
327 static void DestroyFeatureDefn( OGRFeatureDefn * );
328
332 static inline OGRFeatureDefnH ToHandle(OGRFeatureDefn* poFeatureDefn)
333 { return reinterpret_cast<OGRFeatureDefnH>(poFeatureDefn); }
334
338 static inline OGRFeatureDefn* FromHandle(OGRFeatureDefnH hFeatureDefn)
339 { return reinterpret_cast<OGRFeatureDefn*>(hFeatureDefn); }
340
341 private:
342 CPL_DISALLOW_COPY_ASSIGN(OGRFeatureDefn)
343 };
344
345 /************************************************************************/
346 /* OGRFeature */
347 /************************************************************************/
348
353 class CPL_DLL OGRFeature
354 {
355 private:
356
357 GIntBig nFID;
358 OGRFeatureDefn *poDefn;
359 OGRGeometry **papoGeometries;
360 OGRField *pauFields;
361 char *m_pszNativeData;
362 char *m_pszNativeMediaType;
363
364 bool SetFieldInternal( int i, OGRField * puValue );
365
366 protected:
368 mutable char *m_pszStyleString;
369 mutable OGRStyleTable *m_poStyleTable;
370 mutable char *m_pszTmpFieldValue;
372
373 bool CopySelfTo( OGRFeature *poNew ) const;
374
375 public:
376 explicit OGRFeature( OGRFeatureDefn * );
377 virtual ~OGRFeature();
378
380 class CPL_DLL FieldValue
381 {
382 friend class OGRFeature;
383 struct Private;
384 std::unique_ptr<Private> m_poPrivate;
385
386 FieldValue(OGRFeature* poFeature, int iFieldIndex);
387 FieldValue(const OGRFeature* poFeature, int iFieldIndex);
388 FieldValue(const FieldValue& oOther) = delete;
389
390 public:
392 ~FieldValue();
394
396 FieldValue& operator= (const FieldValue& oOther);
398 FieldValue& operator= (int nVal);
400 FieldValue& operator= (GIntBig nVal);
402 FieldValue& operator= (double dfVal);
404 FieldValue& operator= (const char *pszVal);
406 FieldValue& operator= (const std::string& osVal);
408 FieldValue& operator= (const std::vector<int>& oArray);
410 FieldValue& operator= (const std::vector<GIntBig>& oArray);
412 FieldValue& operator= (const std::vector<double>& oArray);
414 FieldValue& operator= (const std::vector<std::string>& oArray);
416 FieldValue& operator= (CSLConstList papszValues);
418 void SetNull();
420 void clear();
422 void Unset() { clear(); }
424 void SetDateTime(int nYear, int nMonth, int nDay,
425 int nHour=0, int nMinute=0, float fSecond=0.f,
426 int nTZFlag = 0 );
427
429 int GetIndex() const;
431 const OGRFieldDefn* GetDefn() const;
433 const char* GetName() const { return GetDefn()->GetNameRef(); }
435 OGRFieldType GetType() const { return GetDefn()->GetType(); }
437 OGRFieldSubType GetSubType() const { return GetDefn()->GetSubType(); }
438
440 // cppcheck-suppress functionStatic
441 bool empty() const { return IsUnset(); }
442
444 // cppcheck-suppress functionStatic
445 bool IsUnset() const;
446
448 // cppcheck-suppress functionStatic
449 bool IsNull() const;
450
452 const OGRField *GetRawValue() const;
453
457 // cppcheck-suppress functionStatic
458 int GetInteger() const { return GetRawValue()->Integer; }
459
463 // cppcheck-suppress functionStatic
464 GIntBig GetInteger64() const { return GetRawValue()->Integer64; }
465
469 // cppcheck-suppress functionStatic
470 double GetDouble() const { return GetRawValue()->Real; }
471
475 // cppcheck-suppress functionStatic
476 const char* GetString() const { return GetRawValue()->String; }
477
479 bool GetDateTime( int *pnYear, int *pnMonth,
480 int *pnDay,
481 int *pnHour, int *pnMinute,
482 float *pfSecond,
483 int *pnTZFlag ) const;
484
486 operator int () const { return GetAsInteger(); }
488 operator GIntBig() const { return GetAsInteger64(); }
490 operator double () const { return GetAsDouble(); }
492 operator const char*() const { return GetAsString(); }
494 operator const std::vector<int>& () const { return GetAsIntegerList(); }
496 operator const std::vector<GIntBig>& () const { return GetAsInteger64List(); }
498 operator const std::vector<double>& () const { return GetAsDoubleList(); }
500 operator const std::vector<std::string>& () const { return GetAsStringList(); }
502 operator CSLConstList () const;
503
505 int GetAsInteger() const;
507 GIntBig GetAsInteger64() const;
509 double GetAsDouble() const;
511 const char* GetAsString() const;
513 const std::vector<int>& GetAsIntegerList() const;
515 const std::vector<GIntBig>& GetAsInteger64List() const;
517 const std::vector<double>& GetAsDoubleList() const;
519 const std::vector<std::string>& GetAsStringList() const;
520 };
521
523 class CPL_DLL ConstFieldIterator
524 {
525 friend class OGRFeature;
526 struct Private;
527 std::unique_ptr<Private> m_poPrivate;
528
529 ConstFieldIterator(const OGRFeature* poSelf, int nPos);
530
531 public:
533 ConstFieldIterator(ConstFieldIterator&& oOther); // declared but not defined. Needed for gcc 5.4 at least
534 ~ConstFieldIterator();
535 const FieldValue& operator*() const;
536 ConstFieldIterator& operator++();
537 bool operator!=(const ConstFieldIterator& it) const;
539 };
540
557 ConstFieldIterator begin() const;
559 ConstFieldIterator end() const;
560
561 const FieldValue operator[](int iField) const;
562 FieldValue operator[](int iField);
563
565 class FieldNotFoundException: public std::exception {};
566
567 const FieldValue operator[](const char* pszFieldName) const;
568 FieldValue operator[](const char* pszFieldName);
569
570 OGRFeatureDefn *GetDefnRef() { return poDefn; }
571 const OGRFeatureDefn *GetDefnRef() const { return poDefn; }
572
573 OGRErr SetGeometryDirectly( OGRGeometry * );
574 OGRErr SetGeometry( const OGRGeometry * );
575 OGRGeometry *GetGeometryRef();
576 const OGRGeometry *GetGeometryRef() const;
577 OGRGeometry *StealGeometry() CPL_WARN_UNUSED_RESULT;
578
579 int GetGeomFieldCount() const
580 { return poDefn->GetGeomFieldCount(); }
581 OGRGeomFieldDefn *GetGeomFieldDefnRef( int iField )
582 { return poDefn->GetGeomFieldDefn(iField); }
583 const OGRGeomFieldDefn *GetGeomFieldDefnRef( int iField ) const
584 { return poDefn->GetGeomFieldDefn(iField); }
585 int GetGeomFieldIndex( const char * pszName ) const
586 { return poDefn->GetGeomFieldIndex(pszName); }
587
588 OGRGeometry* GetGeomFieldRef( int iField );
589 const OGRGeometry* GetGeomFieldRef( int iField ) const;
590 OGRGeometry* StealGeometry( int iField );
591 OGRGeometry* GetGeomFieldRef( const char* pszFName );
592 const OGRGeometry* GetGeomFieldRef( const char* pszFName ) const;
593 OGRErr SetGeomFieldDirectly( int iField, OGRGeometry * );
594 OGRErr SetGeomField( int iField, const OGRGeometry * );
595
596 OGRFeature *Clone() const CPL_WARN_UNUSED_RESULT;
597 virtual OGRBoolean Equal( const OGRFeature * poFeature ) const;
598
599 int GetFieldCount() const
600 { return poDefn->GetFieldCount(); }
601 const OGRFieldDefn *GetFieldDefnRef( int iField ) const
602 { return poDefn->GetFieldDefn(iField); }
603 OGRFieldDefn *GetFieldDefnRef( int iField )
604 { return poDefn->GetFieldDefn(iField); }
605 int GetFieldIndex( const char * pszName ) const
606 { return poDefn->GetFieldIndex(pszName); }
607
608 int IsFieldSet( int iField ) const;
609
610 void UnsetField( int iField );
611
612 bool IsFieldNull( int iField ) const;
613
614 void SetFieldNull( int iField );
615
616 bool IsFieldSetAndNotNull( int iField ) const;
617
618 OGRField *GetRawFieldRef( int i ) { return pauFields + i; }
619 const OGRField *GetRawFieldRef( int i ) const { return pauFields + i; }
620
621 int GetFieldAsInteger( int i ) const;
622 GIntBig GetFieldAsInteger64( int i ) const;
623 double GetFieldAsDouble( int i ) const;
624 const char *GetFieldAsString( int i ) const;
625 const int *GetFieldAsIntegerList( int i, int *pnCount ) const;
626 const GIntBig *GetFieldAsInteger64List( int i, int *pnCount ) const;
627 const double *GetFieldAsDoubleList( int i, int *pnCount ) const;
628 char **GetFieldAsStringList( int i ) const;
629 GByte *GetFieldAsBinary( int i, int *pnCount ) const;
630 int GetFieldAsDateTime( int i,
631 int *pnYear, int *pnMonth,
632 int *pnDay,
633 int *pnHour, int *pnMinute,
634 int *pnSecond,
635 int *pnTZFlag ) const;
636 int GetFieldAsDateTime( int i,
637 int *pnYear, int *pnMonth,
638 int *pnDay,
639 int *pnHour, int *pnMinute,
640 float *pfSecond,
641 int *pnTZFlag ) const;
642 char *GetFieldAsSerializedJSon( int i ) const;
643
644 int GetFieldAsInteger( const char *pszFName ) const
645 { return GetFieldAsInteger( GetFieldIndex(pszFName) ); }
646 GIntBig GetFieldAsInteger64( const char *pszFName ) const
647 { return GetFieldAsInteger64( GetFieldIndex(pszFName) ); }
648 double GetFieldAsDouble( const char *pszFName ) const
649 { return GetFieldAsDouble( GetFieldIndex(pszFName) ); }
650 const char *GetFieldAsString( const char *pszFName ) const
651 { return GetFieldAsString( GetFieldIndex(pszFName) ); }
652 const int *GetFieldAsIntegerList( const char *pszFName,
653 int *pnCount ) const
654 { return GetFieldAsIntegerList( GetFieldIndex(pszFName),
655 pnCount ); }
656 const GIntBig *GetFieldAsInteger64List( const char *pszFName,
657 int *pnCount ) const
658 { return GetFieldAsInteger64List( GetFieldIndex(pszFName),
659 pnCount ); }
660 const double *GetFieldAsDoubleList( const char *pszFName,
661 int *pnCount ) const
662 { return GetFieldAsDoubleList( GetFieldIndex(pszFName),
663 pnCount ); }
664 char **GetFieldAsStringList( const char *pszFName ) const
665 { return GetFieldAsStringList(GetFieldIndex(pszFName)); }
666
667 void SetField( int i, int nValue );
668 void SetField( int i, GIntBig nValue );
669 void SetField( int i, double dfValue );
670 void SetField( int i, const char * pszValue );
671 void SetField( int i, int nCount, const int * panValues );
672 void SetField( int i, int nCount,
673 const GIntBig * panValues );
674 void SetField( int i, int nCount, const double * padfValues );
675 void SetField( int i, const char * const * papszValues );
676 void SetField( int i, OGRField * puValue );
677 void SetField( int i, int nCount, GByte * pabyBinary );
678 void SetField( int i, int nYear, int nMonth, int nDay,
679 int nHour=0, int nMinute=0, float fSecond=0.f,
680 int nTZFlag = 0 );
681
682 void SetField( const char *pszFName, int nValue )
683 { SetField( GetFieldIndex(pszFName), nValue ); }
684 void SetField( const char *pszFName, GIntBig nValue )
685 { SetField( GetFieldIndex(pszFName), nValue ); }
686 void SetField( const char *pszFName, double dfValue )
687 { SetField( GetFieldIndex(pszFName), dfValue ); }
688 void SetField( const char *pszFName, const char * pszValue )
689 { SetField( GetFieldIndex(pszFName), pszValue ); }
690 void SetField( const char *pszFName, int nCount,
691 const int * panValues )
692 { SetField(GetFieldIndex(pszFName),nCount,panValues); }
693 void SetField( const char *pszFName, int nCount,
694 const GIntBig * panValues )
695 { SetField(GetFieldIndex(pszFName),nCount,panValues); }
696 void SetField( const char *pszFName, int nCount,
697 const double * padfValues )
698 {SetField(GetFieldIndex(pszFName),nCount,padfValues); }
699 void SetField( const char *pszFName, const char * const * papszValues )
700 { SetField( GetFieldIndex(pszFName), papszValues); }
701 void SetField( const char *pszFName, OGRField * puValue )
702 { SetField( GetFieldIndex(pszFName), puValue ); }
703 void SetField( const char *pszFName,
704 int nYear, int nMonth, int nDay,
705 int nHour=0, int nMinute=0, float fSecond=0.f,
706 int nTZFlag = 0 )
707 { SetField( GetFieldIndex(pszFName),
708 nYear, nMonth, nDay,
709 nHour, nMinute, fSecond, nTZFlag ); }
710
711 GIntBig GetFID() const { return nFID; }
712 virtual OGRErr SetFID( GIntBig nFIDIn );
713
714 void DumpReadable( FILE *, char** papszOptions = nullptr ) const;
715
716 OGRErr SetFrom( const OGRFeature *, int = TRUE );
717 OGRErr SetFrom( const OGRFeature *, const int *, int = TRUE );
718 OGRErr SetFieldsFrom( const OGRFeature *, const int *, int = TRUE );
719
721 OGRErr RemapFields( OGRFeatureDefn *poNewDefn,
722 const int *panRemapSource );
723 void AppendField();
724 OGRErr RemapGeomFields( OGRFeatureDefn *poNewDefn,
725 const int *panRemapSource );
727
728 int Validate( int nValidateFlags,
729 int bEmitError ) const;
730 void FillUnsetWithDefault( int bNotNullableOnly,
731 char** papszOptions );
732
733 virtual const char *GetStyleString() const;
734 virtual void SetStyleString( const char * );
735 virtual void SetStyleStringDirectly( char * );
736
740 virtual OGRStyleTable *GetStyleTable() const { return m_poStyleTable; } /* f.i.x.m.e: add a const qualifier for return type */
741 virtual void SetStyleTable( OGRStyleTable *poStyleTable );
742 virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
743
744 const char *GetNativeData() const { return m_pszNativeData; }
745 const char *GetNativeMediaType() const
746 { return m_pszNativeMediaType; }
747 void SetNativeData( const char* pszNativeData );
748 void SetNativeMediaType( const char* pszNativeMediaType );
749
750 static OGRFeature *CreateFeature( OGRFeatureDefn * );
751 static void DestroyFeature( OGRFeature * );
752
756 static inline OGRFeatureH ToHandle(OGRFeature* poFeature)
757 { return reinterpret_cast<OGRFeatureH>(poFeature); }
758
762 static inline OGRFeature* FromHandle(OGRFeatureH hFeature)
763 { return reinterpret_cast<OGRFeature*>(hFeature); }
764
765 private:
766 CPL_DISALLOW_COPY_ASSIGN(OGRFeature)
767 };
768
770 struct CPL_DLL OGRFeatureUniquePtrDeleter
771 {
772 void operator()(OGRFeature*) const;
773 };
775
779 typedef std::unique_ptr<OGRFeature, OGRFeatureUniquePtrDeleter> OGRFeatureUniquePtr;
780
782
783 inline OGRFeature::ConstFieldIterator begin(const OGRFeature* poFeature) { return poFeature->begin(); }
785 inline OGRFeature::ConstFieldIterator end(const OGRFeature* poFeature) { return poFeature->end(); }
786
788 inline OGRFeature::ConstFieldIterator begin(const OGRFeatureUniquePtr& poFeature) { return poFeature->begin(); }
790 inline OGRFeature::ConstFieldIterator end(const OGRFeatureUniquePtr& poFeature) { return poFeature->end(); }
791
793
794 /************************************************************************/
795 /* OGRFeatureQuery */
796 /************************************************************************/
797
799 class OGRLayer;
800 class swq_expr_node;
801 class swq_custom_func_registrar;
802
803 class CPL_DLL OGRFeatureQuery
804 {
805 private:
806 OGRFeatureDefn *poTargetDefn;
807 void *pSWQExpr;
808
809 char **FieldCollector( void *, char ** );
810
811 GIntBig *EvaluateAgainstIndices( swq_expr_node*, OGRLayer *,
812 GIntBig& nFIDCount );
813
814 int CanUseIndex( swq_expr_node*, OGRLayer * );
815
816 OGRErr Compile( OGRLayer *, OGRFeatureDefn*, const char *,
817 int bCheck,
818 swq_custom_func_registrar* poCustomFuncRegistrar );
819 public:
820 OGRFeatureQuery();
821 ~OGRFeatureQuery();
822
823 OGRErr Compile( OGRLayer *, const char *,
824 int bCheck = TRUE,
825 swq_custom_func_registrar*
826 poCustomFuncRegistrar = nullptr );
827 OGRErr Compile( OGRFeatureDefn *, const char *,
828 int bCheck = TRUE,
829 swq_custom_func_registrar*
830 poCustomFuncRegistrar = nullptr );
831 int Evaluate( OGRFeature * );
832
833 GIntBig *EvaluateAgainstIndices( OGRLayer *, OGRErr * );
834
835 int CanUseIndex( OGRLayer * );
836
837 char **GetUsedFields();
838
839 void *GetSWQExpr() { return pSWQExpr; }
840 };
842
843 #endif /* ndef OGR_FEATURE_H_INCLUDED */
OGRFeatureDefn::ToHandle
static OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
Convert a OGRFeatureDefn* to a OGRFeatureDefnH.
Definition: ogr_feature.h:332
OGRFeature::SetField
void SetField(const char *pszFName, int nCount, const int *panValues)
Set field to list of integers value.
Definition: ogr_feature.h:690
OGRFeatureDefn::GetGeomFieldCount
virtual int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition: ogrfeaturedefn.cpp:631
OGRFieldDefn::GetSubType
OGRFieldSubType GetSubType() const
Fetch subtype of this field.
Definition: ogr_feature.h:119
OGRFeatureUniquePtr
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:779
OGRFeature::SetField
void SetField(const char *pszFName, int nCount, const double *padfValues)
Set field to list of doubles value.
Definition: ogr_feature.h:696
OGRFieldSubType
OGRFieldSubType
List of field subtypes.
Definition: ogr_core.h:622
OGRFeature::FromHandle
static OGRFeature * FromHandle(OGRFeatureH hFeature)
Convert a OGRFeatureH to a OGRFeature*.
Definition: ogr_feature.h:762
OGRGeomFieldDefnH
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_feature.h:69
OGRFieldDefn::GetJustify
OGRJustification GetJustify() const
Get the justification for this field.
Definition: ogr_feature.h:123
OGRFeatureH
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_feature.h:64
OGRFeature::FieldValue::GetDouble
double GetDouble() const
Return the double value.
Definition: ogr_feature.h:470
OGRFeature::GetFieldAsString
const char * GetFieldAsString(const char *pszFName) const
Fetch field value as a string.
Definition: ogr_feature.h:650
OGRFeature::SetField
void SetField(const char *pszFName, double dfValue)
Set field to double value.
Definition: ogr_feature.h:686
OGRFeature::GetRawFieldRef
OGRField * GetRawFieldRef(int i)
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:618
OGRGeomFieldDefn::IsIgnored
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:211
OGRFeatureDefn::FromHandle
static OGRFeatureDefn * FromHandle(OGRFeatureDefnH hFeatureDefn)
Convert a OGRFeatureDefnH to a OGRFeatureDefn*.
Definition: ogr_feature.h:338
OGRGeomFieldDefn::SetNullable
void SetNullable(int bNullableIn)
Set whether this geometry field can receive null values.
Definition: ogr_feature.h:215
OGRGeomFieldDefn
Definition of a geometry field of an OGRFeatureDefn.
Definition: ogr_feature.h:182
OGRFieldDefn::ToHandle
static OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
Convert a OGRFieldDefn* to a OGRFieldDefnH.
Definition: ogr_feature.h:152
OGRFeatureDefn::IsStyleIgnored
virtual int IsStyleIgnored() const
Determine whether the style can be omitted when fetching features.
Definition: ogr_feature.h:313
OGRGeomFieldDefn::FromHandle
static OGRGeomFieldDefn * FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
Convert a OGRGeomFieldDefnH to a OGRGeomFieldDefn*.
Definition: ogr_feature.h:229
OGRGeomFieldDefn::GetNameRef
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:203
OGRFeature::GetGeomFieldDefnRef
const OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField) const
Fetch definition for this geometry field.
Definition: ogr_feature.h:583
OGRFeatureDefn::SetStyleIgnored
virtual void SetStyleIgnored(int bIgnore)
Set whether the style can be omitted when fetching features.
Definition: ogr_feature.h:314
OGRFeature::SetField
void SetField(const char *pszFName, OGRField *puValue)
Set field.
Definition: ogr_feature.h:701
OGRFeature::FieldNotFoundException
Exception raised by operator[](const char*) when a field is not found.
Definition: ogr_feature.h:565
OGRBoolean
int OGRBoolean
Type for a OGR boolean.
Definition: ogr_core.h:306
OGRStyleTableH
void * OGRStyleTableH
Opaque type for a style table (OGRStyleTable)
Definition: ogr_feature.h:66
GByte
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:213
OGRFeature::FieldValue::GetName
const char * GetName() const
Return field name.
Definition: ogr_feature.h:433
OGRFeature::FieldValue::GetInteger
int GetInteger() const
Return the integer value.
Definition: ogr_feature.h:458
OGRFeature::GetFieldIndex
int GetFieldIndex(const char *pszName) const
Fetch the field index given field name.
Definition: ogr_feature.h:605
OGRFieldDefn::GetWidth
int GetWidth() const
Get the formatting width for this field.
Definition: ogr_feature.h:127
OGRFeatureDefn::GetFieldIndex
virtual int GetFieldIndex(const char *) const
Find field by name.
Definition: ogrfeaturedefn.cpp:1217
OGRFeature::FieldValue::GetInteger64
GIntBig GetInteger64() const
Return the 64-bit integer value.
Definition: ogr_feature.h:464
OGRFeatureDefn
Definition of a feature class or feature layer.
Definition: ogr_feature.h:259
OGRFeature::GetRawFieldRef
const OGRField * GetRawFieldRef(int i) const
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:619
OGRFeature::FieldValue::empty
bool empty() const
Return whether the field value is unset/empty.
Definition: ogr_feature.h:441
OGRFieldDefn::FromHandle
static OGRFieldDefn * FromHandle(OGRFieldDefnH hFieldDefn)
Convert a OGRFieldDefnH to a OGRFieldDefn*.
Definition: ogr_feature.h:158
OGRFieldDefn::GetType
OGRFieldType GetType() const
Fetch type of this field.
Definition: ogr_feature.h:115
OGRFeature::SetField
void SetField(const char *pszFName, const char *const *papszValues)
Set field to list of strings value.
Definition: ogr_feature.h:699
ogr_featurestyle.h
Simple feature style classes.
OGRFeature::GetFieldAsInteger64
GIntBig GetFieldAsInteger64(const char *pszFName) const
Fetch field value as integer 64 bit.
Definition: ogr_feature.h:646
OGRFeature::SetField
void SetField(const char *pszFName, int nValue)
Set field to integer value.
Definition: ogr_feature.h:682
OGRFieldDefn::GetPrecision
int GetPrecision() const
Get the formatting precision for this field.
Definition: ogr_feature.h:130
OGRFieldDefn
Definition of an attribute of an OGRFeatureDefn.
Definition: ogr_feature.h:92
OGRFeature::GetGeomFieldIndex
int GetGeomFieldIndex(const char *pszName) const
Fetch the geometry field index given geometry field name.
Definition: ogr_feature.h:585
OGRFieldDefnH
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_feature.h:60
OGRFeatureDefn::GetGeomFieldIndex
virtual int GetGeomFieldIndex(const char *) const
Find geometry field by name.
Definition: ogrfeaturedefn.cpp:915
MAX
#define MAX(a, b)
Macro to compute the maximum of 2 values.
Definition: cpl_port.h:397
OGRFieldDefnH
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_api.h:297
OGRFeature::FieldValue::GetSubType
OGRFieldSubType GetSubType() const
Return field subtype.
Definition: ogr_feature.h:437
OGRFeature::GetFID
GIntBig GetFID() const
Get feature identifier.
Definition: ogr_feature.h:711
OGRGeomFieldDefnH
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_api.h:306
OGRFeature::FieldValue::Unset
void Unset()
Unset the field.
Definition: ogr_feature.h:422
OGRwkbGeometryType
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:317
OGRFeature::FieldValue::GetString
const char * GetString() const
Return the string value.
Definition: ogr_feature.h:476
OGRFeature::GetNativeMediaType
const char * GetNativeMediaType() const
Returns the native media type for the feature.
Definition: ogr_feature.h:745
OGRFeature::ConstFieldIterator
Field value iterator class.
Definition: ogr_feature.h:523
OGRFeatureDefn::GetGeomFieldDefn
virtual OGRGeomFieldDefn * GetGeomFieldDefn(int i)
Fetch geometry field definition.
Definition: ogrfeaturedefn.cpp:680
OGRFeature::GetFieldDefnRef
OGRFieldDefn * GetFieldDefnRef(int iField)
Fetch definition for this field.
Definition: ogr_feature.h:603
OGRFieldDefn::SetPrecision
void SetPrecision(int nPrecisionIn)
Set the formatting precision for this field in characters.
Definition: ogr_feature.h:131
OGRGeometry
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:286
OGRGeomFieldDefn::GetType
OGRwkbGeometryType GetType() const
Fetch geometry type of this field.
Definition: ogr_feature.h:205
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1184
OGRGeomFieldDefn::ToHandle
static OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
Convert a OGRGeomFieldDefn* to a OGRGeomFieldDefnH.
Definition: ogr_feature.h:223
OGRFeatureDefn::GetReferenceCount
int GetReferenceCount() const
Fetch current reference count.
Definition: ogr_feature.h:308
OGRFieldDefn::IsNullable
int IsNullable() const
Return whether this field can receive null values.
Definition: ogr_feature.h:144
OGRFieldDefn::SetWidth
void SetWidth(int nWidthIn)
Set the formatting width for this field in characters.
Definition: ogr_feature.h:128
OGRFeature::FieldValue
Field value.
Definition: ogr_feature.h:380
OGRJustification
OGRJustification
Display justification for field values.
Definition: ogr_core.h:638
OGRFeature::SetField
void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
Set field to list of 64 bit integers value.
Definition: ogr_feature.h:693
OGRFeatureDefn::Reference
int Reference()
Increments the reference count by one.
Definition: ogr_feature.h:306
OGRFeature::end
ConstFieldIterator end() const
Return end of field value iterator.
Definition: ogrfeature.cpp:7090
OGRFieldType
OGRFieldType
List of feature field types.
Definition: ogr_core.h:594
OGRFeatureDefnH
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_feature.h:62
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:145
OGRFeature::GetFieldAsInteger64List
const GIntBig * GetFieldAsInteger64List(const char *pszFName, int *pnCount) const
Fetch field value as a list of 64 bit integers.
Definition: ogr_feature.h:656
OGRFeature::SetField
void SetField(const char *pszFName, GIntBig nValue)
Set field to 64 bit integer value.
Definition: ogr_feature.h:684
OGRFeature::GetStyleTable
virtual OGRStyleTable * GetStyleTable() const
Return style table.
Definition: ogr_feature.h:740
OGRFeatureH
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_api.h:301
OGRFeature::GetDefnRef
const OGRFeatureDefn * GetDefnRef() const
Fetch feature definition.
Definition: ogr_feature.h:571
OGRFeatureDefn::Dereference
int Dereference()
Decrements the reference count by one.
Definition: ogr_feature.h:307
OGRFeature::GetFieldAsDoubleList
const double * GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
Fetch field value as a list of doubles.
Definition: ogr_feature.h:660
OGRFieldDefn::GetNameRef
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:113
OGRField
OGRFeature field attribute value union.
Definition: ogr_core.h:679
OGRGeomFieldDefn::SetIgnored
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:212
OGRLayer
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:70
OGRFieldDefn::IsIgnored
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:141
OGRFeature::GetFieldAsInteger
int GetFieldAsInteger(const char *pszFName) const
Fetch field value as integer.
Definition: ogr_feature.h:644
OGRFeature::GetGeomFieldDefnRef
OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField)
Fetch definition for this geometry field.
Definition: ogr_feature.h:581
OGRFeature
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:353
OGRFeatureDefn::GetFieldDefn
virtual OGRFieldDefn * GetFieldDefn(int i)
Fetch field definition.
Definition: ogrfeaturedefn.cpp:329
OGRFeature::ToHandle
static OGRFeatureH ToHandle(OGRFeature *poFeature)
Convert a OGRFeature* to a OGRFeatureH.
Definition: ogr_feature.h:756
OGRStyleTable
This class represents a style table.
Definition: ogr_featurestyle.h:84
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:246
OGRFeature::SetField
void SetField(const char *pszFName, const char *pszValue)
Set field to string value.
Definition: ogr_feature.h:688
OGRFeature::FieldValue::GetType
OGRFieldType GetType() const
Return field type.
Definition: ogr_feature.h:435
OGRFeature::GetFieldAsStringList
char ** GetFieldAsStringList(const char *pszFName) const
Fetch field value as a list of strings.
Definition: ogr_feature.h:664
OGRFeature::GetFieldAsDouble
double GetFieldAsDouble(const char *pszFName) const
Fetch field value as a double.
Definition: ogr_feature.h:648
begin
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:287
OGRFeature::GetNativeData
const char * GetNativeData() const
Returns the native data for the feature.
Definition: ogr_feature.h:744
OGRFeature::begin
ConstFieldIterator begin() const
Return begin of field value iterator.
Definition: ogrfeature.cpp:7085
ogr_geometry.h
Simple feature geometry classes.
OGRFieldDefn::SetJustify
void SetJustify(OGRJustification eJustifyIn)
Set the justification for this field.
Definition: ogr_feature.h:124
OGRErr
int OGRErr
Simple container for a bounding region.
Definition: ogr_core.h:290
OGRGeomFieldDefn::IsNullable
int IsNullable() const
Return whether this geometry field can receive null values.
Definition: ogr_feature.h:214
OGRFeature::GetDefnRef
OGRFeatureDefn * GetDefnRef()
Fetch feature definition.
Definition: ogr_feature.h:570
OGRFeatureDefnH
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_api.h:299
end
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:292
OGRFeature::GetFieldAsIntegerList
const int * GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
Fetch field value as a list of integers.
Definition: ogr_feature.h:652
OGRFeature::SetField
void SetField(const char *pszFName, int nYear, int nMonth, int nDay, int nHour=0, int nMinute=0, float fSecond=0.f, int nTZFlag=0)
Set field to date.
Definition: ogr_feature.h:703
OGRFeature::GetFieldDefnRef
const OGRFieldDefn * GetFieldDefnRef(int iField) const
Fetch definition for this field.
Definition: ogr_feature.h:601
OGRFieldDefn::SetIgnored
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:142
OGRFeatureDefn::GetFieldCount
virtual int GetFieldCount() const
Fetch number of fields on this feature.
Definition: ogrfeaturedefn.cpp:285
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:987
OGRFieldDefn::SetNullable
void SetNullable(int bNullableIn)
Set whether this field can receive null values.
Definition: ogr_feature.h:145
CPL_WARN_UNUSED_RESULT
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:929

Generated for GDAL by 1.8.8.