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"
22
23#include <cstddef>
24
25#include <exception>
26#include <memory>
27#include <string>
28#include <vector>
29
36class OGRStyleTable;
37
38/************************************************************************/
39/* OGRFieldDefn */
40/************************************************************************/
41
68class 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 *);
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
121 {
122 return eType;
123 }
124
125 void SetType(OGRFieldType eTypeIn);
126 static const char *GetFieldTypeName(OGRFieldType);
127 static OGRFieldType GetFieldTypeByName(const char *);
128
130 {
131 return eSubType;
132 }
133
134 void SetSubType(OGRFieldSubType eSubTypeIn);
135 static const char *GetFieldSubTypeName(OGRFieldSubType);
136 static OGRFieldSubType GetFieldSubTypeByName(const char *);
137
139 {
140 return eJustify;
141 }
142
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
242 static inline OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
243 {
244 return reinterpret_cast<OGRFieldDefnH>(poFieldDefn);
245 }
246
250 static inline OGRFieldDefn *FromHandle(OGRFieldDefnH hFieldDefn)
251 {
252 return reinterpret_cast<OGRFieldDefn *>(hFieldDefn);
253 }
254
255 void Seal();
256
257 void Unseal();
258
260 struct CPL_DLL TemporaryUnsealer
261 {
262 private:
263 OGRFieldDefn *m_poFieldDefn = nullptr;
264 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
265 public:
266 explicit TemporaryUnsealer(OGRFieldDefn *poFieldDefn)
267 : m_poFieldDefn(poFieldDefn)
268 {
269 m_poFieldDefn->Unseal();
270 }
271
272 TemporaryUnsealer(TemporaryUnsealer &&) = default;
273 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
274
275 ~TemporaryUnsealer()
276 {
277 m_poFieldDefn->Seal();
278 }
279
280 OGRFieldDefn *operator->()
281 {
282 return m_poFieldDefn;
283 }
284 };
285
288 TemporaryUnsealer GetTemporaryUnsealer();
289};
290
291#ifdef GDAL_COMPILATION
303inline OGRFieldDefn::TemporaryUnsealer whileUnsealing(OGRFieldDefn *object)
304{
305 return object->GetTemporaryUnsealer();
306}
307#endif
308
309/************************************************************************/
310/* OGRGeomFieldDefn */
311/************************************************************************/
312
334class CPL_DLL OGRGeomFieldDefn
335{
336 protected:
338 char *pszName = nullptr;
339 OGRwkbGeometryType eGeomType =
340 wkbUnknown; /* all values possible except wkbNone */
341 mutable const OGRSpatialReference *poSRS = nullptr;
342
343 int bIgnore = false;
344 mutable int bNullable = true;
345 bool m_bSealed = false;
346 OGRGeomCoordinatePrecision m_oCoordPrecision{};
347
348 void Initialize(const char *, OGRwkbGeometryType);
350
351 public:
352 OGRGeomFieldDefn(const char *pszNameIn, OGRwkbGeometryType eGeomTypeIn);
353 explicit OGRGeomFieldDefn(const OGRGeomFieldDefn *);
354 virtual ~OGRGeomFieldDefn();
355
356 // Copy constructor
357 OGRGeomFieldDefn(const OGRGeomFieldDefn &oOther);
358
359 // Copy assignment operator
360 OGRGeomFieldDefn &operator=(const OGRGeomFieldDefn &oOther);
361
362 void SetName(const char *);
363
364 const char *GetNameRef() const
365 {
366 return pszName;
367 }
368
370 {
371 return eGeomType;
372 }
373
374 void SetType(OGRwkbGeometryType eTypeIn);
375
376 virtual const OGRSpatialReference *GetSpatialRef() const;
377 void SetSpatialRef(const OGRSpatialReference *poSRSIn);
378
379 int IsIgnored() const
380 {
381 return bIgnore;
382 }
383
384 void SetIgnored(int bIgnoreIn)
385 {
386 bIgnore = bIgnoreIn;
387 }
388
389 int IsNullable() const
390 {
391 return bNullable;
392 }
393
394 void SetNullable(int bNullableIn);
395
397 {
398 return m_oCoordPrecision;
399 }
400
401 void SetCoordinatePrecision(const OGRGeomCoordinatePrecision &prec);
402
403 int IsSame(const OGRGeomFieldDefn *) const;
404
408 static inline OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
409 {
410 return reinterpret_cast<OGRGeomFieldDefnH>(poGeomFieldDefn);
411 }
412
416 static inline OGRGeomFieldDefn *FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
417 {
418 return reinterpret_cast<OGRGeomFieldDefn *>(hGeomFieldDefn);
419 }
420
421 void Seal();
422
423 void Unseal();
424
426 struct CPL_DLL TemporaryUnsealer
427 {
428 private:
429 OGRGeomFieldDefn *m_poFieldDefn = nullptr;
430 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
431 public:
432 explicit TemporaryUnsealer(OGRGeomFieldDefn *poFieldDefn)
433 : m_poFieldDefn(poFieldDefn)
434 {
435 m_poFieldDefn->Unseal();
436 }
437
438 TemporaryUnsealer(TemporaryUnsealer &&) = default;
439 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
440
441 ~TemporaryUnsealer()
442 {
443 m_poFieldDefn->Seal();
444 }
445
446 OGRGeomFieldDefn *operator->()
447 {
448 return m_poFieldDefn;
449 }
450 };
451
454 TemporaryUnsealer GetTemporaryUnsealer();
455};
456
457#ifdef GDAL_COMPILATION
469inline OGRGeomFieldDefn::TemporaryUnsealer
470whileUnsealing(OGRGeomFieldDefn *object)
471{
472 return object->GetTemporaryUnsealer();
473}
474#endif
475
476/************************************************************************/
477/* OGRFeatureDefn */
478/************************************************************************/
479
508class CPL_DLL OGRFeatureDefn
509{
510 protected:
512 volatile int nRefCount = 0;
513
514 mutable std::vector<std::unique_ptr<OGRFieldDefn>> apoFieldDefn{};
515 mutable std::vector<std::unique_ptr<OGRGeomFieldDefn>> apoGeomFieldDefn{};
516
517 char *pszFeatureClassName = nullptr;
518
519 bool bIgnoreStyle = false;
520
521 friend class TemporaryUnsealer;
522 bool m_bSealed = false;
523 int m_nTemporaryUnsealCount = 0;
525
526 public:
527 explicit OGRFeatureDefn(const char *pszName = nullptr);
528 virtual ~OGRFeatureDefn();
529
530 void SetName(const char *pszName);
531 virtual const char *GetName() const;
532
533 virtual int GetFieldCount() const;
534 virtual OGRFieldDefn *GetFieldDefn(int i);
535 virtual const OGRFieldDefn *GetFieldDefn(int i) const;
536 virtual int GetFieldIndex(const char *) const;
537 int GetFieldIndexCaseSensitive(const char *) const;
538
540
544 struct CPL_DLL Fields
545 {
546 private:
547 OGRFeatureDefn *m_poFDefn;
548
549 public:
550 inline explicit Fields(OGRFeatureDefn *poFDefn) : m_poFDefn(poFDefn)
551 {
552 }
553
554 struct CPL_DLL ConstIterator
555 {
556 private:
557 OGRFeatureDefn *m_poFDefn;
558 int m_nIdx;
559
560 public:
561 inline ConstIterator(OGRFeatureDefn *poFDefn, int nIdx)
562 : m_poFDefn(poFDefn), m_nIdx(nIdx)
563 {
564 }
565
566 inline const OGRFieldDefn *operator*() const
567 {
568 return m_poFDefn->GetFieldDefn(m_nIdx);
569 }
570
571 inline ConstIterator &operator++()
572 {
573 m_nIdx++;
574 return *this;
575 }
576
577 inline bool operator!=(const ConstIterator &it) const
578 {
579 return m_nIdx != it.m_nIdx;
580 }
581 };
582
583 inline ConstIterator begin()
584 {
585 return ConstIterator(m_poFDefn, 0);
586 }
587
588 inline ConstIterator end()
589 {
590 return ConstIterator(m_poFDefn, m_poFDefn->GetFieldCount());
591 }
592
593 inline size_t size() const
594 {
595 return static_cast<std::size_t>(m_poFDefn->GetFieldCount());
596 }
597
598 inline OGRFieldDefn *operator[](size_t i)
599 {
600 return m_poFDefn->GetFieldDefn(static_cast<int>(i));
601 }
602
603 inline const OGRFieldDefn *operator[](size_t i) const
604 {
605 return m_poFDefn->GetFieldDefn(static_cast<int>(i));
606 }
607 };
608
610
621 inline Fields GetFields()
622 {
623 return Fields(this);
624 }
625
627 // That method should only be called if there's a guarantee that
628 // GetFieldCount() has been called before
629 int GetFieldCountUnsafe() const
630 {
631 return static_cast<int>(apoFieldDefn.size());
632 }
633
634 // Those methods don't check i is n range.
635 OGRFieldDefn *GetFieldDefnUnsafe(int i)
636 {
637 if (apoFieldDefn.empty())
638 GetFieldDefn(i);
639 return apoFieldDefn[static_cast<std::size_t>(i)].get();
640 }
641
642 const OGRFieldDefn *GetFieldDefnUnsafe(int i) const
643 {
644 if (apoFieldDefn.empty())
645 GetFieldDefn(i);
646 return apoFieldDefn[static_cast<std::size_t>(i)].get();
647 }
648
650
651 virtual void AddFieldDefn(const OGRFieldDefn *);
652 virtual OGRErr DeleteFieldDefn(int iField);
653
662 virtual std::unique_ptr<OGRFieldDefn> StealFieldDefn(int iField);
663
664 virtual void AddFieldDefn(std::unique_ptr<OGRFieldDefn> &&poFieldDefn);
665
666 virtual OGRErr ReorderFieldDefns(const int *panMap);
667
676 virtual std::unique_ptr<OGRGeomFieldDefn> StealGeomFieldDefn(int iField);
677
678 virtual int GetGeomFieldCount() const;
679 virtual OGRGeomFieldDefn *GetGeomFieldDefn(int i);
680 virtual const OGRGeomFieldDefn *GetGeomFieldDefn(int i) const;
681 virtual int GetGeomFieldIndex(const char *) const;
682
684
688 struct CPL_DLL GeomFields
689 {
690 private:
691 OGRFeatureDefn *m_poFDefn;
692
693 public:
694 inline explicit GeomFields(OGRFeatureDefn *poFDefn) : m_poFDefn(poFDefn)
695 {
696 }
697
698 struct CPL_DLL ConstIterator
699 {
700 private:
701 OGRFeatureDefn *m_poFDefn;
702 int m_nIdx;
703
704 public:
705 inline ConstIterator(OGRFeatureDefn *poFDefn, int nIdx)
706 : m_poFDefn(poFDefn), m_nIdx(nIdx)
707 {
708 }
709
710 inline const OGRGeomFieldDefn *operator*() const
711 {
712 return m_poFDefn->GetGeomFieldDefn(m_nIdx);
713 }
714
715 inline ConstIterator &operator++()
716 {
717 m_nIdx++;
718 return *this;
719 }
720
721 inline bool operator!=(const ConstIterator &it) const
722 {
723 return m_nIdx != it.m_nIdx;
724 }
725 };
726
727 inline ConstIterator begin()
728 {
729 return ConstIterator(m_poFDefn, 0);
730 }
731
732 inline ConstIterator end()
733 {
734 return ConstIterator(m_poFDefn, m_poFDefn->GetGeomFieldCount());
735 }
736
737 inline size_t size() const
738 {
739 return static_cast<std::size_t>(m_poFDefn->GetGeomFieldCount());
740 }
741
742 inline OGRGeomFieldDefn *operator[](size_t i)
743 {
744 return m_poFDefn->GetGeomFieldDefn(static_cast<int>(i));
745 }
746
747 inline const OGRGeomFieldDefn *operator[](size_t i) const
748 {
749 return m_poFDefn->GetGeomFieldDefn(static_cast<int>(i));
750 }
751 };
752
754
765 inline GeomFields GetGeomFields()
766 {
767 return GeomFields(this);
768 }
769
770 virtual void AddGeomFieldDefn(const OGRGeomFieldDefn *);
771 virtual void AddGeomFieldDefn(std::unique_ptr<OGRGeomFieldDefn> &&);
772 virtual OGRErr DeleteGeomFieldDefn(int iGeomField);
773
774 virtual OGRwkbGeometryType GetGeomType() const;
775 virtual void SetGeomType(OGRwkbGeometryType);
776
777 virtual OGRFeatureDefn *Clone() const;
778
780 {
781 return CPLAtomicInc(&nRefCount);
782 }
783
785 {
786 return CPLAtomicDec(&nRefCount);
787 }
788
790 {
791 return nRefCount;
792 }
793
794 void Release();
795
796 virtual int IsGeometryIgnored() const;
797 virtual void SetGeometryIgnored(int bIgnore);
798
799 virtual bool IsStyleIgnored() const
800 {
801 return bIgnoreStyle;
802 }
803
804 virtual void SetStyleIgnored(bool bIgnore)
805 {
806 bIgnoreStyle = bIgnore;
807 }
808
809 virtual int IsSame(const OGRFeatureDefn *poOtherFeatureDefn) const;
810
812 void ReserveSpaceForFields(int nFieldCountIn);
814
815 std::vector<int> ComputeMapForSetFrom(const OGRFeatureDefn *poSrcFDefn,
816 bool bForgiving = true) const;
817
818 static OGRFeatureDefn *CreateFeatureDefn(const char *pszName = nullptr);
819 static void DestroyFeatureDefn(OGRFeatureDefn *);
820
824 static inline OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
825 {
826 return reinterpret_cast<OGRFeatureDefnH>(poFeatureDefn);
827 }
828
832 static inline OGRFeatureDefn *FromHandle(OGRFeatureDefnH hFeatureDefn)
833 {
834 return reinterpret_cast<OGRFeatureDefn *>(hFeatureDefn);
835 }
836
837 void Seal(bool bSealFields);
838
839 void Unseal(bool bUnsealFields);
840
842 struct CPL_DLL TemporaryUnsealer
843 {
844 private:
845 OGRFeatureDefn *m_poFeatureDefn = nullptr;
846 bool m_bSealFields = false;
847 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
848 public:
849 explicit TemporaryUnsealer(OGRFeatureDefn *poFeatureDefn,
850 bool bSealFields);
851
852 TemporaryUnsealer(TemporaryUnsealer &&) = default;
853 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
854
855 ~TemporaryUnsealer();
856
857 OGRFeatureDefn *operator->()
858 {
859 return m_poFeatureDefn;
860 }
861 };
862
865 TemporaryUnsealer GetTemporaryUnsealer(bool bSealFields = true);
866
867 private:
869};
870
871#ifdef GDAL_COMPILATION
892inline OGRFeatureDefn::TemporaryUnsealer whileUnsealing(OGRFeatureDefn *object,
893 bool bSealFields = true)
894{
895 return object->GetTemporaryUnsealer(bSealFields);
896}
897#endif
898
899/************************************************************************/
900/* OGRFeature */
901/************************************************************************/
902
907class CPL_DLL OGRFeature
908{
909 private:
910 GIntBig nFID;
911 OGRFeatureDefn *poDefn;
912 OGRGeometry **papoGeometries;
913 OGRField *pauFields;
914 char *m_pszNativeData;
915 char *m_pszNativeMediaType;
916
917 bool SetFieldInternal(int i, const OGRField *puValue);
918
919 protected:
921 mutable char *m_pszStyleString;
922 mutable OGRStyleTable *m_poStyleTable;
923 mutable char *m_pszTmpFieldValue;
925
926 bool CopySelfTo(OGRFeature *poNew) const;
927
928 public:
929 explicit OGRFeature(OGRFeatureDefn *);
930 virtual ~OGRFeature();
931
933 class CPL_DLL FieldValue
934 {
935 friend class OGRFeature;
936 struct Private;
937 std::unique_ptr<Private> m_poPrivate;
938
939 FieldValue(OGRFeature *poFeature, int iFieldIndex);
940 FieldValue(const OGRFeature *poFeature, int iFieldIndex);
941 FieldValue(const FieldValue &oOther) = delete;
942 FieldValue &Assign(const FieldValue &oOther);
943
944 public:
946 ~FieldValue();
947
948 FieldValue &operator=(FieldValue &&oOther);
950
952 FieldValue &operator=(const FieldValue &oOther);
954 FieldValue &operator=(int nVal);
956 FieldValue &operator=(GIntBig nVal);
958 FieldValue &operator=(double dfVal);
960 FieldValue &operator=(const char *pszVal);
962 FieldValue &operator=(const std::string &osVal);
964 FieldValue &operator=(const std::vector<int> &oArray);
966 FieldValue &operator=(const std::vector<GIntBig> &oArray);
968 FieldValue &operator=(const std::vector<double> &oArray);
970 FieldValue &operator=(const std::vector<std::string> &oArray);
972 FieldValue &operator=(CSLConstList papszValues);
974 void SetNull();
976 void clear();
977
979 void Unset()
980 {
981 clear();
982 }
983
985 void SetDateTime(int nYear, int nMonth, int nDay, int nHour = 0,
986 int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0);
987
989 int GetIndex() const;
991 const OGRFieldDefn *GetDefn() const;
992
994 const char *GetName() const
995 {
996 return GetDefn()->GetNameRef();
997 }
998
1001 {
1002 return GetDefn()->GetType();
1003 }
1004
1007 {
1008 return GetDefn()->GetSubType();
1009 }
1010
1012 // cppcheck-suppress functionStatic
1013 bool empty() const
1014 {
1015 return IsUnset();
1016 }
1017
1019 // cppcheck-suppress functionStatic
1020 bool IsUnset() const;
1021
1023 // cppcheck-suppress functionStatic
1024 bool IsNull() const;
1025
1027 const OGRField *GetRawValue() const;
1028
1032 // cppcheck-suppress functionStatic
1033 int GetInteger() const
1034 {
1035 return GetRawValue()->Integer;
1036 }
1037
1041 // cppcheck-suppress functionStatic
1043 {
1044 return GetRawValue()->Integer64;
1045 }
1046
1050 // cppcheck-suppress functionStatic
1051 double GetDouble() const
1052 {
1053 return GetRawValue()->Real;
1054 }
1055
1059 // cppcheck-suppress functionStatic
1060 const char *GetString() const
1061 {
1062 return GetRawValue()->String;
1063 }
1064
1066 bool GetDateTime(int *pnYear, int *pnMonth, int *pnDay, int *pnHour,
1067 int *pnMinute, float *pfSecond, int *pnTZFlag) const;
1068
1070 operator int() const
1071 {
1072 return GetAsInteger();
1073 }
1074
1077 operator GIntBig() const
1078 {
1079 return GetAsInteger64();
1080 }
1081
1083 operator double() const
1084 {
1085 return GetAsDouble();
1086 }
1087
1089 operator const char *() const
1090 {
1091 return GetAsString();
1092 }
1093
1095 operator const std::vector<int> &() const
1096 {
1097 return GetAsIntegerList();
1098 }
1099
1102 operator const std::vector<GIntBig> &() const
1103 {
1104 return GetAsInteger64List();
1105 }
1106
1108 operator const std::vector<double> &() const
1109 {
1110 return GetAsDoubleList();
1111 }
1112
1114 operator const std::vector<std::string> &() const
1115 {
1116 return GetAsStringList();
1117 }
1118
1120 operator CSLConstList() const;
1121
1123 int GetAsInteger() const;
1126 GIntBig GetAsInteger64() const;
1128 double GetAsDouble() const;
1130 const char *GetAsString() const;
1132 const std::vector<int> &GetAsIntegerList() const;
1135 const std::vector<GIntBig> &GetAsInteger64List() const;
1137 const std::vector<double> &GetAsDoubleList() const;
1139 const std::vector<std::string> &GetAsStringList() const;
1140 };
1141
1144 {
1145 friend class OGRFeature;
1146 struct Private;
1147 std::unique_ptr<Private> m_poPrivate;
1148
1149 ConstFieldIterator(const OGRFeature *poSelf, int nPos);
1150
1151 public:
1154 ConstFieldIterator &&oOther) noexcept; // declared but not defined.
1155 // Needed for gcc 5.4 at least
1157 const FieldValue &operator*() const;
1158 ConstFieldIterator &operator++();
1159 bool operator!=(const ConstFieldIterator &it) const;
1161 };
1162
1180 ConstFieldIterator begin() const;
1182 ConstFieldIterator end() const;
1183
1184 const FieldValue operator[](int iField) const;
1185 FieldValue operator[](int iField);
1186
1189 class FieldNotFoundException : public std::exception
1190 {
1191 };
1192
1193 const FieldValue operator[](const char *pszFieldName) const;
1194 FieldValue operator[](const char *pszFieldName);
1195
1197 {
1198 return poDefn;
1199 }
1200
1202 {
1203 return poDefn;
1204 }
1205
1207 void SetFDefnUnsafe(OGRFeatureDefn *poNewFDefn);
1209
1210 OGRErr SetGeometryDirectly(OGRGeometry *);
1211 OGRErr SetGeometry(const OGRGeometry *);
1212 OGRErr SetGeometry(std::unique_ptr<OGRGeometry>);
1213 OGRGeometry *GetGeometryRef();
1214 const OGRGeometry *GetGeometryRef() const;
1215 OGRGeometry *StealGeometry() CPL_WARN_UNUSED_RESULT;
1216
1217 int GetGeomFieldCount() const
1218 {
1219 return poDefn->GetGeomFieldCount();
1220 }
1221
1223 {
1224 return poDefn->GetGeomFieldDefn(iField);
1225 }
1226
1227 const OGRGeomFieldDefn *GetGeomFieldDefnRef(int iField) const
1228 {
1229 return poDefn->GetGeomFieldDefn(iField);
1230 }
1231
1232 int GetGeomFieldIndex(const char *pszName) const
1233 {
1234 return poDefn->GetGeomFieldIndex(pszName);
1235 }
1236
1237 OGRGeometry *GetGeomFieldRef(int iField);
1238 const OGRGeometry *GetGeomFieldRef(int iField) const;
1239 OGRGeometry *StealGeometry(int iField);
1240 OGRGeometry *GetGeomFieldRef(const char *pszFName);
1241 const OGRGeometry *GetGeomFieldRef(const char *pszFName) const;
1242 OGRErr SetGeomFieldDirectly(int iField, OGRGeometry *);
1243 OGRErr SetGeomField(int iField, const OGRGeometry *);
1244 OGRErr SetGeomField(int iField, std::unique_ptr<OGRGeometry>);
1245
1246 void Reset();
1247
1248 OGRFeature *Clone() const CPL_WARN_UNUSED_RESULT;
1249 virtual OGRBoolean Equal(const OGRFeature *poFeature) const;
1250
1251 int GetFieldCount() const
1252 {
1253 return poDefn->GetFieldCount();
1254 }
1255
1256 const OGRFieldDefn *GetFieldDefnRef(int iField) const
1257 {
1258 return poDefn->GetFieldDefn(iField);
1259 }
1260
1262 {
1263 return poDefn->GetFieldDefn(iField);
1264 }
1265
1266 int GetFieldIndex(const char *pszName) const
1267 {
1268 return poDefn->GetFieldIndex(pszName);
1269 }
1270
1271 int IsFieldSet(int iField) const;
1272
1273 void UnsetField(int iField);
1274
1275 bool IsFieldNull(int iField) const;
1276
1277 void SetFieldNull(int iField);
1278
1279 bool IsFieldSetAndNotNull(int iField) const;
1280
1282 {
1283 return pauFields + i;
1284 }
1285
1286 const OGRField *GetRawFieldRef(int i) const
1287 {
1288 return pauFields + i;
1289 }
1290
1291 int GetFieldAsInteger(int i) const;
1292 GIntBig GetFieldAsInteger64(int i) const;
1293 double GetFieldAsDouble(int i) const;
1294 const char *GetFieldAsString(int i) const;
1295 const char *GetFieldAsISO8601DateTime(int i,
1296 CSLConstList papszOptions) const;
1297 const int *GetFieldAsIntegerList(int i, int *pnCount) const;
1298 const GIntBig *GetFieldAsInteger64List(int i, int *pnCount) const;
1299 const double *GetFieldAsDoubleList(int i, int *pnCount) const;
1300 char **GetFieldAsStringList(int i) const;
1301 GByte *GetFieldAsBinary(int i, int *pnCount) const;
1302 int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay,
1303 int *pnHour, int *pnMinute, int *pnSecond,
1304 int *pnTZFlag) const;
1305 int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay,
1306 int *pnHour, int *pnMinute, float *pfSecond,
1307 int *pnTZFlag) const;
1308 char *GetFieldAsSerializedJSon(int i) const;
1309
1311 bool IsFieldSetUnsafe(int i) const
1312 {
1313 return !(pauFields[i].Set.nMarker1 == OGRUnsetMarker &&
1314 pauFields[i].Set.nMarker2 == OGRUnsetMarker &&
1315 pauFields[i].Set.nMarker3 == OGRUnsetMarker);
1316 }
1317
1318 bool IsFieldNullUnsafe(int i) const
1319 {
1320 return (pauFields[i].Set.nMarker1 == OGRNullMarker &&
1321 pauFields[i].Set.nMarker2 == OGRNullMarker &&
1322 pauFields[i].Set.nMarker3 == OGRNullMarker);
1323 }
1324
1325 bool IsFieldSetAndNotNullUnsafe(int i) const
1326 {
1327 return IsFieldSetUnsafe(i) && !IsFieldNullUnsafe(i);
1328 }
1329
1330 // Those methods should only be called on a field that is of the type
1331 // consistent with the value, and that is set.
1332 int GetFieldAsIntegerUnsafe(int i) const
1333 {
1334 return pauFields[i].Integer;
1335 }
1336
1337 GIntBig GetFieldAsInteger64Unsafe(int i) const
1338 {
1339 return pauFields[i].Integer64;
1340 }
1341
1342 double GetFieldAsDoubleUnsafe(int i) const
1343 {
1344 return pauFields[i].Real;
1345 }
1346
1347 const char *GetFieldAsStringUnsafe(int i) const
1348 {
1349 return pauFields[i].String;
1350 }
1351
1353
1354 int GetFieldAsInteger(const char *pszFName) const
1355 {
1356 return GetFieldAsInteger(GetFieldIndex(pszFName));
1357 }
1358
1359 GIntBig GetFieldAsInteger64(const char *pszFName) const
1360 {
1361 return GetFieldAsInteger64(GetFieldIndex(pszFName));
1362 }
1363
1364 double GetFieldAsDouble(const char *pszFName) const
1365 {
1366 return GetFieldAsDouble(GetFieldIndex(pszFName));
1367 }
1368
1369 const char *GetFieldAsString(const char *pszFName) const
1370 {
1371 return GetFieldAsString(GetFieldIndex(pszFName));
1372 }
1373
1374 const char *GetFieldAsISO8601DateTime(const char *pszFName,
1375 CSLConstList papszOptions) const
1376 {
1377 return GetFieldAsISO8601DateTime(GetFieldIndex(pszFName), papszOptions);
1378 }
1379
1380 const int *GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
1381 {
1382 return GetFieldAsIntegerList(GetFieldIndex(pszFName), pnCount);
1383 }
1384
1385 const GIntBig *GetFieldAsInteger64List(const char *pszFName,
1386 int *pnCount) const
1387 {
1388 return GetFieldAsInteger64List(GetFieldIndex(pszFName), pnCount);
1389 }
1390
1391 const double *GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
1392 {
1393 return GetFieldAsDoubleList(GetFieldIndex(pszFName), pnCount);
1394 }
1395
1396 char **GetFieldAsStringList(const char *pszFName) const
1397 {
1398 return GetFieldAsStringList(GetFieldIndex(pszFName));
1399 }
1400
1401 void SetField(int i, int nValue);
1402 void SetField(int i, GIntBig nValue);
1403 void SetField(int i, double dfValue);
1404 void SetField(int i, const char *pszValue);
1405 void SetField(int i, int nCount, const int *panValues);
1406 void SetField(int i, int nCount, const GIntBig *panValues);
1407 void SetField(int i, int nCount, const double *padfValues);
1408 void SetField(int i, const char *const *papszValues);
1409 void SetField(int i, const OGRField *puValue);
1410 void SetField(int i, int nCount, const void *pabyBinary);
1411 void SetField(int i, int nYear, int nMonth, int nDay, int nHour = 0,
1412 int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0);
1413
1415 // Those methods should only be called on a field that is of the type
1416 // consistent with the value, and in a unset state.
1417 void SetFieldSameTypeUnsafe(int i, int nValue)
1418 {
1419 pauFields[i].Integer = nValue;
1420 pauFields[i].Set.nMarker2 = 0;
1421 pauFields[i].Set.nMarker3 = 0;
1422 }
1423
1424 void SetFieldSameTypeUnsafe(int i, GIntBig nValue)
1425 {
1426 pauFields[i].Integer64 = nValue;
1427 }
1428
1429 void SetFieldSameTypeUnsafe(int i, double dfValue)
1430 {
1431 pauFields[i].Real = dfValue;
1432 }
1433
1434 void SetFieldSameTypeUnsafe(int i, char *pszValueTransferred)
1435 {
1436 pauFields[i].String = pszValueTransferred;
1437 }
1438
1440
1441 void SetField(const char *pszFName, int nValue)
1442 {
1443 SetField(GetFieldIndex(pszFName), nValue);
1444 }
1445
1446 void SetField(const char *pszFName, GIntBig nValue)
1447 {
1448 SetField(GetFieldIndex(pszFName), nValue);
1449 }
1450
1451 void SetField(const char *pszFName, double dfValue)
1452 {
1453 SetField(GetFieldIndex(pszFName), dfValue);
1454 }
1455
1456 void SetField(const char *pszFName, const char *pszValue)
1457 {
1458 SetField(GetFieldIndex(pszFName), pszValue);
1459 }
1460
1461 void SetField(const char *pszFName, int nCount, const int *panValues)
1462 {
1463 SetField(GetFieldIndex(pszFName), nCount, panValues);
1464 }
1465
1466 void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
1467 {
1468 SetField(GetFieldIndex(pszFName), nCount, panValues);
1469 }
1470
1471 void SetField(const char *pszFName, int nCount, const double *padfValues)
1472 {
1473 SetField(GetFieldIndex(pszFName), nCount, padfValues);
1474 }
1475
1476 void SetField(const char *pszFName, const char *const *papszValues)
1477 {
1478 SetField(GetFieldIndex(pszFName), papszValues);
1479 }
1480
1481 void SetField(const char *pszFName, const OGRField *puValue)
1482 {
1483 SetField(GetFieldIndex(pszFName), puValue);
1484 }
1485
1486 void SetField(const char *pszFName, int nYear, int nMonth, int nDay,
1487 int nHour = 0, int nMinute = 0, float fSecond = 0.f,
1488 int nTZFlag = 0)
1489 {
1490 SetField(GetFieldIndex(pszFName), nYear, nMonth, nDay, nHour, nMinute,
1491 fSecond, nTZFlag);
1492 }
1493
1495 {
1496 return nFID;
1497 }
1498
1499 virtual OGRErr SetFID(GIntBig nFIDIn);
1500
1501 void DumpReadable(FILE *, CSLConstList papszOptions = nullptr) const;
1502 std::string DumpReadableAsString(CSLConstList papszOptions = nullptr) const;
1503
1504 OGRErr SetFrom(const OGRFeature *, int bForgiving = TRUE);
1505 OGRErr SetFrom(const OGRFeature *, const int *panMap, int bForgiving = TRUE,
1506 bool bUseISO8601ForDateTimeAsString = false);
1507 OGRErr SetFieldsFrom(const OGRFeature *, const int *panMap,
1508 int bForgiving = TRUE,
1509 bool bUseISO8601ForDateTimeAsString = false);
1510
1512 OGRErr RemapFields(OGRFeatureDefn *poNewDefn, const int *panRemapSource);
1513 void AppendField();
1514 OGRErr RemapGeomFields(OGRFeatureDefn *poNewDefn,
1515 const int *panRemapSource);
1517
1518 int Validate(int nValidateFlags, int bEmitError) const;
1519 void FillUnsetWithDefault(int bNotNullableOnly, char **papszOptions);
1520
1521 bool SerializeToBinary(std::vector<GByte> &abyBuffer) const;
1522 bool DeserializeFromBinary(const GByte *pabyBuffer, size_t nSize);
1523
1524 virtual const char *GetStyleString() const;
1525 virtual void SetStyleString(const char *);
1526 virtual void SetStyleStringDirectly(char *);
1527
1532 {
1533 return m_poStyleTable;
1534 } /* f.i.x.m.e: add a const qualifier for return type */
1535
1536 virtual void SetStyleTable(OGRStyleTable *poStyleTable);
1537 virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable);
1538
1539 const char *GetNativeData() const
1540 {
1541 return m_pszNativeData;
1542 }
1543
1544 const char *GetNativeMediaType() const
1545 {
1546 return m_pszNativeMediaType;
1547 }
1548
1549 void SetNativeData(const char *pszNativeData);
1550 void SetNativeMediaType(const char *pszNativeMediaType);
1551
1552 static OGRFeature *CreateFeature(OGRFeatureDefn *);
1553 static void DestroyFeature(OGRFeature *);
1554
1558 static inline OGRFeatureH ToHandle(OGRFeature *poFeature)
1559 {
1560 return reinterpret_cast<OGRFeatureH>(poFeature);
1561 }
1562
1566 static inline OGRFeature *FromHandle(OGRFeatureH hFeature)
1567 {
1568 return reinterpret_cast<OGRFeature *>(hFeature);
1569 }
1570
1571 private:
1573};
1574
1576struct CPL_DLL OGRFeatureUniquePtrDeleter
1577{
1578 void operator()(OGRFeature *) const;
1579};
1580
1582
1586typedef std::unique_ptr<OGRFeature, OGRFeatureUniquePtrDeleter>
1588
1590
1591inline OGRFeature::ConstFieldIterator begin(const OGRFeature *poFeature)
1592{
1593 return poFeature->begin();
1594}
1595
1597inline OGRFeature::ConstFieldIterator end(const OGRFeature *poFeature)
1598{
1599 return poFeature->end();
1600}
1601
1604begin(const OGRFeatureUniquePtr &poFeature)
1605{
1606 return poFeature->begin();
1607}
1608
1611{
1612 return poFeature->end();
1613}
1614
1616
1617/************************************************************************/
1618/* OGRFieldDomain */
1619/************************************************************************/
1620
1621/* clang-format off */
1641/* clang-format on */
1642
1643class CPL_DLL OGRFieldDomain
1644{
1645 protected:
1647 std::string m_osName;
1648 std::string m_osDescription;
1649 OGRFieldDomainType m_eDomainType;
1650 OGRFieldType m_eFieldType;
1651 OGRFieldSubType m_eFieldSubType;
1654
1655 OGRFieldDomain(const std::string &osName, const std::string &osDescription,
1656 OGRFieldDomainType eDomainType, OGRFieldType eFieldType,
1657 OGRFieldSubType eFieldSubType);
1660 public:
1665 virtual ~OGRFieldDomain() = 0;
1666
1671 virtual OGRFieldDomain *Clone() const = 0;
1672
1677 const std::string &GetName() const
1678 {
1679 return m_osName;
1680 }
1681
1687 const std::string &GetDescription() const
1688 {
1689 return m_osDescription;
1690 }
1691
1697 {
1698 return m_eDomainType;
1699 }
1700
1706 {
1707 return m_eFieldType;
1708 }
1709
1715 {
1716 return m_eFieldSubType;
1717 }
1718
1720 static inline OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)
1721 {
1722 return reinterpret_cast<OGRFieldDomainH>(poFieldDomain);
1723 }
1724
1726 static inline OGRFieldDomain *FromHandle(OGRFieldDomainH hFieldDomain)
1727 {
1728 return reinterpret_cast<OGRFieldDomain *>(hFieldDomain);
1729 }
1730
1736 {
1737 return m_eSplitPolicy;
1738 }
1739
1745 {
1746 m_eSplitPolicy = policy;
1747 }
1748
1754 {
1755 return m_eMergePolicy;
1756 }
1757
1763 {
1764 m_eMergePolicy = policy;
1765 }
1766};
1767
1774class CPL_DLL OGRCodedFieldDomain final : public OGRFieldDomain
1775{
1776 private:
1777 std::vector<OGRCodedValue> m_asValues{};
1778
1779 OGRCodedFieldDomain(const OGRCodedFieldDomain &) = delete;
1780 OGRCodedFieldDomain &operator=(const OGRCodedFieldDomain &) = delete;
1781
1782 public:
1798 OGRCodedFieldDomain(const std::string &osName,
1799 const std::string &osDescription,
1800 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1801 std::vector<OGRCodedValue> &&asValues);
1802
1803 ~OGRCodedFieldDomain() override;
1804
1805 OGRCodedFieldDomain *Clone() const override;
1806
1813 {
1814 return m_asValues.data();
1815 }
1816};
1817
1820class CPL_DLL OGRRangeFieldDomain final : public OGRFieldDomain
1821{
1822 private:
1823 OGRField m_sMin;
1824 OGRField m_sMax;
1825 bool m_bMinIsInclusive;
1826 bool m_bMaxIsInclusive;
1827
1828 OGRRangeFieldDomain(const OGRRangeFieldDomain &) = delete;
1829 OGRRangeFieldDomain &operator=(const OGRRangeFieldDomain &) = delete;
1830
1831 public:
1859 OGRRangeFieldDomain(const std::string &osName,
1860 const std::string &osDescription,
1861 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1862 const OGRField &sMin, bool bMinIsInclusive,
1863 const OGRField &sMax, bool bMaxIsInclusive);
1864
1865 OGRRangeFieldDomain *Clone() const override
1866 {
1867 auto poDomain = new OGRRangeFieldDomain(
1868 m_osName, m_osDescription, m_eFieldType, m_eFieldSubType, m_sMin,
1869 m_bMinIsInclusive, m_sMax, m_bMaxIsInclusive);
1870 poDomain->SetMergePolicy(m_eMergePolicy);
1871 poDomain->SetSplitPolicy(m_eSplitPolicy);
1872 return poDomain;
1873 }
1874
1888 const OGRField &GetMin(bool &bIsInclusiveOut) const
1889 {
1890 bIsInclusiveOut = m_bMinIsInclusive;
1891 return m_sMin;
1892 }
1893
1907 const OGRField &GetMax(bool &bIsInclusiveOut) const
1908 {
1909 bIsInclusiveOut = m_bMaxIsInclusive;
1910 return m_sMax;
1911 }
1912};
1913
1918class CPL_DLL OGRGlobFieldDomain final : public OGRFieldDomain
1919{
1920 private:
1921 std::string m_osGlob;
1922
1923 OGRGlobFieldDomain(const OGRGlobFieldDomain &) = delete;
1924 OGRGlobFieldDomain &operator=(const OGRGlobFieldDomain &) = delete;
1925
1926 public:
1937 OGRGlobFieldDomain(const std::string &osName,
1938 const std::string &osDescription,
1939 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1940 const std::string &osBlob);
1941
1942 OGRGlobFieldDomain *Clone() const override
1943 {
1944 auto poDomain = new OGRGlobFieldDomain(
1945 m_osName, m_osDescription, m_eFieldType, m_eFieldSubType, m_osGlob);
1946 poDomain->SetMergePolicy(m_eMergePolicy);
1947 poDomain->SetSplitPolicy(m_eSplitPolicy);
1948 return poDomain;
1949 }
1950
1955 const std::string &GetGlob() const
1956 {
1957 return m_osGlob;
1958 }
1959};
1960
1961/************************************************************************/
1962/* OGRFeatureQuery */
1963/************************************************************************/
1964
1966class OGRLayer;
1967class swq_expr_node;
1968class swq_custom_func_registrar;
1969struct swq_evaluation_context;
1970
1971class CPL_DLL OGRFeatureQuery
1972{
1973 private:
1974 OGRFeatureDefn *poTargetDefn;
1975 void *pSWQExpr;
1976 swq_evaluation_context *m_psContext = nullptr;
1977
1978 char **FieldCollector(void *, char **);
1979
1980 static GIntBig *EvaluateAgainstIndices(const swq_expr_node *, OGRLayer *,
1981 GIntBig &nFIDCount);
1982
1983 static int CanUseIndex(const swq_expr_node *, OGRLayer *);
1984
1985 OGRErr Compile(OGRLayer *, OGRFeatureDefn *, const char *, int bCheck,
1986 swq_custom_func_registrar *poCustomFuncRegistrar);
1987
1988 CPL_DISALLOW_COPY_ASSIGN(OGRFeatureQuery)
1989
1990 public:
1991 OGRFeatureQuery();
1992 ~OGRFeatureQuery();
1993
1994 OGRErr Compile(OGRLayer *, const char *, int bCheck = TRUE,
1995 swq_custom_func_registrar *poCustomFuncRegistrar = nullptr);
1996 OGRErr Compile(OGRFeatureDefn *, const char *, int bCheck = TRUE,
1997 swq_custom_func_registrar *poCustomFuncRegistrar = nullptr);
1998 int Evaluate(OGRFeature *);
1999
2000 GIntBig *EvaluateAgainstIndices(OGRLayer *, OGRErr *);
2001
2002 int CanUseIndex(OGRLayer *);
2003
2004 char **GetUsedFields();
2005
2006 void *GetSWQExpr()
2007 {
2008 return pSWQExpr;
2009 }
2010};
2011
2013
2014#endif /* ndef OGR_FEATURE_H_INCLUDED */
Definition of a coded / enumerated field domain.
Definition ogr_feature.h:1775
const OGRCodedValue * GetEnumeration() const
Get the enumeration as (code, value) pairs.
Definition ogr_feature.h:1812
Definition of a feature class or feature layer.
Definition ogr_feature.h:509
int Reference()
Increments the reference count by one.
Definition ogr_feature.h:779
virtual int GetFieldCount() const
Fetch number of fields on this feature.
Definition ogrfeaturedefn.cpp:262
virtual OGRFieldDefn * GetFieldDefn(int i)
Fetch field definition.
Definition ogrfeaturedefn.cpp:306
GeomFields GetGeomFields()
Return an object that can be used to iterate over geometry fields.
Definition ogr_feature.h:765
virtual bool IsStyleIgnored() const
Determine whether the style can be omitted when fetching features.
Definition ogr_feature.h:799
Fields GetFields()
Return an object that can be used to iterate over non-geometry fields.
Definition ogr_feature.h:621
int Dereference()
Decrements the reference count by one.
Definition ogr_feature.h:784
static OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
Convert a OGRFeatureDefn* to a OGRFeatureDefnH.
Definition ogr_feature.h:824
static OGRFeatureDefn * FromHandle(OGRFeatureDefnH hFeatureDefn)
Convert a OGRFeatureDefnH to a OGRFeatureDefn*.
Definition ogr_feature.h:832
virtual OGRGeomFieldDefn * GetGeomFieldDefn(int i)
Fetch geometry field definition.
Definition ogrfeaturedefn.cpp:715
virtual int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition ogrfeaturedefn.cpp:666
virtual int GetFieldIndex(const char *) const
Find field by name.
Definition ogrfeaturedefn.cpp:1274
int GetReferenceCount() const
Fetch current reference count.
Definition ogr_feature.h:789
virtual int GetGeomFieldIndex(const char *) const
Find geometry field by name.
Definition ogrfeaturedefn.cpp:965
virtual void SetStyleIgnored(bool bIgnore)
Set whether the style can be omitted when fetching features.
Definition ogr_feature.h:804
Field value iterator class.
Definition ogr_feature.h:1144
Exception raised by operator[](const char*) when a field is not found.
Definition ogr_feature.h:1190
Field value.
Definition ogr_feature.h:934
bool empty() const
Return whether the field value is unset/empty.
Definition ogr_feature.h:1013
int GetInteger() const
Return the integer value.
Definition ogr_feature.h:1033
OGRFieldType GetType() const
Return field type.
Definition ogr_feature.h:1000
void Unset()
Unset the field.
Definition ogr_feature.h:979
double GetDouble() const
Return the double value.
Definition ogr_feature.h:1051
const char * GetName() const
Return field name.
Definition ogr_feature.h:994
GIntBig GetInteger64() const
Return the 64-bit integer value.
Definition ogr_feature.h:1042
OGRFieldSubType GetSubType() const
Return field subtype.
Definition ogr_feature.h:1006
const char * GetString() const
Return the string value.
Definition ogr_feature.h:1060
A simple feature, including geometry and attributes.
Definition ogr_feature.h:908
OGRFeatureDefn * GetDefnRef()
Fetch feature definition.
Definition ogr_feature.h:1196
const char * GetFieldAsISO8601DateTime(const char *pszFName, CSLConstList papszOptions) const
Fetch OFTDateTime field value as a ISO8601 representation.
Definition ogr_feature.h:1374
static OGRFeatureH ToHandle(OGRFeature *poFeature)
Convert a OGRFeature* to a OGRFeatureH.
Definition ogr_feature.h:1558
char ** GetFieldAsStringList(const char *pszFName) const
Fetch field value as a list of strings.
Definition ogr_feature.h:1396
ConstFieldIterator end() const
Return end of field value iterator.
Definition ogrfeature.cpp:8424
ConstFieldIterator begin() const
Return begin of field value iterator.
Definition ogrfeature.cpp:8419
void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
Set field to list of 64 bit integers value.
Definition ogr_feature.h:1466
const OGRFeatureDefn * GetDefnRef() const
Fetch feature definition.
Definition ogr_feature.h:1201
OGRFieldDefn * GetFieldDefnRef(int iField)
Fetch definition for this field.
Definition ogr_feature.h:1261
const double * GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
Fetch field value as a list of doubles.
Definition ogr_feature.h:1391
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:1461
void SetField(const char *pszFName, GIntBig nValue)
Set field to 64 bit integer value.
Definition ogr_feature.h:1446
void SetField(const char *pszFName, const char *pszValue)
Set field to string value.
Definition ogr_feature.h:1456
void SetField(const char *pszFName, int nValue)
Set field to integer value.
Definition ogr_feature.h:1441
const OGRFieldDefn * GetFieldDefnRef(int iField) const
Fetch definition for this field.
Definition ogr_feature.h:1256
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:1486
const OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField) const
Fetch definition for this geometry field.
Definition ogr_feature.h:1227
const char * GetNativeData() const
Returns the native data for the feature.
Definition ogr_feature.h:1539
int GetFieldIndex(const char *pszName) const
Fetch the field index given field name.
Definition ogr_feature.h:1266
int GetGeomFieldIndex(const char *pszName) const
Fetch the geometry field index given geometry field name.
Definition ogr_feature.h:1232
OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField)
Fetch definition for this geometry field.
Definition ogr_feature.h:1222
GIntBig GetFieldAsInteger64(const char *pszFName) const
Fetch field value as integer 64 bit.
Definition ogr_feature.h:1359
const int * GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
Fetch field value as a list of integers.
Definition ogr_feature.h:1380
void SetField(const char *pszFName, double dfValue)
Set field to double value.
Definition ogr_feature.h:1451
const char * GetFieldAsString(const char *pszFName) const
Fetch field value as a string.
Definition ogr_feature.h:1369
void SetField(const char *pszFName, const char *const *papszValues)
This method currently on has an effect of OFTStringList fields.
Definition ogr_feature.h:1476
const OGRField * GetRawFieldRef(int i) const
Fetch a pointer to the internal field value given the index.
Definition ogr_feature.h:1286
int GetFieldAsInteger(const char *pszFName) const
Fetch field value as integer.
Definition ogr_feature.h:1354
const char * GetNativeMediaType() const
Returns the native media type for the feature.
Definition ogr_feature.h:1544
void SetField(const char *pszFName, const OGRField *puValue)
Set field.
Definition ogr_feature.h:1481
GIntBig GetFID() const
Get feature identifier.
Definition ogr_feature.h:1494
OGRField * GetRawFieldRef(int i)
Fetch a pointer to the internal field value given the index.
Definition ogr_feature.h:1281
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:1471
virtual OGRStyleTable * GetStyleTable() const
Return style table.
Definition ogr_feature.h:1531
double GetFieldAsDouble(const char *pszFName) const
Fetch field value as a double.
Definition ogr_feature.h:1364
static OGRFeature * FromHandle(OGRFeatureH hFeature)
Convert a OGRFeatureH to a OGRFeature*.
Definition ogr_feature.h:1566
const GIntBig * GetFieldAsInteger64List(const char *pszFName, int *pnCount) const
Fetch field value as a list of 64 bit integers.
Definition ogr_feature.h:1385
Definition of an attribute of an OGRFeatureDefn.
Definition ogr_feature.h:69
const char * GetNameRef() const
Fetch name of this field.
Definition ogr_feature.h:108
void Unseal()
Unseal a OGRFieldDefn.
Definition ogrfielddefn.cpp:2314
int IsNullable() const
Return whether this field can receive null values.
Definition ogr_feature.h:186
void Seal()
Seal a OGRFieldDefn.
Definition ogrfielddefn.cpp:2295
int IsUnique() const
Return whether this field has a unique constraint.
Definition ogr_feature.h:193
OGRFieldSubType GetSubType() const
Fetch subtype of this field.
Definition ogr_feature.h:129
bool IsGenerated() const
Return whether the field is a generated field.
Definition ogr_feature.h:206
OGRJustification GetJustify() const
Get the justification for this field.
Definition ogr_feature.h:138
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition ogr_feature.h:181
int GetPrecision() const
Get the formatting precision for this field.
Definition ogr_feature.h:155
OGRFieldType GetType() const
Fetch type of this field.
Definition ogr_feature.h:120
int GetWidth() const
Get the formatting width for this field.
Definition ogr_feature.h:148
const std::string & GetComment() const
Return the (optional) comment for this field.
Definition ogr_feature.h:230
int GetTZFlag() const
Get the time zone flag.
Definition ogr_feature.h:162
void SetGenerated(bool bGeneratedIn)
SetGenerated set the field generated status.
Definition ogr_feature.h:216
void SetJustify(OGRJustification eJustifyIn)
Set the justification for this field.
Definition ogr_feature.h:143
const char * GetAlternativeNameRef() const
Fetch the alternative name (or "alias") for this field.
Definition ogr_feature.h:115
static OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
Convert a OGRFieldDefn* to a OGRFieldDefnH.
Definition ogr_feature.h:242
const std::string & GetDomainName() const
Return the name of the field domain for this field.
Definition ogr_feature.h:223
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition ogr_feature.h:176
static OGRFieldDefn * FromHandle(OGRFieldDefnH hFieldDefn)
Convert a OGRFieldDefnH to a OGRFieldDefn*.
Definition ogr_feature.h:250
Definition of a field domain.
Definition ogr_feature.h:1644
OGRFieldDomainMergePolicy GetMergePolicy() const
Get the merge policy.
Definition ogr_feature.h:1753
void SetMergePolicy(OGRFieldDomainMergePolicy policy)
Set the merge policy.
Definition ogr_feature.h:1762
static OGRFieldDomain * FromHandle(OGRFieldDomainH hFieldDomain)
Convert a OGRFieldDomainH to a OGRFieldDomain*.
Definition ogr_feature.h:1726
virtual OGRFieldDomain * Clone() const =0
Clone.
OGRFieldSubType GetFieldSubType() const
Get the field subtype.
Definition ogr_feature.h:1714
const std::string & GetName() const
Get the name of the field domain.
Definition ogr_feature.h:1677
virtual ~OGRFieldDomain()=0
Destructor.
const std::string & GetDescription() const
Get the description of the field domain.
Definition ogr_feature.h:1687
OGRFieldDomainSplitPolicy GetSplitPolicy() const
Get the split policy.
Definition ogr_feature.h:1735
static OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)
Convert a OGRFieldDomain* to a OGRFieldDomainH.
Definition ogr_feature.h:1720
OGRFieldType GetFieldType() const
Get the field type.
Definition ogr_feature.h:1705
OGRFieldDomainType GetDomainType() const
Get the type of the field domain.
Definition ogr_feature.h:1696
void SetSplitPolicy(OGRFieldDomainSplitPolicy policy)
Set the split policy.
Definition ogr_feature.h:1744
Definition of a geometry field of an OGRFeatureDefn.
Definition ogr_feature.h:335
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition ogr_feature.h:384
void Seal()
Seal a OGRGeomFieldDefn.
Definition ogrgeomfielddefn.cpp:884
void Unseal()
Unseal a OGRGeomFieldDefn.
Definition ogrgeomfielddefn.cpp:903
static OGRGeomFieldDefn * FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
Convert a OGRGeomFieldDefnH to a OGRGeomFieldDefn*.
Definition ogr_feature.h:416
int IsNullable() const
Return whether this geometry field can receive null values.
Definition ogr_feature.h:389
OGRwkbGeometryType GetType() const
Fetch geometry type of this field.
Definition ogr_feature.h:369
const OGRGeomCoordinatePrecision & GetCoordinatePrecision() const
Return the coordinate precision associated to this geometry field.
Definition ogr_feature.h:396
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition ogr_feature.h:379
static OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
Convert a OGRGeomFieldDefn* to a OGRGeomFieldDefnH.
Definition ogr_feature.h:408
const char * GetNameRef() const
Fetch name of this field.
Definition ogr_feature.h:364
Abstract base class for all geometry classes.
Definition ogr_geometry.h:360
Definition of a field domain for field content validated by a glob.
Definition ogr_feature.h:1919
OGRGlobFieldDomain * Clone() const override
Clone.
Definition ogr_feature.h:1942
const std::string & GetGlob() const
Get the glob expression.
Definition ogr_feature.h:1955
This class represents a layer of simple features, with access methods.
Definition ogrsf_frmts.h:61
Definition of a numeric field domain with a range of validity for values.
Definition ogr_feature.h:1821
OGRRangeFieldDomain * Clone() const override
Clone.
Definition ogr_feature.h:1865
const OGRField & GetMax(bool &bIsInclusiveOut) const
Get the maximum value.
Definition ogr_feature.h:1907
const OGRField & GetMin(bool &bIsInclusiveOut) const
Get the minimum value.
Definition ogr_feature.h:1888
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:152
This class represents a style table.
Definition ogr_featurestyle.h:69
#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:962
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1111
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition cpl_port.h:896
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:175
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:205
Forward definitions of GDAL/OGR/OSR C handle types.
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition gdal_fwd.h:119
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition gdal_fwd.h:121
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition gdal_fwd.h:138
struct OGRFieldDomainHS * OGRFieldDomainH
Opaque type for a field domain definition (OGRFieldDomain)
Definition gdal_fwd.h:128
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition gdal_fwd.h:125
#define OGRUnsetMarker
Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for a unset field.
Definition ogr_core.h:863
#define OGR_TZFLAG_UNKNOWN
Time zone flag indicating unknown timezone.
Definition ogr_core.h:877
int OGRBoolean
Type for a OGR boolean.
Definition ogr_core.h:387
OGRFieldSubType
List of field subtypes.
Definition ogr_core.h:816
OGRFieldDomainMergePolicy
Merge policy for field domains.
Definition ogr_core.h:1271
@ OFDMP_DEFAULT_VALUE
Default value.
Definition ogr_core.h:1273
OGRFieldDomainType
Type of field domain.
Definition ogr_core.h:1236
OGRJustification
Display justification for field values.
Definition ogr_core.h:841
OGRFieldType
List of feature field types.
Definition ogr_core.h:788
#define OGRNullMarker
Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for a null field.
Definition ogr_core.h:871
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:406
@ wkbUnknown
unknown type, non-standard
Definition ogr_core.h:407
int OGRErr
Type for a OGR error.
Definition ogr_core.h:370
OGRFieldDomainSplitPolicy
Split policy for field domains.
Definition ogr_core.h:1253
@ OFDSP_DEFAULT_VALUE
Default value.
Definition ogr_core.h:1255
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition ogr_feature.h:1587
Simple feature style classes.
Geometry coordinate precision class.
Simple feature geometry classes.
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition ogrsf_frmts.h:467
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition ogrsf_frmts.h:475
Associates a code and a value.
Definition ogr_core.h:1223
Geometry coordinate precision.
Definition ogr_geomcoordinateprecision.h:40
OGRFeature field attribute value union.
Definition ogr_core.h:905