GDAL
ogr_feature.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: ogr_feature.h 03663aa9cc098380fe5420faa4f424c3dac45a08 2018-10-29 23:18:12 +0100 Even Rouault $
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:
162 };
163 
164 /************************************************************************/
165 /* OGRGeomFieldDefn */
166 /************************************************************************/
167 
182 class CPL_DLL OGRGeomFieldDefn
183 {
184 protected:
186  char *pszName = nullptr;
187  OGRwkbGeometryType eGeomType = wkbUnknown; /* all values possible except wkbNone */
188  mutable OGRSpatialReference* poSRS = nullptr;
189 
190  int bIgnore = false;
191  mutable int bNullable = true;
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:
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  int GetFieldIndexCaseSensitive( const char * ) const;
288 
289  virtual void AddFieldDefn( OGRFieldDefn * );
290  virtual OGRErr DeleteFieldDefn( int iField );
291  virtual OGRErr ReorderFieldDefns( int* panMap );
292 
293  virtual int GetGeomFieldCount() const;
294  virtual OGRGeomFieldDefn *GetGeomFieldDefn( int i );
295  virtual const OGRGeomFieldDefn *GetGeomFieldDefn( int i ) const;
296  virtual int GetGeomFieldIndex( const char * ) const;
297 
298  virtual void AddGeomFieldDefn( OGRGeomFieldDefn *,
299  int bCopy = TRUE );
300  virtual OGRErr DeleteGeomFieldDefn( int iGeomField );
301 
302  virtual OGRwkbGeometryType GetGeomType() const;
303  virtual void SetGeomType( OGRwkbGeometryType );
304 
305  virtual OGRFeatureDefn *Clone() const;
306 
307  int Reference() { return CPLAtomicInc(&nRefCount); }
308  int Dereference() { return CPLAtomicDec(&nRefCount); }
309  int GetReferenceCount() const { return nRefCount; }
310  void Release();
311 
312  virtual int IsGeometryIgnored() const;
313  virtual void SetGeometryIgnored( int bIgnore );
314  virtual int IsStyleIgnored() const { return bIgnoreStyle; }
315  virtual void SetStyleIgnored( int bIgnore )
316  { bIgnoreStyle = bIgnore; }
317 
318  virtual int IsSame( const OGRFeatureDefn * poOtherFeatureDefn ) const;
319 
321  void ReserveSpaceForFields(int nFieldCountIn);
323 
324  std::vector<int> ComputeMapForSetFrom( const OGRFeatureDefn* poSrcFDefn,
325  bool bForgiving = true ) const;
326 
327  static OGRFeatureDefn *CreateFeatureDefn( const char *pszName = nullptr );
328  static void DestroyFeatureDefn( OGRFeatureDefn * );
329 
333  static inline OGRFeatureDefnH ToHandle(OGRFeatureDefn* poFeatureDefn)
334  { return reinterpret_cast<OGRFeatureDefnH>(poFeatureDefn); }
335 
339  static inline OGRFeatureDefn* FromHandle(OGRFeatureDefnH hFeatureDefn)
340  { return reinterpret_cast<OGRFeatureDefn*>(hFeatureDefn); }
341 
342  private:
344 };
345 
346 /************************************************************************/
347 /* OGRFeature */
348 /************************************************************************/
349 
354 class CPL_DLL OGRFeature
355 {
356  private:
357 
358  GIntBig nFID;
359  OGRFeatureDefn *poDefn;
360  OGRGeometry **papoGeometries;
361  OGRField *pauFields;
362  char *m_pszNativeData;
363  char *m_pszNativeMediaType;
364 
365  bool SetFieldInternal( int i, OGRField * puValue );
366 
367  protected:
369  mutable char *m_pszStyleString;
370  mutable OGRStyleTable *m_poStyleTable;
371  mutable char *m_pszTmpFieldValue;
373 
374  bool CopySelfTo( OGRFeature *poNew ) const;
375 
376  public:
377  explicit OGRFeature( OGRFeatureDefn * );
378  virtual ~OGRFeature();
379 
381  class CPL_DLL FieldValue
382  {
383  friend class OGRFeature;
384  struct Private;
385  std::unique_ptr<Private> m_poPrivate;
386 
387  FieldValue(OGRFeature* poFeature, int iFieldIndex);
388  FieldValue(const OGRFeature* poFeature, int iFieldIndex);
389  FieldValue(const FieldValue& oOther) = delete;
390 
391  public:
393  ~FieldValue();
395 
397  FieldValue& operator= (const FieldValue& oOther);
399  FieldValue& operator= (int nVal);
401  FieldValue& operator= (GIntBig nVal);
403  FieldValue& operator= (double dfVal);
405  FieldValue& operator= (const char *pszVal);
407  FieldValue& operator= (const std::string& osVal);
409  FieldValue& operator= (const std::vector<int>& oArray);
411  FieldValue& operator= (const std::vector<GIntBig>& oArray);
413  FieldValue& operator= (const std::vector<double>& oArray);
415  FieldValue& operator= (const std::vector<std::string>& oArray);
417  FieldValue& operator= (CSLConstList papszValues);
419  void SetNull();
421  void clear();
423  void Unset() { clear(); }
425  void SetDateTime(int nYear, int nMonth, int nDay,
426  int nHour=0, int nMinute=0, float fSecond=0.f,
427  int nTZFlag = 0 );
428 
430  int GetIndex() const;
432  const OGRFieldDefn* GetDefn() const;
434  const char* GetName() const { return GetDefn()->GetNameRef(); }
436  OGRFieldType GetType() const { return GetDefn()->GetType(); }
438  OGRFieldSubType GetSubType() const { return GetDefn()->GetSubType(); }
439 
441  // cppcheck-suppress functionStatic
442  bool empty() const { return IsUnset(); }
443 
445  // cppcheck-suppress functionStatic
446  bool IsUnset() const;
447 
449  // cppcheck-suppress functionStatic
450  bool IsNull() const;
451 
453  const OGRField *GetRawValue() const;
454 
458  // cppcheck-suppress functionStatic
459  int GetInteger() const { return GetRawValue()->Integer; }
460 
464  // cppcheck-suppress functionStatic
465  GIntBig GetInteger64() const { return GetRawValue()->Integer64; }
466 
470  // cppcheck-suppress functionStatic
471  double GetDouble() const { return GetRawValue()->Real; }
472 
476  // cppcheck-suppress functionStatic
477  const char* GetString() const { return GetRawValue()->String; }
478 
480  bool GetDateTime( int *pnYear, int *pnMonth,
481  int *pnDay,
482  int *pnHour, int *pnMinute,
483  float *pfSecond,
484  int *pnTZFlag ) const;
485 
487  operator int () const { return GetAsInteger(); }
489  operator GIntBig() const { return GetAsInteger64(); }
491  operator double () const { return GetAsDouble(); }
493  operator const char*() const { return GetAsString(); }
495  operator const std::vector<int>& () const { return GetAsIntegerList(); }
497  operator const std::vector<GIntBig>& () const { return GetAsInteger64List(); }
499  operator const std::vector<double>& () const { return GetAsDoubleList(); }
501  operator const std::vector<std::string>& () const { return GetAsStringList(); }
503  operator CSLConstList () const;
504 
506  int GetAsInteger() const;
508  GIntBig GetAsInteger64() const;
510  double GetAsDouble() const;
512  const char* GetAsString() const;
514  const std::vector<int>& GetAsIntegerList() const;
516  const std::vector<GIntBig>& GetAsInteger64List() const;
518  const std::vector<double>& GetAsDoubleList() const;
520  const std::vector<std::string>& GetAsStringList() const;
521  };
522 
524  class CPL_DLL ConstFieldIterator
525  {
526  friend class OGRFeature;
527  struct Private;
528  std::unique_ptr<Private> m_poPrivate;
529 
530  ConstFieldIterator(const OGRFeature* poSelf, int nPos);
531 
532  public:
534  ConstFieldIterator(ConstFieldIterator&& oOther) noexcept; // declared but not defined. Needed for gcc 5.4 at least
536  const FieldValue& operator*() const;
537  ConstFieldIterator& operator++();
538  bool operator!=(const ConstFieldIterator& it) const;
540  };
541 
558  ConstFieldIterator begin() const;
560  ConstFieldIterator end() const;
561 
562  const FieldValue operator[](int iField) const;
563  FieldValue operator[](int iField);
564 
566  class FieldNotFoundException: public std::exception {};
567 
568  const FieldValue operator[](const char* pszFieldName) const;
569  FieldValue operator[](const char* pszFieldName);
570 
571  OGRFeatureDefn *GetDefnRef() { return poDefn; }
572  const OGRFeatureDefn *GetDefnRef() const { return poDefn; }
573 
574  OGRErr SetGeometryDirectly( OGRGeometry * );
575  OGRErr SetGeometry( const OGRGeometry * );
576  OGRGeometry *GetGeometryRef();
577  const OGRGeometry *GetGeometryRef() const;
578  OGRGeometry *StealGeometry() CPL_WARN_UNUSED_RESULT;
579 
580  int GetGeomFieldCount() const
581  { return poDefn->GetGeomFieldCount(); }
583  { return poDefn->GetGeomFieldDefn(iField); }
584  const OGRGeomFieldDefn *GetGeomFieldDefnRef( int iField ) const
585  { return poDefn->GetGeomFieldDefn(iField); }
586  int GetGeomFieldIndex( const char * pszName ) const
587  { return poDefn->GetGeomFieldIndex(pszName); }
588 
589  OGRGeometry* GetGeomFieldRef( int iField );
590  const OGRGeometry* GetGeomFieldRef( int iField ) const;
591  OGRGeometry* StealGeometry( int iField );
592  OGRGeometry* GetGeomFieldRef( const char* pszFName );
593  const OGRGeometry* GetGeomFieldRef( const char* pszFName ) const;
594  OGRErr SetGeomFieldDirectly( int iField, OGRGeometry * );
595  OGRErr SetGeomField( int iField, const OGRGeometry * );
596 
597  OGRFeature *Clone() const CPL_WARN_UNUSED_RESULT;
598  virtual OGRBoolean Equal( const OGRFeature * poFeature ) const;
599 
600  int GetFieldCount() const
601  { return poDefn->GetFieldCount(); }
602  const OGRFieldDefn *GetFieldDefnRef( int iField ) const
603  { return poDefn->GetFieldDefn(iField); }
605  { return poDefn->GetFieldDefn(iField); }
606  int GetFieldIndex( const char * pszName ) const
607  { return poDefn->GetFieldIndex(pszName); }
608 
609  int IsFieldSet( int iField ) const;
610 
611  void UnsetField( int iField );
612 
613  bool IsFieldNull( int iField ) const;
614 
615  void SetFieldNull( int iField );
616 
617  bool IsFieldSetAndNotNull( int iField ) const;
618 
619  OGRField *GetRawFieldRef( int i ) { return pauFields + i; }
620  const OGRField *GetRawFieldRef( int i ) const { return pauFields + i; }
621 
622  int GetFieldAsInteger( int i ) const;
623  GIntBig GetFieldAsInteger64( int i ) const;
624  double GetFieldAsDouble( int i ) const;
625  const char *GetFieldAsString( int i ) const;
626  const int *GetFieldAsIntegerList( int i, int *pnCount ) const;
627  const GIntBig *GetFieldAsInteger64List( int i, int *pnCount ) const;
628  const double *GetFieldAsDoubleList( int i, int *pnCount ) const;
629  char **GetFieldAsStringList( int i ) const;
630  GByte *GetFieldAsBinary( int i, int *pnCount ) const;
631  int GetFieldAsDateTime( int i,
632  int *pnYear, int *pnMonth,
633  int *pnDay,
634  int *pnHour, int *pnMinute,
635  int *pnSecond,
636  int *pnTZFlag ) const;
637  int GetFieldAsDateTime( int i,
638  int *pnYear, int *pnMonth,
639  int *pnDay,
640  int *pnHour, int *pnMinute,
641  float *pfSecond,
642  int *pnTZFlag ) const;
643  char *GetFieldAsSerializedJSon( int i ) const;
644 
645  int GetFieldAsInteger( const char *pszFName ) const
646  { return GetFieldAsInteger( GetFieldIndex(pszFName) ); }
647  GIntBig GetFieldAsInteger64( const char *pszFName ) const
648  { return GetFieldAsInteger64( GetFieldIndex(pszFName) ); }
649  double GetFieldAsDouble( const char *pszFName ) const
650  { return GetFieldAsDouble( GetFieldIndex(pszFName) ); }
651  const char *GetFieldAsString( const char *pszFName ) const
652  { return GetFieldAsString( GetFieldIndex(pszFName) ); }
653  const int *GetFieldAsIntegerList( const char *pszFName,
654  int *pnCount ) const
655  { return GetFieldAsIntegerList( GetFieldIndex(pszFName),
656  pnCount ); }
657  const GIntBig *GetFieldAsInteger64List( const char *pszFName,
658  int *pnCount ) const
659  { return GetFieldAsInteger64List( GetFieldIndex(pszFName),
660  pnCount ); }
661  const double *GetFieldAsDoubleList( const char *pszFName,
662  int *pnCount ) const
663  { return GetFieldAsDoubleList( GetFieldIndex(pszFName),
664  pnCount ); }
665  char **GetFieldAsStringList( const char *pszFName ) const
666  { return GetFieldAsStringList(GetFieldIndex(pszFName)); }
667 
668  void SetField( int i, int nValue );
669  void SetField( int i, GIntBig nValue );
670  void SetField( int i, double dfValue );
671  void SetField( int i, const char * pszValue );
672  void SetField( int i, int nCount, const int * panValues );
673  void SetField( int i, int nCount,
674  const GIntBig * panValues );
675  void SetField( int i, int nCount, const double * padfValues );
676  void SetField( int i, const char * const * papszValues );
677  void SetField( int i, OGRField * puValue );
678  void SetField( int i, int nCount, GByte * pabyBinary );
679  void SetField( int i, int nYear, int nMonth, int nDay,
680  int nHour=0, int nMinute=0, float fSecond=0.f,
681  int nTZFlag = 0 );
682 
683  void SetField( const char *pszFName, int nValue )
684  { SetField( GetFieldIndex(pszFName), nValue ); }
685  void SetField( const char *pszFName, GIntBig nValue )
686  { SetField( GetFieldIndex(pszFName), nValue ); }
687  void SetField( const char *pszFName, double dfValue )
688  { SetField( GetFieldIndex(pszFName), dfValue ); }
689  void SetField( const char *pszFName, const char * pszValue )
690  { SetField( GetFieldIndex(pszFName), pszValue ); }
691  void SetField( const char *pszFName, int nCount,
692  const int * panValues )
693  { SetField(GetFieldIndex(pszFName),nCount,panValues); }
694  void SetField( const char *pszFName, int nCount,
695  const GIntBig * panValues )
696  { SetField(GetFieldIndex(pszFName),nCount,panValues); }
697  void SetField( const char *pszFName, int nCount,
698  const double * padfValues )
699  {SetField(GetFieldIndex(pszFName),nCount,padfValues); }
700  void SetField( const char *pszFName, const char * const * papszValues )
701  { SetField( GetFieldIndex(pszFName), papszValues); }
702  void SetField( const char *pszFName, OGRField * puValue )
703  { SetField( GetFieldIndex(pszFName), puValue ); }
704  void SetField( const char *pszFName,
705  int nYear, int nMonth, int nDay,
706  int nHour=0, int nMinute=0, float fSecond=0.f,
707  int nTZFlag = 0 )
708  { SetField( GetFieldIndex(pszFName),
709  nYear, nMonth, nDay,
710  nHour, nMinute, fSecond, nTZFlag ); }
711 
712  GIntBig GetFID() const { return nFID; }
713  virtual OGRErr SetFID( GIntBig nFIDIn );
714 
715  void DumpReadable( FILE *, char** papszOptions = nullptr ) const;
716 
717  OGRErr SetFrom( const OGRFeature *, int = TRUE );
718  OGRErr SetFrom( const OGRFeature *, const int *, int = TRUE );
719  OGRErr SetFieldsFrom( const OGRFeature *, const int *, int = TRUE );
720 
722  OGRErr RemapFields( OGRFeatureDefn *poNewDefn,
723  const int *panRemapSource );
724  void AppendField();
725  OGRErr RemapGeomFields( OGRFeatureDefn *poNewDefn,
726  const int *panRemapSource );
728 
729  int Validate( int nValidateFlags,
730  int bEmitError ) const;
731  void FillUnsetWithDefault( int bNotNullableOnly,
732  char** papszOptions );
733 
734  virtual const char *GetStyleString() const;
735  virtual void SetStyleString( const char * );
736  virtual void SetStyleStringDirectly( char * );
737 
741  virtual OGRStyleTable *GetStyleTable() const { return m_poStyleTable; } /* f.i.x.m.e: add a const qualifier for return type */
742  virtual void SetStyleTable( OGRStyleTable *poStyleTable );
743  virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
744 
745  const char *GetNativeData() const { return m_pszNativeData; }
746  const char *GetNativeMediaType() const
747  { return m_pszNativeMediaType; }
748  void SetNativeData( const char* pszNativeData );
749  void SetNativeMediaType( const char* pszNativeMediaType );
750 
751  static OGRFeature *CreateFeature( OGRFeatureDefn * );
752  static void DestroyFeature( OGRFeature * );
753 
757  static inline OGRFeatureH ToHandle(OGRFeature* poFeature)
758  { return reinterpret_cast<OGRFeatureH>(poFeature); }
759 
763  static inline OGRFeature* FromHandle(OGRFeatureH hFeature)
764  { return reinterpret_cast<OGRFeature*>(hFeature); }
765 
766  private:
768 };
769 
771 struct CPL_DLL OGRFeatureUniquePtrDeleter
772 {
773  void operator()(OGRFeature*) const;
774 };
776 
780 typedef std::unique_ptr<OGRFeature, OGRFeatureUniquePtrDeleter> OGRFeatureUniquePtr;
781 
783 
784 inline OGRFeature::ConstFieldIterator begin(const OGRFeature* poFeature) { return poFeature->begin(); }
786 inline OGRFeature::ConstFieldIterator end(const OGRFeature* poFeature) { return poFeature->end(); }
787 
789 inline OGRFeature::ConstFieldIterator begin(const OGRFeatureUniquePtr& poFeature) { return poFeature->begin(); }
791 inline OGRFeature::ConstFieldIterator end(const OGRFeatureUniquePtr& poFeature) { return poFeature->end(); }
792 
794 
795 /************************************************************************/
796 /* OGRFeatureQuery */
797 /************************************************************************/
798 
800 class OGRLayer;
801 class swq_expr_node;
802 class swq_custom_func_registrar;
803 
804 class CPL_DLL OGRFeatureQuery
805 {
806  private:
807  OGRFeatureDefn *poTargetDefn;
808  void *pSWQExpr;
809 
810  char **FieldCollector( void *, char ** );
811 
812  GIntBig *EvaluateAgainstIndices( swq_expr_node*, OGRLayer *,
813  GIntBig& nFIDCount );
814 
815  int CanUseIndex( swq_expr_node*, OGRLayer * );
816 
817  OGRErr Compile( OGRLayer *, OGRFeatureDefn*, const char *,
818  int bCheck,
819  swq_custom_func_registrar* poCustomFuncRegistrar );
820 
821  CPL_DISALLOW_COPY_ASSIGN(OGRFeatureQuery)
822 
823  public:
824  OGRFeatureQuery();
825  ~OGRFeatureQuery();
826 
827  OGRErr Compile( OGRLayer *, const char *,
828  int bCheck = TRUE,
829  swq_custom_func_registrar*
830  poCustomFuncRegistrar = nullptr );
831  OGRErr Compile( OGRFeatureDefn *, const char *,
832  int bCheck = TRUE,
833  swq_custom_func_registrar*
834  poCustomFuncRegistrar = nullptr );
835  int Evaluate( OGRFeature * );
836 
837  GIntBig *EvaluateAgainstIndices( OGRLayer *, OGRErr * );
838 
839  int CanUseIndex( OGRLayer * );
840 
841  char **GetUsedFields();
842 
843  void *GetSWQExpr() { return pSWQExpr; }
844 };
846 
847 #endif /* ndef OGR_FEATURE_H_INCLUDED */
static OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
Convert a OGRFeatureDefn* to a OGRFeatureDefnH.
Definition: ogr_feature.h:333
void SetField(const char *pszFName, int nCount, const int *panValues)
Set field to list of integers value.
Definition: ogr_feature.h:691
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:780
void SetField(const char *pszFName, int nCount, const double *padfValues)
Set field to list of doubles value.
Definition: ogr_feature.h:697
int GetPrecision() const
Get the formatting precision for this field.
Definition: ogr_feature.h:130
OGRFieldSubType
List of field subtypes.
Definition: ogr_core.h:622
static OGRFeature * FromHandle(OGRFeatureH hFeature)
Convert a OGRFeatureH to a OGRFeature*.
Definition: ogr_feature.h:763
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_feature.h:69
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_feature.h:64
double GetDouble() const
Return the double value.
Definition: ogr_feature.h:471
int IsNullable() const
Return whether this geometry field can receive null values.
Definition: ogr_feature.h:214
void SetField(const char *pszFName, double dfValue)
Set field to double value.
Definition: ogr_feature.h:687
OGRwkbGeometryType GetType() const
Fetch geometry type of this field.
Definition: ogr_feature.h:205
OGRJustification GetJustify() const
Get the justification for this field.
Definition: ogr_feature.h:123
OGRField * GetRawFieldRef(int i)
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:619
static OGRFeatureDefn * FromHandle(OGRFeatureDefnH hFeatureDefn)
Convert a OGRFeatureDefnH to a OGRFeatureDefn*.
Definition: ogr_feature.h:339
int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition: ogr_feature.h:580
void SetNullable(int bNullableIn)
Set whether this geometry field can receive null values.
Definition: ogr_feature.h:215
Definition of a geometry field of an OGRFeatureDefn.
Definition: ogr_feature.h:182
const OGRFeatureDefn * GetDefnRef() const
Fetch feature definition.
Definition: ogr_feature.h:572
static OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
Convert a OGRFieldDefn* to a OGRFieldDefnH.
Definition: ogr_feature.h:152
const OGRFieldDefn * GetFieldDefnRef(int iField) const
Fetch definition for this field.
Definition: ogr_feature.h:602
static OGRGeomFieldDefn * FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
Convert a OGRGeomFieldDefnH to a OGRGeomFieldDefn*.
Definition: ogr_feature.h:229
virtual void SetStyleIgnored(int bIgnore)
Set whether the style can be omitted when fetching features.
Definition: ogr_feature.h:315
void SetField(const char *pszFName, OGRField *puValue)
Set field.
Definition: ogr_feature.h:702
Exception raised by operator[](const char*) when a field is not found.
Definition: ogr_feature.h:566
const OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField) const
Fetch definition for this geometry field.
Definition: ogr_feature.h:584
ConstFieldIterator end() const
Return end of field value iterator.
Definition: ogrfeature.cpp:7093
virtual int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition: ogrfeaturedefn.cpp:631
int OGRBoolean
Type for a OGR boolean.
Definition: ogr_core.h:306
void * OGRStyleTableH
Opaque type for a style table (OGRStyleTable)
Definition: ogr_feature.h:66
const OGRField * GetRawFieldRef(int i) const
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:620
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:215
const GIntBig * GetFieldAsInteger64List(const char *pszFName, int *pnCount) const
Fetch field value as a list of 64 bit integers.
Definition: ogr_feature.h:657
const char * GetNativeMediaType() const
Returns the native media type for the feature.
Definition: ogr_feature.h:746
Definition of a feature class or feature layer.
Definition: ogr_feature.h:259
unknown type, non-standard
Definition: ogr_core.h:319
static OGRFieldDefn * FromHandle(OGRFieldDefnH hFieldDefn)
Convert a OGRFieldDefnH to a OGRFieldDefn*.
Definition: ogr_feature.h:158
const char * GetFieldAsString(const char *pszFName) const
Fetch field value as a string.
Definition: ogr_feature.h:651
void SetField(const char *pszFName, const char *const *papszValues)
Set field to list of strings value.
Definition: ogr_feature.h:700
virtual int GetGeomFieldIndex(const char *) const
Find geometry field by name.
Definition: ogrfeaturedefn.cpp:915
const int * GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
Fetch field value as a list of integers.
Definition: ogr_feature.h:653
GIntBig GetFieldAsInteger64(const char *pszFName) const
Fetch field value as integer 64 bit.
Definition: ogr_feature.h:647
OGRFieldSubType GetSubType() const
Return field subtype.
Definition: ogr_feature.h:438
Simple feature style classes.
void SetField(const char *pszFName, int nValue)
Set field to integer value.
Definition: ogr_feature.h:683
Definition of an attribute of an OGRFeatureDefn.
Definition: ogr_feature.h:92
virtual int GetFieldCount() const
Fetch number of fields on this feature.
Definition: ogrfeaturedefn.cpp:285
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_feature.h:60
#define MAX(a, b)
Macro to compute the maximum of 2 values.
Definition: cpl_port.h:399
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_api.h:297
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_api.h:306
virtual int IsStyleIgnored() const
Determine whether the style can be omitted when fetching features.
Definition: ogr_feature.h:314
int GetReferenceCount() const
Fetch current reference count.
Definition: ogr_feature.h:309
void Unset()
Unset the field.
Definition: ogr_feature.h:423
const double * GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
Fetch field value as a list of doubles.
Definition: ogr_feature.h:661
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:317
Field value iterator class.
Definition: ogr_feature.h:524
virtual OGRGeomFieldDefn * GetGeomFieldDefn(int i)
Fetch geometry field definition.
Definition: ogrfeaturedefn.cpp:680
OGRFieldDefn * GetFieldDefnRef(int iField)
Fetch definition for this field.
Definition: ogr_feature.h:604
const char * GetNativeData() const
Returns the native data for the feature.
Definition: ogr_feature.h:745
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:113
GIntBig GetFID() const
Get feature identifier.
Definition: ogr_feature.h:712
void SetPrecision(int nPrecisionIn)
Set the formatting precision for this field in characters.
Definition: ogr_feature.h:131
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:286
char ** GetFieldAsStringList(const char *pszFName) const
Fetch field value as a list of strings.
Definition: ogr_feature.h:665
int GetFieldAsInteger(const char *pszFName) const
Fetch field value as integer.
Definition: ogr_feature.h:645
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1186
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:141
static OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
Convert a OGRGeomFieldDefn* to a OGRGeomFieldDefnH.
Definition: ogr_feature.h:223
void SetWidth(int nWidthIn)
Set the formatting width for this field in characters.
Definition: ogr_feature.h:128
Field value.
Definition: ogr_feature.h:381
OGRJustification
Display justification for field values.
Definition: ogr_core.h:642
void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
Set field to list of 64 bit integers value.
Definition: ogr_feature.h:694
virtual OGRStyleTable * GetStyleTable() const
Return style table.
Definition: ogr_feature.h:741
int Reference()
Increments the reference count by one.
Definition: ogr_feature.h:307
int IsNullable() const
Return whether this field can receive null values.
Definition: ogr_feature.h:144
int GetFieldCount() const
Fetch number of fields on this feature.
Definition: ogr_feature.h:600
double GetFieldAsDouble(const char *pszFName) const
Fetch field value as a double.
Definition: ogr_feature.h:649
OGRFieldType
List of feature field types.
Definition: ogr_core.h:594
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_feature.h:62
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:147
void SetField(const char *pszFName, GIntBig nValue)
Set field to 64 bit integer value.
Definition: ogr_feature.h:685
const char * GetString() const
Return the string value.
Definition: ogr_feature.h:477
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_api.h:301
int Dereference()
Decrements the reference count by one.
Definition: ogr_feature.h:308
OGRFieldSubType GetSubType() const
Fetch subtype of this field.
Definition: ogr_feature.h:119
virtual int GetFieldIndex(const char *) const
Find field by name.
Definition: ogrfeaturedefn.cpp:1217
OGRFeature field attribute value union.
Definition: ogr_core.h:683
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:212
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:70
GIntBig GetInteger64() const
Return the 64-bit integer value.
Definition: ogr_feature.h:465
OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField)
Fetch definition for this geometry field.
Definition: ogr_feature.h:582
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:354
virtual OGRFieldDefn * GetFieldDefn(int i)
Fetch field definition.
Definition: ogrfeaturedefn.cpp:329
ConstFieldIterator begin() const
Return begin of field value iterator.
Definition: ogrfeature.cpp:7088
static OGRFeatureH ToHandle(OGRFeature *poFeature)
Convert a OGRFeature* to a OGRFeatureH.
Definition: ogr_feature.h:757
OGRFieldType GetType() const
Fetch type of this field.
Definition: ogr_feature.h:115
This class represents a style table.
Definition: ogr_featurestyle.h:84
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:248
void SetField(const char *pszFName, const char *pszValue)
Set field to string value.
Definition: ogr_feature.h:689
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:287
bool empty() const
Return whether the field value is unset/empty.
Definition: ogr_feature.h:442
Simple feature geometry classes.
const char * GetName() const
Return field name.
Definition: ogr_feature.h:434
void SetJustify(OGRJustification eJustifyIn)
Set the justification for this field.
Definition: ogr_feature.h:124
int OGRErr
Simple container for a bounding region.
Definition: ogr_core.h:290
int GetFieldIndex(const char *pszName) const
Fetch the field index given field name.
Definition: ogr_feature.h:606
int GetInteger() const
Return the integer value.
Definition: ogr_feature.h:459
OGRFeatureDefn * GetDefnRef()
Fetch feature definition.
Definition: ogr_feature.h:571
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_api.h:299
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:292
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:704
OGRFieldType GetType() const
Return field type.
Definition: ogr_feature.h:436
int GetGeomFieldIndex(const char *pszName) const
Fetch the geometry field index given geometry field name.
Definition: ogr_feature.h:586
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:203
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:211
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:142
int GetWidth() const
Get the formatting width for this field.
Definition: ogr_feature.h:127
#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:989
void SetNullable(int bNullableIn)
Set whether this field can receive null values.
Definition: ogr_feature.h:145
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:931

Generated for GDAL by doxygen 1.8.13.