Go to the documentation of this file.
31 #ifndef OGR_FEATURE_H_INCLUDED
32 #define OGR_FEATURE_H_INCLUDED
34 #include "cpl_atomic_ops.h"
49 #ifndef DEFINE_OGRFeatureH
51 #define DEFINE_OGRFeatureH
112 void SetName(
const char * );
113 const char *GetNameRef()
const {
return pszName; }
125 { eJustify = eJustifyIn; }
127 int GetWidth()
const {
return nWidth; }
128 void SetWidth(
int nWidthIn ) { nWidth =
MAX(0,nWidthIn); }
130 int GetPrecision()
const {
return nPrecision; }
131 void SetPrecision(
int nPrecisionIn )
132 { nPrecision = nPrecisionIn; }
137 void SetDefault(
const char* );
138 const char *GetDefault()
const;
139 int IsDefaultDriverSpecific()
const;
141 int IsIgnored()
const {
return bIgnore; }
142 void SetIgnored(
int bIgnoreIn ) { bIgnore = bIgnoreIn; }
144 int IsNullable()
const {
return bNullable; }
145 void SetNullable(
int bNullableIn ) { bNullable = bNullableIn; }
153 {
return reinterpret_cast<OGRFieldDefnH>(poFieldDefn); }
159 {
return reinterpret_cast<OGRFieldDefn*>(hFieldDefn); }
186 char *pszName =
nullptr;
191 mutable int bNullable =
true;
202 void SetName(
const char * );
203 const char *GetNameRef()
const {
return pszName; }
211 int IsIgnored()
const {
return bIgnore; }
212 void SetIgnored(
int bIgnoreIn ) { bIgnore = bIgnoreIn; }
214 int IsNullable()
const {
return bNullable; }
215 void SetNullable(
int bNullableIn )
216 { bNullable = bNullableIn; }
224 {
return reinterpret_cast<OGRGeomFieldDefnH>(poGeomFieldDefn); }
230 {
return reinterpret_cast<OGRGeomFieldDefn*>(hGeomFieldDefn); }
263 volatile int nRefCount;
265 mutable int nFieldCount;
268 mutable int nGeomFieldCount;
271 char *pszFeatureClassName;
280 void SetName(
const char* pszName );
281 virtual const char *GetName()
const;
283 virtual int GetFieldCount()
const;
285 virtual const OGRFieldDefn *GetFieldDefn(
int i )
const;
286 virtual int GetFieldIndex(
const char * )
const;
287 int GetFieldIndexCaseSensitive(
const char * )
const;
290 virtual OGRErr DeleteFieldDefn(
int iField );
291 virtual OGRErr ReorderFieldDefns(
int* panMap );
293 virtual int GetGeomFieldCount()
const;
296 virtual int GetGeomFieldIndex(
const char * )
const;
300 virtual OGRErr DeleteGeomFieldDefn(
int iGeomField );
307 int Reference() {
return CPLAtomicInc(&nRefCount); }
308 int Dereference() {
return CPLAtomicDec(&nRefCount); }
309 int GetReferenceCount()
const {
return nRefCount; }
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; }
318 virtual int IsSame(
const OGRFeatureDefn * poOtherFeatureDefn )
const;
321 void ReserveSpaceForFields(
int nFieldCountIn);
324 std::vector<int> ComputeMapForSetFrom(
const OGRFeatureDefn* poSrcFDefn,
325 bool bForgiving =
true )
const;
327 static OGRFeatureDefn *CreateFeatureDefn(
const char *pszName =
nullptr );
334 {
return reinterpret_cast<OGRFeatureDefnH>(poFeatureDefn); }
340 {
return reinterpret_cast<OGRFeatureDefn*>(hFeatureDefn); }
362 char *m_pszNativeData;
363 char *m_pszNativeMediaType;
365 bool SetFieldInternal(
int i,
OGRField * puValue );
369 mutable char *m_pszStyleString;
371 mutable char *m_pszTmpFieldValue;
381 class CPL_DLL FieldValue
385 std::unique_ptr<Private> m_poPrivate;
387 FieldValue(
OGRFeature* poFeature,
int iFieldIndex);
388 FieldValue(
const OGRFeature* poFeature,
int iFieldIndex);
389 FieldValue(
const FieldValue& oOther) =
delete;
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);
423 void Unset() { clear(); }
425 void SetDateTime(
int nYear,
int nMonth,
int nDay,
426 int nHour=0,
int nMinute=0,
float fSecond=0.f,
430 int GetIndex()
const;
434 const char* GetName()
const {
return GetDefn()->GetNameRef(); }
436 OGRFieldType GetType()
const {
return GetDefn()->GetType(); }
442 bool empty()
const {
return IsUnset(); }
446 bool IsUnset()
const;
453 const OGRField *GetRawValue()
const;
459 int GetInteger()
const {
return GetRawValue()->Integer; }
465 GIntBig GetInteger64()
const {
return GetRawValue()->Integer64; }
471 double GetDouble()
const {
return GetRawValue()->Real; }
477 const char* GetString()
const {
return GetRawValue()->String; }
480 bool GetDateTime(
int *pnYear,
int *pnMonth,
482 int *pnHour,
int *pnMinute,
484 int *pnTZFlag )
const;
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(); }
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;
524 class CPL_DLL ConstFieldIterator
528 std::unique_ptr<Private> m_poPrivate;
530 ConstFieldIterator(
const OGRFeature* poSelf,
int nPos);
534 ConstFieldIterator(ConstFieldIterator&& oOther) noexcept;
535 ~ConstFieldIterator();
536 const FieldValue& operator*()
const;
537 ConstFieldIterator& operator++();
538 bool operator!=(
const ConstFieldIterator& it)
const;
558 ConstFieldIterator
begin()
const;
560 ConstFieldIterator
end()
const;
562 const FieldValue operator[](
int iField)
const;
563 FieldValue operator[](
int iField);
566 class FieldNotFoundException:
public std::exception {};
568 const FieldValue operator[](
const char* pszFieldName)
const;
569 FieldValue operator[](
const char* pszFieldName);
580 int GetGeomFieldCount()
const
586 int GetGeomFieldIndex(
const char * pszName )
const
590 const OGRGeometry* GetGeomFieldRef(
int iField )
const;
592 OGRGeometry* GetGeomFieldRef(
const char* pszFName );
593 const OGRGeometry* GetGeomFieldRef(
const char* pszFName )
const;
600 int GetFieldCount()
const
606 int GetFieldIndex(
const char * pszName )
const
609 int IsFieldSet(
int iField )
const;
611 void UnsetField(
int iField );
613 bool IsFieldNull(
int iField )
const;
615 void SetFieldNull(
int iField );
617 bool IsFieldSetAndNotNull(
int iField )
const;
620 const OGRField *GetRawFieldRef(
int i )
const {
return pauFields + i; }
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,
634 int *pnHour,
int *pnMinute,
636 int *pnTZFlag )
const;
637 int GetFieldAsDateTime(
int i,
638 int *pnYear,
int *pnMonth,
640 int *pnHour,
int *pnMinute,
642 int *pnTZFlag )
const;
643 char *GetFieldAsSerializedJSon(
int i )
const;
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,
655 {
return GetFieldAsIntegerList( GetFieldIndex(pszFName),
657 const GIntBig *GetFieldAsInteger64List(
const char *pszFName,
659 {
return GetFieldAsInteger64List( GetFieldIndex(pszFName),
661 const double *GetFieldAsDoubleList(
const char *pszFName,
663 {
return GetFieldAsDoubleList( GetFieldIndex(pszFName),
665 char **GetFieldAsStringList(
const char *pszFName )
const
666 {
return GetFieldAsStringList(GetFieldIndex(pszFName)); }
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,
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,
const void * pabyBinary );
679 void SetField(
int i,
int nYear,
int nMonth,
int nDay,
680 int nHour=0,
int nMinute=0,
float fSecond=0.f,
683 void SetField(
const char *pszFName,
int nValue )
685 void SetField(
const char *pszFName,
GIntBig nValue )
687 void SetField(
const char *pszFName,
double dfValue )
689 void SetField(
const char *pszFName,
const char * 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,
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 )
704 void SetField(
const char *pszFName,
705 int nYear,
int nMonth,
int nDay,
706 int nHour=0,
int nMinute=0,
float fSecond=0.f,
708 { SetField( GetFieldIndex(pszFName),
710 nHour, nMinute, fSecond, nTZFlag ); }
712 GIntBig GetFID()
const {
return nFID; }
715 void DumpReadable( FILE *,
char** papszOptions =
nullptr )
const;
723 const int *panRemapSource );
726 const int *panRemapSource );
729 int Validate(
int nValidateFlags,
730 int bEmitError )
const;
731 void FillUnsetWithDefault(
int bNotNullableOnly,
732 char** papszOptions );
734 virtual const char *GetStyleString()
const;
735 virtual void SetStyleString(
const char * );
736 virtual void SetStyleStringDirectly(
char * );
741 virtual OGRStyleTable *GetStyleTable()
const {
return m_poStyleTable; }
743 virtual void SetStyleTableDirectly(
OGRStyleTable *poStyleTable );
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 );
758 {
return reinterpret_cast<OGRFeatureH>(poFeature); }
764 {
return reinterpret_cast<OGRFeature*>(hFeature); }
771 struct CPL_DLL OGRFeatureUniquePtrDeleter
802 class swq_custom_func_registrar;
804 class CPL_DLL OGRFeatureQuery
810 char **FieldCollector(
void *,
char ** );
815 int CanUseIndex( swq_expr_node*,
OGRLayer * );
819 swq_custom_func_registrar* poCustomFuncRegistrar );
829 swq_custom_func_registrar*
830 poCustomFuncRegistrar =
nullptr );
833 swq_custom_func_registrar*
834 poCustomFuncRegistrar =
nullptr );
841 char **GetUsedFields();
843 void *GetSWQExpr() {
return pSWQExpr; }
#define MAX(a, b)
Macro to compute the maximum of 2 values.
Definition: cpl_port.h:406
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:214
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_feature.h:59
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
Field value iterator class.
Definition: ogr_feature.h:523
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:286
This class represents a style table.
Definition: ogr_featurestyle.h:83
virtual int GetGeomFieldIndex(const char *) const
Find geometry field by name.
Definition: ogrfeaturedefn.cpp:915
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:155
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_feature.h:68
void * OGRStyleTableH
Opaque type for a style table (OGRStyleTable)
Definition: ogr_feature.h:65
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_feature.h:63
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:285
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:69
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:779
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_api.h:301
int OGRBoolean
Type for a OGR boolean.
Definition: ogr_core.h:305
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_api.h:299
virtual OGRFieldDefn * GetFieldDefn(int i)
Fetch field definition.
Definition: ogrfeaturedefn.cpp:329
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_api.h:306
ConstFieldIterator begin() const
Return begin of field value iterator.
Definition: ogrfeature.cpp:7090
OGRFeature field attribute value union.
Definition: ogr_core.h:682
virtual OGRGeomFieldDefn * GetGeomFieldDefn(int i)
Fetch geometry field definition.
Definition: ogrfeaturedefn.cpp:680
void SetField(const char *pszFName, int nCount, const double *padfValues)
Set field to list of doubles value.
Definition: ogr_feature.h:696
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1192
virtual int GetFieldCount() const
Fetch number of fields on this feature.
Definition: ogrfeaturedefn.cpp:285
void SetField(const char *pszFName, const char *pszValue)
Set field to string value.
Definition: ogr_feature.h:688
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 OGRFeatureDefn * GetDefnRef() const
Fetch feature definition.
Definition: ogr_feature.h:571
Definition of an attribute of an OGRFeatureDefn.
Definition: ogr_feature.h:91
void SetField(const char *pszFName, int nCount, const int *panValues)
Set field to list of integers value.
Definition: ogr_feature.h:690
OGRJustification
Display justification for field values.
Definition: ogr_core.h:641
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_api.h:297
Definition of a geometry field of an OGRFeatureDefn.
Definition: ogr_feature.h:181
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:291
virtual int GetFieldIndex(const char *) const
Find field by name.
Definition: ogrfeaturedefn.cpp:1217
int OGRErr
Simple container for a bounding region.
Definition: ogr_core.h:289
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:247
const OGRField * GetRawFieldRef(int i) const
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:619
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:316
void SetField(const char *pszFName, double dfValue)
Set field to double value.
Definition: ogr_feature.h:686
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:937
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:353
ConstFieldIterator end() const
Return end of field value iterator.
Definition: ogrfeature.cpp:7095
OGRFieldSubType
List of field subtypes.
Definition: ogr_core.h:621
OGRFieldType
List of feature field types.
Definition: ogr_core.h:593
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_feature.h:61
virtual int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition: ogrfeaturedefn.cpp:631
void SetField(const char *pszFName, OGRField *puValue)
Set field.
Definition: ogr_feature.h:701
void SetField(const char *pszFName, const char *const *papszValues)
Set field to list of strings value.
Definition: ogr_feature.h:699
Definition of a feature class or feature layer.
Definition: ogr_feature.h:258
unknown type, non-standard
Definition: ogr_core.h:318
#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:995
void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
Set field to list of 64 bit integers value.
Definition: ogr_feature.h:693
Generated for GDAL by
1.8.16.