OGR
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
51#define DEFINE_OGRFeatureH
53#ifdef DEBUG
54typedef struct OGRFieldDefnHS *OGRFieldDefnH;
55typedef struct OGRFeatureDefnHS *OGRFeatureDefnH;
56typedef struct OGRFeatureHS *OGRFeatureH;
57typedef struct OGRStyleTableHS *OGRStyleTableH;
58#else
60typedef void *OGRFieldDefnH;
62typedef void *OGRFeatureDefnH;
64typedef void *OGRFeatureH;
66typedef void *OGRStyleTableH;
67#endif
69typedef struct OGRGeomFieldDefnHS *OGRGeomFieldDefnH;
70#endif /* DEFINE_OGRFeatureH */
71
72class OGRStyleTable;
73
74/************************************************************************/
75/* OGRFieldDefn */
76/************************************************************************/
77
92class 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 * );
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
182class CPL_DLL OGRGeomFieldDefn
183{
184protected:
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
196public:
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
259class 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:
343};
344
345/************************************************************************/
346/* OGRFeature */
347/************************************************************************/
348
353class 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
535 const FieldValue& operator*() const;
536 ConstFieldIterator& operator++();
537 bool operator!=(const ConstFieldIterator& it) const;
539 };
540
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(); }
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); }
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:
767};
768
770struct CPL_DLL OGRFeatureUniquePtrDeleter
771{
772 void operator()(OGRFeature*) const;
773};
775
779typedef std::unique_ptr<OGRFeature, OGRFeatureUniquePtrDeleter> OGRFeatureUniquePtr;
780
782
783inline OGRFeature::ConstFieldIterator begin(const OGRFeature* poFeature) { return poFeature->begin(); }
785inline OGRFeature::ConstFieldIterator end(const OGRFeature* poFeature) { return poFeature->end(); }
786
788inline OGRFeature::ConstFieldIterator begin(const OGRFeatureUniquePtr& poFeature) { return poFeature->begin(); }
790inline OGRFeature::ConstFieldIterator end(const OGRFeatureUniquePtr& poFeature) { return poFeature->end(); }
791
793
794/************************************************************************/
795/* OGRFeatureQuery */
796/************************************************************************/
797
799class OGRLayer;
800class swq_expr_node;
801class swq_custom_func_registrar;
802
803class 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 */
Definition: ogr_feature.h:260
virtual void SetStyleIgnored(int bIgnore)
Set whether the style can be omitted when fetching features.
Definition: ogr_feature.h:314
int Reference()
Increments the reference count by one.
Definition: ogr_feature.h:306
virtual int GetFieldCount() const
Fetch number of fields on this feature.
Definition: ogrfeaturedefn.cpp:285
virtual OGRFieldDefn * GetFieldDefn(int i)
Fetch field definition.
Definition: ogrfeaturedefn.cpp:329
virtual int IsStyleIgnored() const
Determine whether the style can be omitted when fetching features.
Definition: ogr_feature.h:313
int Dereference()
Decrements the reference count by one.
Definition: ogr_feature.h:307
static OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
Definition: ogr_feature.h:332
static OGRFeatureDefn * FromHandle(OGRFeatureDefnH hFeatureDefn)
Definition: ogr_feature.h:338
virtual OGRGeomFieldDefn * GetGeomFieldDefn(int i)
Fetch geometry field definition.
Definition: ogrfeaturedefn.cpp:680
virtual int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition: ogrfeaturedefn.cpp:631
virtual int GetFieldIndex(const char *) const
Find field by name.
Definition: ogrfeaturedefn.cpp:1217
int GetReferenceCount() const
Fetch current reference count.
Definition: ogr_feature.h:308
virtual int GetGeomFieldIndex(const char *) const
Find geometry field by name.
Definition: ogrfeaturedefn.cpp:915
Definition: ogr_feature.h:524
Definition: ogr_feature.h:565
Definition: ogr_feature.h:381
bool empty() const
Definition: ogr_feature.h:441
int GetInteger() const
Definition: ogr_feature.h:458
OGRFieldType GetType() const
Definition: ogr_feature.h:435
void Unset()
Definition: ogr_feature.h:422
double GetDouble() const
Definition: ogr_feature.h:470
const char * GetName() const
Definition: ogr_feature.h:433
GIntBig GetInteger64() const
Definition: ogr_feature.h:464
OGRFieldSubType GetSubType() const
Definition: ogr_feature.h:437
const char * GetString() const
Definition: ogr_feature.h:476
Definition: ogr_feature.h:354
OGRFeatureDefn * GetDefnRef()
Fetch feature definition.
Definition: ogr_feature.h:570
static OGRFeatureH ToHandle(OGRFeature *poFeature)
Definition: ogr_feature.h:756
char ** GetFieldAsStringList(const char *pszFName) const
Fetch field value as a list of strings.
Definition: ogr_feature.h:664
ConstFieldIterator end() const
Definition: ogrfeature.cpp:7091
ConstFieldIterator begin() const
Definition: ogrfeature.cpp:7086
void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
Set field to list of 64 bit integers value.
Definition: ogr_feature.h:693
const OGRFeatureDefn * GetDefnRef() const
Fetch feature definition.
Definition: ogr_feature.h:571
OGRFieldDefn * GetFieldDefnRef(int iField)
Fetch definition for this field.
Definition: ogr_feature.h:603
const double * GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
Fetch field value as a list of doubles.
Definition: ogr_feature.h:660
void SetField(const char *pszFName, int nCount, const int *panValues)
Set field to list of integers value.
Definition: ogr_feature.h:690
void SetField(const char *pszFName, GIntBig nValue)
Set field to 64 bit integer value. OFTInteger, OFTInteger64 and OFTReal fields will be set directly....
Definition: ogr_feature.h:684
void SetField(const char *pszFName, const char *pszValue)
Set field to string value.
Definition: ogr_feature.h:688
void SetField(const char *pszFName, int nValue)
Set field to integer value. OFTInteger, OFTInteger64 and OFTReal fields will be set directly....
Definition: ogr_feature.h:682
const OGRFieldDefn * GetFieldDefnRef(int iField) const
Fetch definition for this field.
Definition: ogr_feature.h:601
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
const OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField) const
Fetch definition for this geometry field.
Definition: ogr_feature.h:583
const char * GetNativeData() const
Returns the native data for the feature.
Definition: ogr_feature.h:744
int GetFieldIndex(const char *pszName) const
Fetch the field index given field name.
Definition: ogr_feature.h:605
int GetGeomFieldIndex(const char *pszName) const
Fetch the geometry field index given geometry field name.
Definition: ogr_feature.h:585
OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField)
Fetch definition for this geometry field.
Definition: ogr_feature.h:581
void SetField(const char *pszFName, OGRField *puValue)
Set field.
Definition: ogr_feature.h:701
GIntBig GetFieldAsInteger64(const char *pszFName) const
Fetch field value as integer 64 bit.
Definition: ogr_feature.h:646
const int * GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
Fetch field value as a list of integers.
Definition: ogr_feature.h:652
void SetField(const char *pszFName, double dfValue)
Set field to double value.
Definition: ogr_feature.h:686
const char * GetFieldAsString(const char *pszFName) const
Fetch field value as a string.
Definition: ogr_feature.h:650
void SetField(const char *pszFName, const char *const *papszValues)
Set field to list of strings value.
Definition: ogr_feature.h:699
const OGRField * GetRawFieldRef(int i) const
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:619
int GetFieldAsInteger(const char *pszFName) const
Fetch field value as integer.
Definition: ogr_feature.h:644
const char * GetNativeMediaType() const
Returns the native media type for the feature.
Definition: ogr_feature.h:745
GIntBig GetFID() const
Get feature identifier.
Definition: ogr_feature.h:711
OGRField * GetRawFieldRef(int i)
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:618
void SetField(const char *pszFName, int nCount, const double *padfValues)
Set field to list of doubles value.
Definition: ogr_feature.h:696
virtual OGRStyleTable * GetStyleTable() const
Definition: ogr_feature.h:740
double GetFieldAsDouble(const char *pszFName) const
Fetch field value as a double.
Definition: ogr_feature.h:648
static OGRFeature * FromHandle(OGRFeatureH hFeature)
Definition: ogr_feature.h:762
const GIntBig * GetFieldAsInteger64List(const char *pszFName, int *pnCount) const
Fetch field value as a list of 64 bit integers.
Definition: ogr_feature.h:656
Definition: ogr_feature.h:93
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:113
int IsNullable() const
Return whether this field can receive null values.
Definition: ogr_feature.h:144
OGRFieldSubType GetSubType() const
Fetch subtype of this field.
Definition: ogr_feature.h:119
OGRJustification GetJustify() const
Get the justification for this field.
Definition: ogr_feature.h:123
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:142
int GetPrecision() const
Get the formatting precision for this field. This should normally be zero for fields of types other t...
Definition: ogr_feature.h:130
OGRFieldType GetType() const
Fetch type of this field.
Definition: ogr_feature.h:115
void SetWidth(int nWidthIn)
Set the formatting width for this field in characters.
Definition: ogr_feature.h:128
int GetWidth() const
Get the formatting width for this field.
Definition: ogr_feature.h:127
void SetPrecision(int nPrecisionIn)
Set the formatting precision for this field in characters.
Definition: ogr_feature.h:131
void SetNullable(int bNullableIn)
Set whether this field can receive null values.
Definition: ogr_feature.h:145
void SetJustify(OGRJustification eJustifyIn)
Set the justification for this field.
Definition: ogr_feature.h:124
static OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
Definition: ogr_feature.h:152
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:141
static OGRFieldDefn * FromHandle(OGRFieldDefnH hFieldDefn)
Definition: ogr_feature.h:158
Definition: ogr_feature.h:183
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:212
static OGRGeomFieldDefn * FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
Definition: ogr_feature.h:229
int IsNullable() const
Return whether this geometry field can receive null values.
Definition: ogr_feature.h:214
void SetNullable(int bNullableIn)
Set whether this geometry field can receive null values.
Definition: ogr_feature.h:215
OGRwkbGeometryType GetType() const
Fetch geometry type of this field.
Definition: ogr_feature.h:205
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:211
static OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
Definition: ogr_feature.h:223
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:203
Definition: ogr_geometry.h:287
Definition: ogrsf_frmts.h:71
Definition: ogr_spatialref.h:146
Definition: ogr_featurestyle.h:85
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Definition: cpl_port.h:987
char ** CSLConstList
Definition: cpl_port.h:1184
#define CPL_WARN_UNUSED_RESULT
Definition: cpl_port.h:929
unsigned char GByte
Definition: cpl_port.h:213
long long GIntBig
Definition: cpl_port.h:246
#define MAX(a, b)
Definition: cpl_port.h:397
void * OGRFieldDefnH
Definition: ogr_api.h:297
void * OGRFeatureDefnH
Definition: ogr_api.h:299
void * OGRFeatureH
Definition: ogr_api.h:301
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Definition: ogr_api.h:306
int OGRBoolean
Definition: ogr_core.h:306
OGRFieldSubType
Definition: ogr_core.h:623
OGRJustification
Definition: ogr_core.h:639
OGRFieldType
Definition: ogr_core.h:595
OGRwkbGeometryType
Definition: ogr_core.h:318
int OGRErr
Definition: ogr_core.h:290
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Definition: ogr_feature.h:779
void * OGRFieldDefnH
Definition: ogr_feature.h:60
void * OGRFeatureDefnH
Definition: ogr_feature.h:62
void * OGRFeatureH
Definition: ogr_feature.h:64
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Definition: ogr_feature.h:69
void * OGRStyleTableH
Definition: ogr_feature.h:66
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Definition: ogrsf_frmts.h:285
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Definition: ogrsf_frmts.h:290
Definition: ogrfeature.cpp:7048
Definition: ogrfeature.cpp:7031
Definition: ogr_core.h:679

Generated for GDAL by doxygen 1.9.3.