GDAL

ogr_feature.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Project: OpenGIS Simple Features Reference Implementation
4 * Purpose: Class for representing a whole feature, and layer schemas.
5 * Author: Frank Warmerdam, warmerdam@pobox.com
6 *
7 ******************************************************************************
8 * Copyright (c) 1999, Les Technologies SoftMap Inc.
9 * Copyright (c) 2008-2013, Even Rouault <even dot rouault at spatialys.com>
10 *
11 * SPDX-License-Identifier: MIT
12 ****************************************************************************/
13
14#ifndef OGR_FEATURE_H_INCLUDED
15#define OGR_FEATURE_H_INCLUDED
16
17#include "cpl_atomic_ops.h"
18#include "gdal_fwd.h"
19#include "ogr_featurestyle.h"
20#include "ogr_geometry.h"
21#include "ogr_geomcoordinateprecision.h"
22
23#include <cstddef>
24
25#include <exception>
26#include <memory>
27#include <string>
28#include <vector>
29
36 class OGRStyleTable;
37
38/************************************************************************/
39/* OGRFieldDefn */
40/************************************************************************/
41
68 class CPL_DLL OGRFieldDefn
69{
70 private:
71 char *pszName;
72 char *pszAlternativeName;
73 OGRFieldType eType;
74 OGRJustification eJustify;
75 int nWidth; // Zero is variable.
76 int nPrecision;
77 char *pszDefault;
78
79 int bIgnore;
80 OGRFieldSubType eSubType;
81
82 int bNullable;
83 int bUnique;
84
85 // Used by drivers (GPKG) to track generated fields
86 bool m_bGenerated = false;
87
88 std::string m_osDomainName{}; // field domain name. Might be empty
89
90 std::string m_osComment{}; // field comment. Might be empty
91
92 int m_nTZFlag = OGR_TZFLAG_UNKNOWN;
93 bool m_bSealed = false;
94
95 public:
96 OGRFieldDefn(const char *, OGRFieldType);
97 explicit OGRFieldDefn(const OGRFieldDefn *);
98 ~OGRFieldDefn();
99
100 // Copy constructor
101 OGRFieldDefn(const OGRFieldDefn &oOther);
102
103 // Copy assignment operator
104 OGRFieldDefn &operator=(const OGRFieldDefn &oOther);
105
106 void SetName(const char *);
107
108 const char *GetNameRef() const
109 {
110 return pszName;
111 }
112
113 void SetAlternativeName(const char *);
114
115 const char *GetAlternativeNameRef() const
116 {
117 return pszAlternativeName;
118 }
119
120 OGRFieldType GetType() const
121 {
122 return eType;
123 }
124
125 void SetType(OGRFieldType eTypeIn);
126 static const char *GetFieldTypeName(OGRFieldType);
127 static OGRFieldType GetFieldTypeByName(const char *);
128
129 OGRFieldSubType GetSubType() const
130 {
131 return eSubType;
132 }
133
134 void SetSubType(OGRFieldSubType eSubTypeIn);
135 static const char *GetFieldSubTypeName(OGRFieldSubType);
136 static OGRFieldSubType GetFieldSubTypeByName(const char *);
137
138 OGRJustification GetJustify() const
139 {
140 return eJustify;
141 }
142
143 void SetJustify(OGRJustification eJustifyIn)
144 {
145 eJustify = eJustifyIn;
146 }
147
148 int GetWidth() const
149 {
150 return nWidth;
151 }
152
153 void SetWidth(int nWidthIn);
154
155 int GetPrecision() const
156 {
157 return nPrecision;
158 }
159
160 void SetPrecision(int nPrecisionIn);
161
162 int GetTZFlag() const
163 {
164 return m_nTZFlag;
165 }
166
167 void SetTZFlag(int nTZFlag);
168
169 void Set(const char *, OGRFieldType, int = 0, int = 0,
170 OGRJustification = OJUndefined);
171
172 void SetDefault(const char *);
173 const char *GetDefault() const;
174 int IsDefaultDriverSpecific() const;
175
176 int IsIgnored() const
177 {
178 return bIgnore;
179 }
180
181 void SetIgnored(int bIgnoreIn)
182 {
183 bIgnore = bIgnoreIn;
184 }
185
186 int IsNullable() const
187 {
188 return bNullable;
189 }
190
191 void SetNullable(int bNullableIn);
192
193 int IsUnique() const
194 {
195 return bUnique;
196 }
197
206 bool IsGenerated() const
207 {
208 return m_bGenerated;
209 }
210
216 void SetGenerated(bool bGeneratedIn)
217 {
218 m_bGenerated = bGeneratedIn;
219 }
220
221 void SetUnique(int bUniqueIn);
222
223 const std::string &GetDomainName() const
224 {
225 return m_osDomainName;
226 }
227
228 void SetDomainName(const std::string &osDomainName);
229
230 const std::string &GetComment() const
231 {
232 return m_osComment;
233 }
234
235 void SetComment(const std::string &osComment);
236
237 int IsSame(const OGRFieldDefn *) const;
238
241 static inline OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
242 {
243 return reinterpret_cast<OGRFieldDefnH>(poFieldDefn);
244 }
245
248 static inline OGRFieldDefn *FromHandle(OGRFieldDefnH hFieldDefn)
249 {
250 return reinterpret_cast<OGRFieldDefn *>(hFieldDefn);
251 }
252
253 void Seal();
254
255 void Unseal();
256
258 struct CPL_DLL TemporaryUnsealer
259 {
260 private:
261 OGRFieldDefn *m_poFieldDefn = nullptr;
262 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
263 public:
264 explicit TemporaryUnsealer(OGRFieldDefn *poFieldDefn)
265 : m_poFieldDefn(poFieldDefn)
266 {
267 m_poFieldDefn->Unseal();
268 }
269
270 TemporaryUnsealer(TemporaryUnsealer &&) = default;
271 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
272
273 ~TemporaryUnsealer()
274 {
275 m_poFieldDefn->Seal();
276 }
277
278 OGRFieldDefn *operator->()
279 {
280 return m_poFieldDefn;
281 }
282 };
283
286 TemporaryUnsealer GetTemporaryUnsealer();
287};
288
289#ifdef GDAL_COMPILATION
301 inline OGRFieldDefn::TemporaryUnsealer whileUnsealing(OGRFieldDefn *object)
302{
303 return object->GetTemporaryUnsealer();
304}
305#endif
306
307/************************************************************************/
308/* OGRGeomFieldDefn */
309/************************************************************************/
310
331 class CPL_DLL OGRGeomFieldDefn
332{
333 protected:
335 char *pszName = nullptr;
336 OGRwkbGeometryType eGeomType =
337 wkbUnknown; /* all values possible except wkbNone */
338 mutable const OGRSpatialReference *poSRS = nullptr;
339
340 int bIgnore = false;
341 mutable int bNullable = true;
342 bool m_bSealed = false;
343 OGRGeomCoordinatePrecision m_oCoordPrecision{};
344
345 void Initialize(const char *, OGRwkbGeometryType);
347
348 public:
349 OGRGeomFieldDefn(const char *pszNameIn, OGRwkbGeometryType eGeomTypeIn);
350 explicit OGRGeomFieldDefn(const OGRGeomFieldDefn *);
351 virtual ~OGRGeomFieldDefn();
352
353 // Copy constructor
354 OGRGeomFieldDefn(const OGRGeomFieldDefn &oOther);
355
356 // Copy assignment operator
357 OGRGeomFieldDefn &operator=(const OGRGeomFieldDefn &oOther);
358
359 void SetName(const char *);
360
361 const char *GetNameRef() const
362 {
363 return pszName;
364 }
365
366 OGRwkbGeometryType GetType() const
367 {
368 return eGeomType;
369 }
370
371 void SetType(OGRwkbGeometryType eTypeIn);
372
373 virtual const OGRSpatialReference *GetSpatialRef() const;
374 void SetSpatialRef(const OGRSpatialReference *poSRSIn);
375
376 int IsIgnored() const
377 {
378 return bIgnore;
379 }
380
381 void SetIgnored(int bIgnoreIn)
382 {
383 bIgnore = bIgnoreIn;
384 }
385
386 int IsNullable() const
387 {
388 return bNullable;
389 }
390
391 void SetNullable(int bNullableIn);
392
393 const OGRGeomCoordinatePrecision &GetCoordinatePrecision() const
394 {
395 return m_oCoordPrecision;
396 }
397
398 void SetCoordinatePrecision(const OGRGeomCoordinatePrecision &prec);
399
400 int IsSame(const OGRGeomFieldDefn *) const;
401
404 static inline OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
405 {
406 return reinterpret_cast<OGRGeomFieldDefnH>(poGeomFieldDefn);
407 }
408
411 static inline OGRGeomFieldDefn *FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
412 {
413 return reinterpret_cast<OGRGeomFieldDefn *>(hGeomFieldDefn);
414 }
415
416 void Seal();
417
418 void Unseal();
419
421 struct CPL_DLL TemporaryUnsealer
422 {
423 private:
424 OGRGeomFieldDefn *m_poFieldDefn = nullptr;
425 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
426 public:
427 explicit TemporaryUnsealer(OGRGeomFieldDefn *poFieldDefn)
428 : m_poFieldDefn(poFieldDefn)
429 {
430 m_poFieldDefn->Unseal();
431 }
432
433 TemporaryUnsealer(TemporaryUnsealer &&) = default;
434 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
435
436 ~TemporaryUnsealer()
437 {
438 m_poFieldDefn->Seal();
439 }
440
441 OGRGeomFieldDefn *operator->()
442 {
443 return m_poFieldDefn;
444 }
445 };
446
449 TemporaryUnsealer GetTemporaryUnsealer();
450};
451
452#ifdef GDAL_COMPILATION
464 inline OGRGeomFieldDefn::TemporaryUnsealer
465whileUnsealing(OGRGeomFieldDefn *object)
466{
467 return object->GetTemporaryUnsealer();
468}
469#endif
470
471/************************************************************************/
472/* OGRFeatureDefn */
473/************************************************************************/
474
503 class CPL_DLL OGRFeatureDefn
504{
505 protected:
507 volatile int nRefCount = 0;
508
509 mutable std::vector<std::unique_ptr<OGRFieldDefn>> apoFieldDefn{};
510 mutable std::vector<std::unique_ptr<OGRGeomFieldDefn>> apoGeomFieldDefn{};
511
512 char *pszFeatureClassName = nullptr;
513
514 bool bIgnoreStyle = false;
515
516 friend class TemporaryUnsealer;
517 bool m_bSealed = false;
518 int m_nTemporaryUnsealCount = 0;
520
521 public:
522 explicit OGRFeatureDefn(const char *pszName = nullptr);
523 virtual ~OGRFeatureDefn();
524
525 void SetName(const char *pszName);
526 virtual const char *GetName() const;
527
528 virtual int GetFieldCount() const;
529 virtual OGRFieldDefn *GetFieldDefn(int i);
530 virtual const OGRFieldDefn *GetFieldDefn(int i) const;
531 virtual int GetFieldIndex(const char *) const;
532 int GetFieldIndexCaseSensitive(const char *) const;
533
535
539 template <class OwnerT, class ChildT> struct CPL_DLL Fields
540 {
541 private:
542 OwnerT m_poFDefn;
543
544 public:
545 inline explicit Fields(OwnerT poFDefn) : m_poFDefn(poFDefn)
546 {
547 }
548
549 struct CPL_DLL Iterator
550 {
551 private:
552 OwnerT m_poFDefn;
553 int m_nIdx;
554
555 public:
556 inline Iterator(OwnerT poFDefn, int nIdx)
557 : m_poFDefn(poFDefn), m_nIdx(nIdx)
558 {
559 }
560
561 inline ChildT operator*() const
562 {
563 return m_poFDefn->GetFieldDefn(m_nIdx);
564 }
565
566 inline Iterator &operator++()
567 {
568 m_nIdx++;
569 return *this;
570 }
571
572 inline bool operator!=(const Iterator &it) const
573 {
574 return m_nIdx != it.m_nIdx;
575 }
576 };
577
578 inline Iterator begin()
579 {
580 return Iterator(m_poFDefn, 0);
581 }
582
583 inline Iterator end()
584 {
585 return Iterator(m_poFDefn, m_poFDefn->GetFieldCount());
586 }
587
588 inline size_t size() const
589 {
590 return static_cast<std::size_t>(m_poFDefn->GetFieldCount());
591 }
592
593 inline ChildT operator[](size_t i)
594 {
595 return m_poFDefn->GetFieldDefn(static_cast<int>(i));
596 }
597 };
598
600
602 using NonConstFields = Fields<OGRFeatureDefn *, OGRFieldDefn *>;
603
614 inline NonConstFields GetFields()
615 {
616 return NonConstFields(this);
617 }
618
620 using ConstFields = Fields<const OGRFeatureDefn *, const OGRFieldDefn *>;
621
632 inline ConstFields GetFields() const
633 {
634 return ConstFields(this);
635 }
636
638 // That method should only be called if there's a guarantee that
639 // GetFieldCount() has been called before
640 int GetFieldCountUnsafe() const
641 {
642 return static_cast<int>(apoFieldDefn.size());
643 }
644
645 // Those methods don't check i is n range.
646 OGRFieldDefn *GetFieldDefnUnsafe(int i)
647 {
648 if (apoFieldDefn.empty())
649 GetFieldDefn(i);
650 return apoFieldDefn[static_cast<std::size_t>(i)].get();
651 }
652
653 const OGRFieldDefn *GetFieldDefnUnsafe(int i) const
654 {
655 if (apoFieldDefn.empty())
656 GetFieldDefn(i);
657 return apoFieldDefn[static_cast<std::size_t>(i)].get();
658 }
659
661
662 virtual void AddFieldDefn(const OGRFieldDefn *);
663 virtual OGRErr DeleteFieldDefn(int iField);
664
673 virtual std::unique_ptr<OGRFieldDefn> StealFieldDefn(int iField);
674
675 virtual void AddFieldDefn(std::unique_ptr<OGRFieldDefn> &&poFieldDefn);
676
677 virtual OGRErr ReorderFieldDefns(const int *panMap);
678
687 virtual std::unique_ptr<OGRGeomFieldDefn> StealGeomFieldDefn(int iField);
688
689 virtual int GetGeomFieldCount() const;
690 virtual OGRGeomFieldDefn *GetGeomFieldDefn(int i);
691 virtual const OGRGeomFieldDefn *GetGeomFieldDefn(int i) const;
692 virtual int GetGeomFieldIndex(const char *) const;
693
695
699 template <class OwnerT, class ChildT> struct CPL_DLL GeomFields
700 {
701 private:
702 OwnerT m_poFDefn;
703
704 public:
705 inline explicit GeomFields(OwnerT poFDefn) : m_poFDefn(poFDefn)
706 {
707 }
708
709 struct CPL_DLL Iterator
710 {
711 private:
712 OwnerT m_poFDefn;
713 int m_nIdx;
714
715 public:
716 inline Iterator(OwnerT poFDefn, int nIdx)
717 : m_poFDefn(poFDefn), m_nIdx(nIdx)
718 {
719 }
720
721 inline ChildT operator*() const
722 {
723 return m_poFDefn->GetGeomFieldDefn(m_nIdx);
724 }
725
726 inline Iterator &operator++()
727 {
728 m_nIdx++;
729 return *this;
730 }
731
732 inline bool operator!=(const Iterator &it) const
733 {
734 return m_nIdx != it.m_nIdx;
735 }
736 };
737
738 inline Iterator begin()
739 {
740 return Iterator(m_poFDefn, 0);
741 }
742
743 inline Iterator end()
744 {
745 return Iterator(m_poFDefn, m_poFDefn->GetGeomFieldCount());
746 }
747
748 inline size_t size() const
749 {
750 return static_cast<std::size_t>(m_poFDefn->GetGeomFieldCount());
751 }
752
753 inline ChildT operator[](size_t i) const
754 {
755 return m_poFDefn->GetGeomFieldDefn(static_cast<int>(i));
756 }
757 };
758
760
762 using NonConstGeomFields = GeomFields<OGRFeatureDefn *, OGRGeomFieldDefn *>;
763
774 inline NonConstGeomFields GetGeomFields()
775 {
776 return NonConstGeomFields(this);
777 }
778
780 using ConstGeomFields =
781 GeomFields<const OGRFeatureDefn *, const OGRGeomFieldDefn *>;
782
793 inline ConstGeomFields GetGeomFields() const
794 {
795 return ConstGeomFields(this);
796 }
797
798 virtual void AddGeomFieldDefn(const OGRGeomFieldDefn *);
799 virtual void AddGeomFieldDefn(std::unique_ptr<OGRGeomFieldDefn> &&);
800 virtual OGRErr DeleteGeomFieldDefn(int iGeomField);
801
802 virtual OGRwkbGeometryType GetGeomType() const;
803 virtual void SetGeomType(OGRwkbGeometryType);
804
805 virtual OGRFeatureDefn *Clone() const;
806
807 int Reference()
808 {
809 return CPLAtomicInc(&nRefCount);
810 }
811
812 int Dereference()
813 {
814 return CPLAtomicDec(&nRefCount);
815 }
816
817 int GetReferenceCount() const
818 {
819 return nRefCount;
820 }
821
822 void Release();
823
824 virtual int IsGeometryIgnored() const;
825 virtual void SetGeometryIgnored(int bIgnore);
826
827 virtual bool IsStyleIgnored() const
828 {
829 return bIgnoreStyle;
830 }
831
832 virtual void SetStyleIgnored(bool bIgnore)
833 {
834 bIgnoreStyle = bIgnore;
835 }
836
837 virtual int IsSame(const OGRFeatureDefn *poOtherFeatureDefn) const;
838
840 void ReserveSpaceForFields(int nFieldCountIn);
842
843 std::vector<int> ComputeMapForSetFrom(const OGRFeatureDefn *poSrcFDefn,
844 bool bForgiving = true) const;
845
846 static OGRFeatureDefn *CreateFeatureDefn(const char *pszName = nullptr);
847 static void DestroyFeatureDefn(OGRFeatureDefn *);
848
851 static inline OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
852 {
853 return reinterpret_cast<OGRFeatureDefnH>(poFeatureDefn);
854 }
855
858 static inline OGRFeatureDefn *FromHandle(OGRFeatureDefnH hFeatureDefn)
859 {
860 return reinterpret_cast<OGRFeatureDefn *>(hFeatureDefn);
861 }
862
863 void Seal(bool bSealFields);
864
865 void Unseal(bool bUnsealFields);
866
868 struct CPL_DLL TemporaryUnsealer
869 {
870 private:
871 OGRFeatureDefn *m_poFeatureDefn = nullptr;
872 bool m_bSealFields = false;
873 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
874 public:
875 explicit TemporaryUnsealer(OGRFeatureDefn *poFeatureDefn,
876 bool bSealFields);
877
878 TemporaryUnsealer(TemporaryUnsealer &&) = default;
879 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
880
881 ~TemporaryUnsealer();
882
883 OGRFeatureDefn *operator->()
884 {
885 return m_poFeatureDefn;
886 }
887 };
888
891 TemporaryUnsealer GetTemporaryUnsealer(bool bSealFields = true);
892
893 private:
894 CPL_DISALLOW_COPY_ASSIGN(OGRFeatureDefn)
895};
896
897#ifdef GDAL_COMPILATION
918 inline OGRFeatureDefn::TemporaryUnsealer whileUnsealing(OGRFeatureDefn *object,
919 bool bSealFields = true)
920{
921 return object->GetTemporaryUnsealer(bSealFields);
922}
923#endif
924
925/************************************************************************/
926/* OGRFeature */
927/************************************************************************/
928
933 class CPL_DLL OGRFeature
934{
935 private:
936 GIntBig nFID;
937 const OGRFeatureDefn *poDefn;
938 OGRGeometry **papoGeometries;
939 OGRField *pauFields;
940 char *m_pszNativeData;
941 char *m_pszNativeMediaType;
942
943 bool SetFieldInternal(int i, const OGRField *puValue);
944
945 protected:
947 mutable char *m_pszStyleString;
948 mutable OGRStyleTable *m_poStyleTable;
949 mutable char *m_pszTmpFieldValue;
951
952 bool CopySelfTo(OGRFeature *poNew) const;
953
954 public:
955 explicit OGRFeature(const OGRFeatureDefn *);
956 virtual ~OGRFeature();
957
959 class CPL_DLL FieldValue
960 {
961 friend class OGRFeature;
962 struct Private;
963 std::unique_ptr<Private> m_poPrivate;
964
965 FieldValue(OGRFeature *poFeature, int iFieldIndex);
966 FieldValue(const OGRFeature *poFeature, int iFieldIndex);
967 FieldValue(const FieldValue &oOther) = delete;
968 FieldValue &Assign(const FieldValue &oOther);
969
970 public:
972 ~FieldValue();
973
974 FieldValue &operator=(FieldValue &&oOther);
976
978 FieldValue &operator=(const FieldValue &oOther);
980 FieldValue &operator=(int nVal);
982 FieldValue &operator=(GIntBig nVal);
984 FieldValue &operator=(double dfVal);
986 FieldValue &operator=(const char *pszVal);
988 FieldValue &operator=(const std::string &osVal);
990 FieldValue &operator=(const std::vector<int> &oArray);
992 FieldValue &operator=(const std::vector<GIntBig> &oArray);
994 FieldValue &operator=(const std::vector<double> &oArray);
996 FieldValue &operator=(const std::vector<std::string> &oArray);
998 FieldValue &operator=(CSLConstList papszValues);
1000 void SetNull();
1002 void clear();
1003
1005 void Unset()
1006 {
1007 clear();
1008 }
1009
1011 void SetDateTime(int nYear, int nMonth, int nDay, int nHour = 0,
1012 int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0);
1013
1015 int GetIndex() const;
1017 const OGRFieldDefn *GetDefn() const;
1018
1020 const char *GetName() const
1021 {
1022 return GetDefn()->GetNameRef();
1023 }
1024
1026 OGRFieldType GetType() const
1027 {
1028 return GetDefn()->GetType();
1029 }
1030
1032 OGRFieldSubType GetSubType() const
1033 {
1034 return GetDefn()->GetSubType();
1035 }
1036
1038 // cppcheck-suppress functionStatic
1039 bool empty() const
1040 {
1041 return IsUnset();
1042 }
1043
1045 // cppcheck-suppress functionStatic
1046 bool IsUnset() const;
1047
1049 // cppcheck-suppress functionStatic
1050 bool IsNull() const;
1051
1053 const OGRField *GetRawValue() const;
1054
1058 // cppcheck-suppress functionStatic
1059 int GetInteger() const
1060 {
1061 return GetRawValue()->Integer;
1062 }
1063
1067 // cppcheck-suppress functionStatic
1068 GIntBig GetInteger64() const
1069 {
1070 return GetRawValue()->Integer64;
1071 }
1072
1076 // cppcheck-suppress functionStatic
1077 double GetDouble() const
1078 {
1079 return GetRawValue()->Real;
1080 }
1081
1085 // cppcheck-suppress functionStatic
1086 const char *GetString() const
1087 {
1088 return GetRawValue()->String;
1089 }
1090
1092 bool GetDateTime(int *pnYear, int *pnMonth, int *pnDay, int *pnHour,
1093 int *pnMinute, float *pfSecond, int *pnTZFlag) const;
1094
1096 operator int() const
1097 {
1098 return GetAsInteger();
1099 }
1100
1103 operator GIntBig() const
1104 {
1105 return GetAsInteger64();
1106 }
1107
1109 operator double() const
1110 {
1111 return GetAsDouble();
1112 }
1113
1115 operator const char *() const
1116 {
1117 return GetAsString();
1118 }
1119
1121 operator const std::vector<int> &() const
1122 {
1123 return GetAsIntegerList();
1124 }
1125
1128 operator const std::vector<GIntBig> &() const
1129 {
1130 return GetAsInteger64List();
1131 }
1132
1134 operator const std::vector<double> &() const
1135 {
1136 return GetAsDoubleList();
1137 }
1138
1140 operator const std::vector<std::string> &() const
1141 {
1142 return GetAsStringList();
1143 }
1144
1146 operator CSLConstList() const;
1147
1149 int GetAsInteger() const;
1152 GIntBig GetAsInteger64() const;
1154 double GetAsDouble() const;
1156 const char *GetAsString() const;
1158 const std::vector<int> &GetAsIntegerList() const;
1161 const std::vector<GIntBig> &GetAsInteger64List() const;
1163 const std::vector<double> &GetAsDoubleList() const;
1165 const std::vector<std::string> &GetAsStringList() const;
1166 };
1167
1169 class CPL_DLL ConstFieldIterator
1170 {
1171 friend class OGRFeature;
1172 struct Private;
1173 std::unique_ptr<Private> m_poPrivate;
1174
1175 ConstFieldIterator(const OGRFeature *poSelf, int nPos);
1176
1177 public:
1179 ConstFieldIterator(
1180 ConstFieldIterator &&oOther) noexcept; // declared but not defined.
1181 // Needed for gcc 5.4 at least
1182 ~ConstFieldIterator();
1183 const FieldValue &operator*() const;
1184 ConstFieldIterator &operator++();
1185 bool operator!=(const ConstFieldIterator &it) const;
1187 };
1188
1205 ConstFieldIterator begin() const;
1207 ConstFieldIterator end() const;
1208
1209 const FieldValue operator[](int iField) const;
1210 FieldValue operator[](int iField);
1211
1212#if defined(__clang__)
1213#pragma clang diagnostic push
1214#pragma clang diagnostic ignored "-Wweak-vtables"
1215#endif
1216
1219 class FieldNotFoundException final : public std::exception
1220 {
1221 };
1222
1223#if defined(__clang__)
1224#pragma clang diagnostic pop
1225#endif
1226
1227 const FieldValue operator[](const char *pszFieldName) const;
1228 FieldValue operator[](const char *pszFieldName);
1229
1230 const OGRFeatureDefn *GetDefnRef() const
1231 {
1232 return poDefn;
1233 }
1234
1236 void SetFDefnUnsafe(OGRFeatureDefn *poNewFDefn);
1238
1239 OGRErr SetGeometryDirectly(OGRGeometry *);
1240 OGRErr SetGeometry(const OGRGeometry *);
1241 OGRErr SetGeometry(std::unique_ptr<OGRGeometry>);
1242 OGRGeometry *GetGeometryRef();
1243 const OGRGeometry *GetGeometryRef() const;
1244 OGRGeometry *StealGeometry() CPL_WARN_UNUSED_RESULT;
1245
1246 int GetGeomFieldCount() const
1247 {
1248 return poDefn->GetGeomFieldCount();
1249 }
1250
1251 const OGRGeomFieldDefn *GetGeomFieldDefnRef(int iField) const
1252 {
1253 return poDefn->GetGeomFieldDefn(iField);
1254 }
1255
1256 int GetGeomFieldIndex(const char *pszName) const
1257 {
1258 return poDefn->GetGeomFieldIndex(pszName);
1259 }
1260
1261 OGRGeometry *GetGeomFieldRef(int iField);
1262 const OGRGeometry *GetGeomFieldRef(int iField) const;
1263 OGRGeometry *StealGeometry(int iField);
1264 OGRGeometry *GetGeomFieldRef(const char *pszFName);
1265 const OGRGeometry *GetGeomFieldRef(const char *pszFName) const;
1266 OGRErr SetGeomFieldDirectly(int iField, OGRGeometry *);
1267 OGRErr SetGeomField(int iField, const OGRGeometry *);
1268 OGRErr SetGeomField(int iField, std::unique_ptr<OGRGeometry>);
1269
1270 void Reset();
1271
1272 OGRFeature *Clone() const CPL_WARN_UNUSED_RESULT;
1273 virtual OGRBoolean Equal(const OGRFeature *poFeature) const;
1274
1275 int GetFieldCount() const
1276 {
1277 return poDefn->GetFieldCount();
1278 }
1279
1280 const OGRFieldDefn *GetFieldDefnRef(int iField) const
1281 {
1282 return poDefn->GetFieldDefn(iField);
1283 }
1284
1285 int GetFieldIndex(const char *pszName) const
1286 {
1287 return poDefn->GetFieldIndex(pszName);
1288 }
1289
1290 int IsFieldSet(int iField) const;
1291
1292 void UnsetField(int iField);
1293
1294 bool IsFieldNull(int iField) const;
1295
1296 void SetFieldNull(int iField);
1297
1298 bool IsFieldSetAndNotNull(int iField) const;
1299
1300 OGRField *GetRawFieldRef(int i)
1301 {
1302 return pauFields + i;
1303 }
1304
1305 const OGRField *GetRawFieldRef(int i) const
1306 {
1307 return pauFields + i;
1308 }
1309
1310 int GetFieldAsInteger(int i) const;
1311 GIntBig GetFieldAsInteger64(int i) const;
1312 double GetFieldAsDouble(int i) const;
1313 const char *GetFieldAsString(int i) const;
1314 const char *GetFieldAsISO8601DateTime(int i,
1315 CSLConstList papszOptions) const;
1316 const int *GetFieldAsIntegerList(int i, int *pnCount) const;
1317 const GIntBig *GetFieldAsInteger64List(int i, int *pnCount) const;
1318 const double *GetFieldAsDoubleList(int i, int *pnCount) const;
1319 char **GetFieldAsStringList(int i) const;
1320 GByte *GetFieldAsBinary(int i, int *pnCount) const;
1321 int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay,
1322 int *pnHour, int *pnMinute, int *pnSecond,
1323 int *pnTZFlag) const;
1324 int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay,
1325 int *pnHour, int *pnMinute, float *pfSecond,
1326 int *pnTZFlag) const;
1327 char *GetFieldAsSerializedJSon(int i) const;
1328
1330 bool IsFieldSetUnsafe(int i) const
1331 {
1332 return !(pauFields[i].Set.nMarker1 == OGRUnsetMarker &&
1333 pauFields[i].Set.nMarker2 == OGRUnsetMarker &&
1334 pauFields[i].Set.nMarker3 == OGRUnsetMarker);
1335 }
1336
1337 bool IsFieldNullUnsafe(int i) const
1338 {
1339 return (pauFields[i].Set.nMarker1 == OGRNullMarker &&
1340 pauFields[i].Set.nMarker2 == OGRNullMarker &&
1341 pauFields[i].Set.nMarker3 == OGRNullMarker);
1342 }
1343
1344 bool IsFieldSetAndNotNullUnsafe(int i) const
1345 {
1346 return IsFieldSetUnsafe(i) && !IsFieldNullUnsafe(i);
1347 }
1348
1349 // Those methods should only be called on a field that is of the type
1350 // consistent with the value, and that is set.
1351 int GetFieldAsIntegerUnsafe(int i) const
1352 {
1353 return pauFields[i].Integer;
1354 }
1355
1356 GIntBig GetFieldAsInteger64Unsafe(int i) const
1357 {
1358 return pauFields[i].Integer64;
1359 }
1360
1361 double GetFieldAsDoubleUnsafe(int i) const
1362 {
1363 return pauFields[i].Real;
1364 }
1365
1366 const char *GetFieldAsStringUnsafe(int i) const
1367 {
1368 return pauFields[i].String;
1369 }
1370
1372
1373 int GetFieldAsInteger(const char *pszFName) const
1374 {
1375 return GetFieldAsInteger(GetFieldIndex(pszFName));
1376 }
1377
1378 GIntBig GetFieldAsInteger64(const char *pszFName) const
1379 {
1380 return GetFieldAsInteger64(GetFieldIndex(pszFName));
1381 }
1382
1383 double GetFieldAsDouble(const char *pszFName) const
1384 {
1385 return GetFieldAsDouble(GetFieldIndex(pszFName));
1386 }
1387
1388 const char *GetFieldAsString(const char *pszFName) const
1389 {
1390 return GetFieldAsString(GetFieldIndex(pszFName));
1391 }
1392
1393 const char *GetFieldAsISO8601DateTime(const char *pszFName,
1394 CSLConstList papszOptions) const
1395 {
1396 return GetFieldAsISO8601DateTime(GetFieldIndex(pszFName), papszOptions);
1397 }
1398
1399 const int *GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
1400 {
1401 return GetFieldAsIntegerList(GetFieldIndex(pszFName), pnCount);
1402 }
1403
1404 const GIntBig *GetFieldAsInteger64List(const char *pszFName,
1405 int *pnCount) const
1406 {
1407 return GetFieldAsInteger64List(GetFieldIndex(pszFName), pnCount);
1408 }
1409
1410 const double *GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
1411 {
1412 return GetFieldAsDoubleList(GetFieldIndex(pszFName), pnCount);
1413 }
1414
1415 char **GetFieldAsStringList(const char *pszFName) const
1416 {
1417 return GetFieldAsStringList(GetFieldIndex(pszFName));
1418 }
1419
1420 void SetField(int i, int nValue);
1421 void SetField(int i, GIntBig nValue);
1422 void SetField(int i, double dfValue);
1423 void SetField(int i, const char *pszValue);
1424 void SetField(int i, int nCount, const int *panValues);
1425 void SetField(int i, int nCount, const GIntBig *panValues);
1426 void SetField(int i, int nCount, const double *padfValues);
1427 void SetField(int i, const char *const *papszValues);
1428 void SetField(int i, const OGRField *puValue);
1429 void SetField(int i, int nCount, const void *pabyBinary);
1430 void SetField(int i, int nYear, int nMonth, int nDay, int nHour = 0,
1431 int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0);
1432
1434 // Those methods should only be called on a field that is of the type
1435 // consistent with the value, and in a unset state.
1436 void SetFieldSameTypeUnsafe(int i, int nValue)
1437 {
1438 pauFields[i].Integer = nValue;
1439 pauFields[i].Set.nMarker2 = 0;
1440 pauFields[i].Set.nMarker3 = 0;
1441 }
1442
1443 void SetFieldSameTypeUnsafe(int i, GIntBig nValue)
1444 {
1445 pauFields[i].Integer64 = nValue;
1446 }
1447
1448 void SetFieldSameTypeUnsafe(int i, double dfValue)
1449 {
1450 pauFields[i].Real = dfValue;
1451 }
1452
1453 void SetFieldSameTypeUnsafe(int i, char *pszValueTransferred)
1454 {
1455 pauFields[i].String = pszValueTransferred;
1456 }
1457
1459
1460 void SetField(const char *pszFName, int nValue)
1461 {
1462 SetField(GetFieldIndex(pszFName), nValue);
1463 }
1464
1465 void SetField(const char *pszFName, GIntBig nValue)
1466 {
1467 SetField(GetFieldIndex(pszFName), nValue);
1468 }
1469
1470 void SetField(const char *pszFName, double dfValue)
1471 {
1472 SetField(GetFieldIndex(pszFName), dfValue);
1473 }
1474
1475 void SetField(const char *pszFName, const char *pszValue)
1476 {
1477 SetField(GetFieldIndex(pszFName), pszValue);
1478 }
1479
1480 void SetField(const char *pszFName, int nCount, const int *panValues)
1481 {
1482 SetField(GetFieldIndex(pszFName), nCount, panValues);
1483 }
1484
1485 void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
1486 {
1487 SetField(GetFieldIndex(pszFName), nCount, panValues);
1488 }
1489
1490 void SetField(const char *pszFName, int nCount, const double *padfValues)
1491 {
1492 SetField(GetFieldIndex(pszFName), nCount, padfValues);
1493 }
1494
1495 void SetField(const char *pszFName, const char *const *papszValues)
1496 {
1497 SetField(GetFieldIndex(pszFName), papszValues);
1498 }
1499
1500 void SetField(const char *pszFName, const OGRField *puValue)
1501 {
1502 SetField(GetFieldIndex(pszFName), puValue);
1503 }
1504
1505 void SetField(const char *pszFName, int nYear, int nMonth, int nDay,
1506 int nHour = 0, int nMinute = 0, float fSecond = 0.f,
1507 int nTZFlag = 0)
1508 {
1509 SetField(GetFieldIndex(pszFName), nYear, nMonth, nDay, nHour, nMinute,
1510 fSecond, nTZFlag);
1511 }
1512
1513 GIntBig GetFID() const
1514 {
1515 return nFID;
1516 }
1517
1518 virtual OGRErr SetFID(GIntBig nFIDIn);
1519
1520 void DumpReadable(FILE *, CSLConstList papszOptions = nullptr) const;
1521 std::string DumpReadableAsString(CSLConstList papszOptions = nullptr) const;
1522
1523 OGRErr SetFrom(const OGRFeature *, int bForgiving = TRUE);
1524 OGRErr SetFrom(const OGRFeature *, const int *panMap, int bForgiving = TRUE,
1525 bool bUseISO8601ForDateTimeAsString = false);
1526 OGRErr SetFieldsFrom(const OGRFeature *, const int *panMap,
1527 int bForgiving = TRUE,
1528 bool bUseISO8601ForDateTimeAsString = false);
1529
1531 OGRErr RemapFields(const OGRFeatureDefn *poNewDefn,
1532 const int *panRemapSource);
1533 void AppendField();
1534 OGRErr RemapGeomFields(const OGRFeatureDefn *poNewDefn,
1535 const int *panRemapSource);
1537
1538 int Validate(int nValidateFlags, int bEmitError) const;
1539 void FillUnsetWithDefault(int bNotNullableOnly, char **papszOptions);
1540
1541 bool SerializeToBinary(std::vector<GByte> &abyBuffer) const;
1542 bool DeserializeFromBinary(const GByte *pabyBuffer, size_t nSize);
1543
1544 virtual const char *GetStyleString() const;
1545 virtual void SetStyleString(const char *);
1546 virtual void SetStyleStringDirectly(char *);
1547
1551 virtual OGRStyleTable *GetStyleTable() const
1552 {
1553 return m_poStyleTable;
1554 } /* f.i.x.m.e: add a const qualifier for return type */
1555
1556 virtual void SetStyleTable(OGRStyleTable *poStyleTable);
1557 virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable);
1558
1559 const char *GetNativeData() const
1560 {
1561 return m_pszNativeData;
1562 }
1563
1564 const char *GetNativeMediaType() const
1565 {
1566 return m_pszNativeMediaType;
1567 }
1568
1569 void SetNativeData(const char *pszNativeData);
1570 void SetNativeMediaType(const char *pszNativeMediaType);
1571
1572 static OGRFeature *CreateFeature(const OGRFeatureDefn *);
1573 static void DestroyFeature(OGRFeature *);
1574
1577 static inline OGRFeatureH ToHandle(OGRFeature *poFeature)
1578 {
1579 return reinterpret_cast<OGRFeatureH>(poFeature);
1580 }
1581
1584 static inline OGRFeature *FromHandle(OGRFeatureH hFeature)
1585 {
1586 return reinterpret_cast<OGRFeature *>(hFeature);
1587 }
1588
1589 private:
1590 CPL_DISALLOW_COPY_ASSIGN(OGRFeature)
1591};
1592
1594 struct CPL_DLL OGRFeatureUniquePtrDeleter
1595{
1596 void operator()(OGRFeature *) const;
1597};
1598
1600
1603 typedef std::unique_ptr<OGRFeature, OGRFeatureUniquePtrDeleter>
1604 OGRFeatureUniquePtr;
1605
1607
1608 inline OGRFeature::ConstFieldIterator begin(const OGRFeature *poFeature)
1609{
1610 return poFeature->begin();
1611}
1612
1614 inline OGRFeature::ConstFieldIterator end(const OGRFeature *poFeature)
1615{
1616 return poFeature->end();
1617}
1618
1620 inline OGRFeature::ConstFieldIterator
1621 begin(const OGRFeatureUniquePtr &poFeature)
1622{
1623 return poFeature->begin();
1624}
1625
1627 inline OGRFeature::ConstFieldIterator end(const OGRFeatureUniquePtr &poFeature)
1628{
1629 return poFeature->end();
1630}
1631
1633
1634/************************************************************************/
1635/* OGRFieldDomain */
1636/************************************************************************/
1637
1638/* clang-format off */
1658/* clang-format on */
1659
1660 class CPL_DLL OGRFieldDomain
1661{
1662 protected:
1664 std::string m_osName;
1665 std::string m_osDescription;
1666 OGRFieldDomainType m_eDomainType;
1667 OGRFieldType m_eFieldType;
1668 OGRFieldSubType m_eFieldSubType;
1669 OGRFieldDomainSplitPolicy m_eSplitPolicy = OFDSP_DEFAULT_VALUE;
1670 OGRFieldDomainMergePolicy m_eMergePolicy = OFDMP_DEFAULT_VALUE;
1671
1672 OGRFieldDomain(const std::string &osName, const std::string &osDescription,
1673 OGRFieldDomainType eDomainType, OGRFieldType eFieldType,
1674 OGRFieldSubType eFieldSubType);
1677 public:
1682 virtual ~OGRFieldDomain();
1683
1688 virtual OGRFieldDomain *Clone() const = 0;
1689
1694 const std::string &GetName() const
1695 {
1696 return m_osName;
1697 }
1698
1704 const std::string &GetDescription() const
1705 {
1706 return m_osDescription;
1707 }
1708
1713 OGRFieldDomainType GetDomainType() const
1714 {
1715 return m_eDomainType;
1716 }
1717
1722 OGRFieldType GetFieldType() const
1723 {
1724 return m_eFieldType;
1725 }
1726
1731 OGRFieldSubType GetFieldSubType() const
1732 {
1733 return m_eFieldSubType;
1734 }
1735
1737 static inline OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)
1738 {
1739 return reinterpret_cast<OGRFieldDomainH>(poFieldDomain);
1740 }
1741
1743 static inline OGRFieldDomain *FromHandle(OGRFieldDomainH hFieldDomain)
1744 {
1745 return reinterpret_cast<OGRFieldDomain *>(hFieldDomain);
1746 }
1747
1752 OGRFieldDomainSplitPolicy GetSplitPolicy() const
1753 {
1754 return m_eSplitPolicy;
1755 }
1756
1761 void SetSplitPolicy(OGRFieldDomainSplitPolicy policy)
1762 {
1763 m_eSplitPolicy = policy;
1764 }
1765
1770 OGRFieldDomainMergePolicy GetMergePolicy() const
1771 {
1772 return m_eMergePolicy;
1773 }
1774
1779 void SetMergePolicy(OGRFieldDomainMergePolicy policy)
1780 {
1781 m_eMergePolicy = policy;
1782 }
1783};
1784
1791 class CPL_DLL OGRCodedFieldDomain final : public OGRFieldDomain
1792{
1793 private:
1794 std::vector<OGRCodedValue> m_asValues{};
1795
1796 OGRCodedFieldDomain(const OGRCodedFieldDomain &) = delete;
1797 OGRCodedFieldDomain &operator=(const OGRCodedFieldDomain &) = delete;
1798
1799 public:
1815 OGRCodedFieldDomain(const std::string &osName,
1816 const std::string &osDescription,
1817 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1818 std::vector<OGRCodedValue> &&asValues);
1819
1820 ~OGRCodedFieldDomain() override;
1821
1822 OGRCodedFieldDomain *Clone() const override;
1823
1829 const OGRCodedValue *GetEnumeration() const
1830 {
1831 return m_asValues.data();
1832 }
1833};
1834
1837 class CPL_DLL OGRRangeFieldDomain final : public OGRFieldDomain
1838{
1839 private:
1840 OGRField m_sMin;
1841 OGRField m_sMax;
1842 bool m_bMinIsInclusive;
1843 bool m_bMaxIsInclusive;
1844
1845 OGRRangeFieldDomain(const OGRRangeFieldDomain &) = delete;
1846 OGRRangeFieldDomain &operator=(const OGRRangeFieldDomain &) = delete;
1847
1848 public:
1876 OGRRangeFieldDomain(const std::string &osName,
1877 const std::string &osDescription,
1878 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1879 const OGRField &sMin, bool bMinIsInclusive,
1880 const OGRField &sMax, bool bMaxIsInclusive);
1881
1882 OGRRangeFieldDomain *Clone() const override;
1883
1897 const OGRField &GetMin(bool &bIsInclusiveOut) const
1898 {
1899 bIsInclusiveOut = m_bMinIsInclusive;
1900 return m_sMin;
1901 }
1902
1916 const OGRField &GetMax(bool &bIsInclusiveOut) const
1917 {
1918 bIsInclusiveOut = m_bMaxIsInclusive;
1919 return m_sMax;
1920 }
1921};
1922
1927 class CPL_DLL OGRGlobFieldDomain final : public OGRFieldDomain
1928{
1929 private:
1930 std::string m_osGlob;
1931
1932 OGRGlobFieldDomain(const OGRGlobFieldDomain &) = delete;
1933 OGRGlobFieldDomain &operator=(const OGRGlobFieldDomain &) = delete;
1934
1935 public:
1946 OGRGlobFieldDomain(const std::string &osName,
1947 const std::string &osDescription,
1948 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1949 const std::string &osBlob);
1950
1951 OGRGlobFieldDomain *Clone() const override;
1952
1957 const std::string &GetGlob() const
1958 {
1959 return m_osGlob;
1960 }
1961};
1962
1963/************************************************************************/
1964/* OGRFeatureQuery */
1965/************************************************************************/
1966
1968 class OGRLayer;
1969 class swq_expr_node;
1970 class swq_custom_func_registrar;
1971 struct swq_evaluation_context;
1972
1973 class CPL_DLL OGRFeatureQuery
1974{
1975 private:
1976 const OGRFeatureDefn *poTargetDefn;
1977 void *pSWQExpr;
1978 swq_evaluation_context *m_psContext = nullptr;
1979
1980 char **FieldCollector(void *, char **);
1981
1982 static GIntBig *EvaluateAgainstIndices(const swq_expr_node *, OGRLayer *,
1983 GIntBig &nFIDCount);
1984
1985 static int CanUseIndex(const swq_expr_node *, OGRLayer *);
1986
1987 OGRErr Compile(const OGRLayer *, const OGRFeatureDefn *, const char *,
1988 int bCheck,
1989 swq_custom_func_registrar *poCustomFuncRegistrar);
1990
1991 CPL_DISALLOW_COPY_ASSIGN(OGRFeatureQuery)
1992
1993 public:
1994 OGRFeatureQuery();
1995 ~OGRFeatureQuery();
1996
1997 OGRErr Compile(const OGRLayer *, const char *, int bCheck = TRUE,
1998 swq_custom_func_registrar *poCustomFuncRegistrar = nullptr);
1999 OGRErr Compile(const OGRFeatureDefn *, const char *, int bCheck = TRUE,
2000 swq_custom_func_registrar *poCustomFuncRegistrar = nullptr);
2001 int Evaluate(OGRFeature *);
2002
2003 GIntBig *EvaluateAgainstIndices(OGRLayer *, OGRErr *);
2004
2005 int CanUseIndex(OGRLayer *);
2006
2007 char **GetUsedFields();
2008
2009 void *GetSWQExpr()
2010 {
2011 return pSWQExpr;
2012 }
2013};
2014
2016
2017#endif /* ndef OGR_FEATURE_H_INCLUDED */
OGRCodedFieldDomain
Definition of a coded / enumerated field domain.
Definition ogr_feature.h:1792
OGRCodedFieldDomain::GetEnumeration
const OGRCodedValue * GetEnumeration() const
Get the enumeration as (code, value) pairs.
Definition ogr_feature.h:1829
OGRFeatureDefn
Definition of a feature class or feature layer.
Definition ogr_feature.h:504
OGRFeatureDefn::Reference
int Reference()
Increments the reference count by one.
Definition ogr_feature.h:807
OGRFeatureDefn::GetFields
ConstFields GetFields() const
Return an object that can be used to iterate over non-geometry fields.
Definition ogr_feature.h:632
OGRFeatureDefn::GetGeomFields
ConstGeomFields GetGeomFields() const
Return an object that can be used to iterate over geometry fields.
Definition ogr_feature.h:793
OGRFeatureDefn::GetFieldCount
virtual int GetFieldCount() const
Fetch number of fields on this feature.
Definition ogrfeaturedefn.cpp:261
OGRFeatureDefn::GetFieldDefn
virtual OGRFieldDefn * GetFieldDefn(int i)
Fetch field definition.
Definition ogrfeaturedefn.cpp:305
OGRFeatureDefn::GetGeomFields
NonConstGeomFields GetGeomFields()
Return an object that can be used to iterate over geometry fields.
Definition ogr_feature.h:774
OGRFeatureDefn::IsStyleIgnored
virtual bool IsStyleIgnored() const
Determine whether the style can be omitted when fetching features.
Definition ogr_feature.h:827
OGRFeatureDefn::Dereference
int Dereference()
Decrements the reference count by one.
Definition ogr_feature.h:812
OGRFeatureDefn::ToHandle
static OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
Convert a OGRFeatureDefn* to a OGRFeatureDefnH.
Definition ogr_feature.h:851
OGRFeatureDefn::NonConstFields
Fields< OGRFeatureDefn *, OGRFieldDefn * > NonConstFields
Return type of GetFields()
Definition ogr_feature.h:602
OGRFeatureDefn::FromHandle
static OGRFeatureDefn * FromHandle(OGRFeatureDefnH hFeatureDefn)
Convert a OGRFeatureDefnH to a OGRFeatureDefn*.
Definition ogr_feature.h:858
OGRFeatureDefn::NonConstGeomFields
GeomFields< OGRFeatureDefn *, OGRGeomFieldDefn * > NonConstGeomFields
Return type of GetGeomFields()
Definition ogr_feature.h:762
OGRFeatureDefn::GetGeomFieldDefn
virtual OGRGeomFieldDefn * GetGeomFieldDefn(int i)
Fetch geometry field definition.
Definition ogrfeaturedefn.cpp:706
OGRFeatureDefn::ConstFields
Fields< const OGRFeatureDefn *, const OGRFieldDefn * > ConstFields
Return type of GetFields() const.
Definition ogr_feature.h:620
OGRFeatureDefn::GetGeomFieldCount
virtual int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition ogrfeaturedefn.cpp:659
OGRFeatureDefn::ConstGeomFields
GeomFields< const OGRFeatureDefn *, const OGRGeomFieldDefn * > ConstGeomFields
Return type of GetGeomFields() const.
Definition ogr_feature.h:781
OGRFeatureDefn::GetFieldIndex
virtual int GetFieldIndex(const char *) const
Find field by name.
Definition ogrfeaturedefn.cpp:1259
OGRFeatureDefn::GetReferenceCount
int GetReferenceCount() const
Fetch current reference count.
Definition ogr_feature.h:817
OGRFeatureDefn::GetGeomFieldIndex
virtual int GetGeomFieldIndex(const char *) const
Find geometry field by name.
Definition ogrfeaturedefn.cpp:950
OGRFeatureDefn::SetStyleIgnored
virtual void SetStyleIgnored(bool bIgnore)
Set whether the style can be omitted when fetching features.
Definition ogr_feature.h:832
OGRFeatureDefn::GetFields
NonConstFields GetFields()
Return an object that can be used to iterate over non-geometry fields.
Definition ogr_feature.h:614
OGRFeature::ConstFieldIterator
Field value iterator class.
Definition ogr_feature.h:1170
OGRFeature::FieldNotFoundException
Exception raised by operator[](const char*) when a field is not found.
Definition ogr_feature.h:1220
OGRFeature::FieldValue
Field value.
Definition ogr_feature.h:960
OGRFeature::FieldValue::empty
bool empty() const
Return whether the field value is unset/empty.
Definition ogr_feature.h:1039
OGRFeature::FieldValue::GetInteger
int GetInteger() const
Return the integer value.
Definition ogr_feature.h:1059
OGRFeature::FieldValue::GetType
OGRFieldType GetType() const
Return field type.
Definition ogr_feature.h:1026
OGRFeature::FieldValue::Unset
void Unset()
Unset the field.
Definition ogr_feature.h:1005
OGRFeature::FieldValue::GetDouble
double GetDouble() const
Return the double value.
Definition ogr_feature.h:1077
OGRFeature::FieldValue::GetName
const char * GetName() const
Return field name.
Definition ogr_feature.h:1020
OGRFeature::FieldValue::GetInteger64
GIntBig GetInteger64() const
Return the 64-bit integer value.
Definition ogr_feature.h:1068
OGRFeature::FieldValue::GetSubType
OGRFieldSubType GetSubType() const
Return field subtype.
Definition ogr_feature.h:1032
OGRFeature::FieldValue::GetString
const char * GetString() const
Return the string value.
Definition ogr_feature.h:1086
OGRFeature
A simple feature, including geometry and attributes.
Definition ogr_feature.h:934
OGRFeature::GetFieldAsISO8601DateTime
const char * GetFieldAsISO8601DateTime(const char *pszFName, CSLConstList papszOptions) const
Fetch OFTDateTime field value as a ISO8601 representation.
Definition ogr_feature.h:1393
OGRFeature::ToHandle
static OGRFeatureH ToHandle(OGRFeature *poFeature)
Convert a OGRFeature* to a OGRFeatureH.
Definition ogr_feature.h:1577
OGRFeature::GetFieldAsStringList
char ** GetFieldAsStringList(const char *pszFName) const
Fetch field value as a list of strings.
Definition ogr_feature.h:1415
OGRFeature::end
ConstFieldIterator end() const
Return end of field value iterator.
Definition ogrfeature.cpp:8340
OGRFeature::begin
ConstFieldIterator begin() const
Return begin of field value iterator.
Definition ogrfeature.cpp:8335
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:1485
OGRFeature::GetDefnRef
const OGRFeatureDefn * GetDefnRef() const
Fetch feature definition.
Definition ogr_feature.h:1230
OGRFeature::GetFieldAsDoubleList
const double * GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
Fetch field value as a list of doubles.
Definition ogr_feature.h:1410
OGRFeature::SetField
void SetField(const char *pszFName, int nCount, const int *panValues)
This method currently on has an effect of OFTIntegerList, OFTInteger64List and OFTRealList fields.
Definition ogr_feature.h:1480
OGRFeature::SetField
void SetField(const char *pszFName, GIntBig nValue)
Set field to 64 bit integer value.
Definition ogr_feature.h:1465
OGRFeature::SetField
void SetField(const char *pszFName, const char *pszValue)
Set field to string value.
Definition ogr_feature.h:1475
OGRFeature::SetField
void SetField(const char *pszFName, int nValue)
Set field to integer value.
Definition ogr_feature.h:1460
OGRFeature::GetFieldDefnRef
const OGRFieldDefn * GetFieldDefnRef(int iField) const
Fetch definition for this field.
Definition ogr_feature.h:1280
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:1505
OGRFeature::GetGeomFieldDefnRef
const OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField) const
Fetch definition for this geometry field.
Definition ogr_feature.h:1251
OGRFeature::GetNativeData
const char * GetNativeData() const
Returns the native data for the feature.
Definition ogr_feature.h:1559
OGRFeature::GetFieldIndex
int GetFieldIndex(const char *pszName) const
Fetch the field index given field name.
Definition ogr_feature.h:1285
OGRFeature::GetGeomFieldIndex
int GetGeomFieldIndex(const char *pszName) const
Fetch the geometry field index given geometry field name.
Definition ogr_feature.h:1256
OGRFeature::GetFieldAsInteger64
GIntBig GetFieldAsInteger64(const char *pszFName) const
Fetch field value as integer 64 bit.
Definition ogr_feature.h:1378
OGRFeature::GetFieldAsIntegerList
const int * GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
Fetch field value as a list of integers.
Definition ogr_feature.h:1399
OGRFeature::SetField
void SetField(const char *pszFName, double dfValue)
Set field to double value.
Definition ogr_feature.h:1470
OGRFeature::GetFieldAsString
const char * GetFieldAsString(const char *pszFName) const
Fetch field value as a string.
Definition ogr_feature.h:1388
OGRFeature::SetField
void SetField(const char *pszFName, const char *const *papszValues)
This method currently on has an effect of OFTStringList fields.
Definition ogr_feature.h:1495
OGRFeature::GetRawFieldRef
const OGRField * GetRawFieldRef(int i) const
Fetch a pointer to the internal field value given the index.
Definition ogr_feature.h:1305
OGRFeature::GetFieldAsInteger
int GetFieldAsInteger(const char *pszFName) const
Fetch field value as integer.
Definition ogr_feature.h:1373
OGRFeature::GetNativeMediaType
const char * GetNativeMediaType() const
Returns the native media type for the feature.
Definition ogr_feature.h:1564
OGRFeature::SetField
void SetField(const char *pszFName, const OGRField *puValue)
Set field.
Definition ogr_feature.h:1500
OGRFeature::GetFID
GIntBig GetFID() const
Get feature identifier.
Definition ogr_feature.h:1513
OGRFeature::GetRawFieldRef
OGRField * GetRawFieldRef(int i)
Fetch a pointer to the internal field value given the index.
Definition ogr_feature.h:1300
OGRFeature::SetField
void SetField(const char *pszFName, int nCount, const double *padfValues)
This method currently on has an effect of OFTIntegerList, OFTInteger64List, OFTRealList fields.
Definition ogr_feature.h:1490
OGRFeature::GetStyleTable
virtual OGRStyleTable * GetStyleTable() const
Return style table.
Definition ogr_feature.h:1551
OGRFeature::GetFieldAsDouble
double GetFieldAsDouble(const char *pszFName) const
Fetch field value as a double.
Definition ogr_feature.h:1383
OGRFeature::FromHandle
static OGRFeature * FromHandle(OGRFeatureH hFeature)
Convert a OGRFeatureH to a OGRFeature*.
Definition ogr_feature.h:1584
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:1404
OGRFieldDefn
Definition of an attribute of an OGRFeatureDefn.
Definition ogr_feature.h:69
OGRFieldDefn::GetNameRef
const char * GetNameRef() const
Fetch name of this field.
Definition ogr_feature.h:108
OGRFieldDefn::Unseal
void Unseal()
Unseal a OGRFieldDefn.
Definition ogrfielddefn.cpp:2296
OGRFieldDefn::IsNullable
int IsNullable() const
Return whether this field can receive null values.
Definition ogr_feature.h:186
OGRFieldDefn::Seal
void Seal()
Seal a OGRFieldDefn.
Definition ogrfielddefn.cpp:2277
OGRFieldDefn::IsUnique
int IsUnique() const
Return whether this field has a unique constraint.
Definition ogr_feature.h:193
OGRFieldDefn::GetSubType
OGRFieldSubType GetSubType() const
Fetch subtype of this field.
Definition ogr_feature.h:129
OGRFieldDefn::IsGenerated
bool IsGenerated() const
Return whether the field is a generated field.
Definition ogr_feature.h:206
OGRFieldDefn::GetJustify
OGRJustification GetJustify() const
Get the justification for this field.
Definition ogr_feature.h:138
OGRFieldDefn::SetIgnored
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition ogr_feature.h:181
OGRFieldDefn::GetPrecision
int GetPrecision() const
Get the formatting precision for this field.
Definition ogr_feature.h:155
OGRFieldDefn::GetType
OGRFieldType GetType() const
Fetch type of this field.
Definition ogr_feature.h:120
OGRFieldDefn::GetWidth
int GetWidth() const
Get the formatting width for this field.
Definition ogr_feature.h:148
OGRFieldDefn::GetComment
const std::string & GetComment() const
Return the (optional) comment for this field.
Definition ogr_feature.h:230
OGRFieldDefn::GetTZFlag
int GetTZFlag() const
Get the time zone flag.
Definition ogr_feature.h:162
OGRFieldDefn::SetGenerated
void SetGenerated(bool bGeneratedIn)
SetGenerated set the field generated status.
Definition ogr_feature.h:216
OGRFieldDefn::SetJustify
void SetJustify(OGRJustification eJustifyIn)
Set the justification for this field.
Definition ogr_feature.h:143
OGRFieldDefn::GetAlternativeNameRef
const char * GetAlternativeNameRef() const
Fetch the alternative name (or "alias") for this field.
Definition ogr_feature.h:115
OGRFieldDefn::ToHandle
static OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
Convert a OGRFieldDefn* to a OGRFieldDefnH.
Definition ogr_feature.h:241
OGRFieldDefn::GetDomainName
const std::string & GetDomainName() const
Return the name of the field domain for this field.
Definition ogr_feature.h:223
OGRFieldDefn::IsIgnored
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition ogr_feature.h:176
OGRFieldDefn::FromHandle
static OGRFieldDefn * FromHandle(OGRFieldDefnH hFieldDefn)
Convert a OGRFieldDefnH to a OGRFieldDefn*.
Definition ogr_feature.h:248
OGRFieldDomain
Definition of a field domain.
Definition ogr_feature.h:1661
OGRFieldDomain::GetMergePolicy
OGRFieldDomainMergePolicy GetMergePolicy() const
Get the merge policy.
Definition ogr_feature.h:1770
OGRFieldDomain::SetMergePolicy
void SetMergePolicy(OGRFieldDomainMergePolicy policy)
Set the merge policy.
Definition ogr_feature.h:1779
OGRFieldDomain::FromHandle
static OGRFieldDomain * FromHandle(OGRFieldDomainH hFieldDomain)
Convert a OGRFieldDomainH to a OGRFieldDomain*.
Definition ogr_feature.h:1743
OGRFieldDomain::Clone
virtual OGRFieldDomain * Clone() const =0
Clone.
OGRFieldDomain::GetFieldSubType
OGRFieldSubType GetFieldSubType() const
Get the field subtype.
Definition ogr_feature.h:1731
OGRFieldDomain::GetName
const std::string & GetName() const
Get the name of the field domain.
Definition ogr_feature.h:1694
OGRFieldDomain::GetDescription
const std::string & GetDescription() const
Get the description of the field domain.
Definition ogr_feature.h:1704
OGRFieldDomain::GetSplitPolicy
OGRFieldDomainSplitPolicy GetSplitPolicy() const
Get the split policy.
Definition ogr_feature.h:1752
OGRFieldDomain::ToHandle
static OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)
Convert a OGRFieldDomain* to a OGRFieldDomainH.
Definition ogr_feature.h:1737
OGRFieldDomain::GetFieldType
OGRFieldType GetFieldType() const
Get the field type.
Definition ogr_feature.h:1722
OGRFieldDomain::GetDomainType
OGRFieldDomainType GetDomainType() const
Get the type of the field domain.
Definition ogr_feature.h:1713
OGRFieldDomain::SetSplitPolicy
void SetSplitPolicy(OGRFieldDomainSplitPolicy policy)
Set the split policy.
Definition ogr_feature.h:1761
OGRFieldDomain::~OGRFieldDomain
virtual ~OGRFieldDomain()
Destructor.
OGRGeomFieldDefn
Definition of a geometry field of an OGRFeatureDefn.
Definition ogr_feature.h:332
OGRGeomFieldDefn::SetIgnored
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition ogr_feature.h:381
OGRGeomFieldDefn::Seal
void Seal()
Seal a OGRGeomFieldDefn.
Definition ogrgeomfielddefn.cpp:859
OGRGeomFieldDefn::Unseal
void Unseal()
Unseal a OGRGeomFieldDefn.
Definition ogrgeomfielddefn.cpp:878
OGRGeomFieldDefn::FromHandle
static OGRGeomFieldDefn * FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
Convert a OGRGeomFieldDefnH to a OGRGeomFieldDefn*.
Definition ogr_feature.h:411
OGRGeomFieldDefn::IsNullable
int IsNullable() const
Return whether this geometry field can receive null values.
Definition ogr_feature.h:386
OGRGeomFieldDefn::GetType
OGRwkbGeometryType GetType() const
Fetch geometry type of this field.
Definition ogr_feature.h:366
OGRGeomFieldDefn::GetCoordinatePrecision
const OGRGeomCoordinatePrecision & GetCoordinatePrecision() const
Return the coordinate precision associated to this geometry field.
Definition ogr_feature.h:393
OGRGeomFieldDefn::IsIgnored
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition ogr_feature.h:376
OGRGeomFieldDefn::ToHandle
static OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
Convert a OGRGeomFieldDefn* to a OGRGeomFieldDefnH.
Definition ogr_feature.h:404
OGRGeomFieldDefn::GetNameRef
const char * GetNameRef() const
Fetch name of this field.
Definition ogr_feature.h:361
OGRGeometry
Abstract base class for all geometry classes.
Definition ogr_geometry.h:357
OGRGlobFieldDomain
Definition of a field domain for field content validated by a glob.
Definition ogr_feature.h:1928
OGRGlobFieldDomain::GetGlob
const std::string & GetGlob() const
Get the glob expression.
Definition ogr_feature.h:1957
OGRLayer
This class represents a layer of simple features, with access methods.
Definition ogrsf_frmts.h:61
OGRRangeFieldDomain
Definition of a numeric field domain with a range of validity for values.
Definition ogr_feature.h:1838
OGRRangeFieldDomain::GetMax
const OGRField & GetMax(bool &bIsInclusiveOut) const
Get the maximum value.
Definition ogr_feature.h:1916
OGRRangeFieldDomain::GetMin
const OGRField & GetMin(bool &bIsInclusiveOut) const
Get the minimum value.
Definition ogr_feature.h:1897
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:152
OGRStyleTable
This class represents a style table.
Definition ogr_featurestyle.h:69
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:936
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
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:870
GByte
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:175
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:205
gdal_fwd.h
Forward definitions of GDAL/OGR/OSR C handle types.
OGRFieldDefnH
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition gdal_fwd.h:122
OGRFeatureDefnH
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition gdal_fwd.h:124
OGRFeatureH
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition gdal_fwd.h:141
OGRFieldDomainH
struct OGRFieldDomainHS * OGRFieldDomainH
Opaque type for a field domain definition (OGRFieldDomain)
Definition gdal_fwd.h:131
OGRGeomFieldDefnH
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition gdal_fwd.h:128
OGRUnsetMarker
#define OGRUnsetMarker
Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for a unset field.
Definition ogr_core.h:845
OGR_TZFLAG_UNKNOWN
#define OGR_TZFLAG_UNKNOWN
Time zone flag indicating unknown timezone.
Definition ogr_core.h:858
OGRBoolean
int OGRBoolean
Type for a OGR boolean.
Definition ogr_core.h:386
OGRFieldSubType
OGRFieldSubType
List of field subtypes.
Definition ogr_core.h:799
OGRFieldDomainMergePolicy
OGRFieldDomainMergePolicy
Merge policy for field domains.
Definition ogr_core.h:1251
OFDMP_DEFAULT_VALUE
@ OFDMP_DEFAULT_VALUE
Default value.
Definition ogr_core.h:1253
OGRFieldDomainType
OGRFieldDomainType
Type of field domain.
Definition ogr_core.h:1216
OGRJustification
OGRJustification
Display justification for field values.
Definition ogr_core.h:823
OGRFieldType
OGRFieldType
List of feature field types.
Definition ogr_core.h:772
OGRNullMarker
#define OGRNullMarker
Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for a null field.
Definition ogr_core.h:852
OGRwkbGeometryType
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:405
wkbUnknown
@ wkbUnknown
unknown type, non-standard
Definition ogr_core.h:406
OGRErr
int OGRErr
Type for a OGR error.
Definition ogr_core.h:370
OGRFieldDomainSplitPolicy
OGRFieldDomainSplitPolicy
Split policy for field domains.
Definition ogr_core.h:1233
OFDSP_DEFAULT_VALUE
@ OFDSP_DEFAULT_VALUE
Default value.
Definition ogr_core.h:1235
OGRFeatureUniquePtr
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition ogr_feature.h:1604
ogr_featurestyle.h
Simple feature style classes.
ogr_geomcoordinateprecision.h
Geometry coordinate precision class.
ogr_geometry.h
Simple feature geometry classes.
begin
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition ogrsf_frmts.h:470
end
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition ogrsf_frmts.h:478
OGRCodedValue
Associates a code and a value.
Definition ogr_core.h:1203
OGRGeomCoordinatePrecision
Geometry coordinate precision.
Definition ogr_geomcoordinateprecision.h:40
OGRField
OGRFeature field attribute value union.
Definition ogr_core.h:886