GDAL

ogr_feature.h
Go to the documentation of this file.
1/******************************************************************************
2 * $Id$
3 *
4 * Project: OpenGIS Simple Features Reference Implementation
5 * Purpose: Class for representing a whole feature, and layer schemas.
6 * Author: Frank Warmerdam, warmerdam@pobox.com
7 *
8 ******************************************************************************
9 * Copyright (c) 1999, Les Technologies SoftMap Inc.
10 * Copyright (c) 2008-2013, Even Rouault <even dot rouault at spatialys.com>
11 *
12 * SPDX-License-Identifier: MIT
13 ****************************************************************************/
14
15#ifndef OGR_FEATURE_H_INCLUDED
16#define OGR_FEATURE_H_INCLUDED
17
18#include "cpl_atomic_ops.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#ifndef DEFINE_OGRFeatureH
38#define DEFINE_OGRFeatureH
40#ifdef DEBUG
41 typedef struct OGRFieldDefnHS *OGRFieldDefnH;
42 typedef struct OGRFeatureDefnHS *OGRFeatureDefnH;
43 typedef struct OGRFeatureHS *OGRFeatureH;
44 typedef struct OGRStyleTableHS *OGRStyleTableH;
45#else
47 typedef void *OGRFieldDefnH;
49 typedef void *OGRFeatureDefnH;
51 typedef void *OGRFeatureH;
53 typedef void *OGRStyleTableH;
54#endif
56 typedef struct OGRGeomFieldDefnHS *OGRGeomFieldDefnH;
57
59 typedef struct OGRFieldDomainHS *OGRFieldDomainH;
60#endif /* DEFINE_OGRFeatureH */
61
62 class OGRStyleTable;
63
64/************************************************************************/
65/* OGRFieldDefn */
66/************************************************************************/
67
94 class CPL_DLL OGRFieldDefn
95{
96 private:
97 char *pszName;
98 char *pszAlternativeName;
99 OGRFieldType eType;
100 OGRJustification eJustify;
101 int nWidth; // Zero is variable.
102 int nPrecision;
103 char *pszDefault;
104
105 int bIgnore;
106 OGRFieldSubType eSubType;
107
108 int bNullable;
109 int bUnique;
110
111 std::string m_osDomainName{}; // field domain name. Might be empty
112
113 std::string m_osComment{}; // field comment. Might be empty
114
115 int m_nTZFlag = OGR_TZFLAG_UNKNOWN;
116 bool m_bSealed = false;
117
118 public:
119 OGRFieldDefn(const char *, OGRFieldType);
120 explicit OGRFieldDefn(const OGRFieldDefn *);
121 ~OGRFieldDefn();
122
123 void SetName(const char *);
124
125 const char *GetNameRef() const
126 {
127 return pszName;
128 }
129
130 void SetAlternativeName(const char *);
131
132 const char *GetAlternativeNameRef() const
133 {
134 return pszAlternativeName;
135 }
136
137 OGRFieldType GetType() const
138 {
139 return eType;
140 }
141
142 void SetType(OGRFieldType eTypeIn);
143 static const char *GetFieldTypeName(OGRFieldType);
144
145 OGRFieldSubType GetSubType() const
146 {
147 return eSubType;
148 }
149
150 void SetSubType(OGRFieldSubType eSubTypeIn);
151 static const char *GetFieldSubTypeName(OGRFieldSubType);
152
153 OGRJustification GetJustify() const
154 {
155 return eJustify;
156 }
157
158 void SetJustify(OGRJustification eJustifyIn)
159 {
160 eJustify = eJustifyIn;
161 }
162
163 int GetWidth() const
164 {
165 return nWidth;
166 }
167
168 void SetWidth(int nWidthIn);
169
170 int GetPrecision() const
171 {
172 return nPrecision;
173 }
174
175 void SetPrecision(int nPrecisionIn);
176
177 int GetTZFlag() const
178 {
179 return m_nTZFlag;
180 }
181
182 void SetTZFlag(int nTZFlag);
183
184 void Set(const char *, OGRFieldType, int = 0, int = 0,
185 OGRJustification = OJUndefined);
186
187 void SetDefault(const char *);
188 const char *GetDefault() const;
189 int IsDefaultDriverSpecific() const;
190
191 int IsIgnored() const
192 {
193 return bIgnore;
194 }
195
196 void SetIgnored(int bIgnoreIn)
197 {
198 bIgnore = bIgnoreIn;
199 }
200
201 int IsNullable() const
202 {
203 return bNullable;
204 }
205
206 void SetNullable(int bNullableIn);
207
208 int IsUnique() const
209 {
210 return bUnique;
211 }
212
213 void SetUnique(int bUniqueIn);
214
215 const std::string &GetDomainName() const
216 {
217 return m_osDomainName;
218 }
219
220 void SetDomainName(const std::string &osDomainName);
221
222 const std::string &GetComment() const
223 {
224 return m_osComment;
225 }
226
227 void SetComment(const std::string &osComment);
228
229 int IsSame(const OGRFieldDefn *) const;
230
234 static inline OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
235 {
236 return reinterpret_cast<OGRFieldDefnH>(poFieldDefn);
237 }
238
242 static inline OGRFieldDefn *FromHandle(OGRFieldDefnH hFieldDefn)
243 {
244 return reinterpret_cast<OGRFieldDefn *>(hFieldDefn);
245 }
246
247 void Seal();
248
249 void Unseal();
250
252 struct CPL_DLL TemporaryUnsealer
253 {
254 private:
255 OGRFieldDefn *m_poFieldDefn = nullptr;
256 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
257 public:
258 explicit TemporaryUnsealer(OGRFieldDefn *poFieldDefn)
259 : m_poFieldDefn(poFieldDefn)
260 {
261 m_poFieldDefn->Unseal();
262 }
263
264 TemporaryUnsealer(TemporaryUnsealer &&) = default;
265 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
266
267 ~TemporaryUnsealer()
268 {
269 m_poFieldDefn->Seal();
270 }
271
272 OGRFieldDefn *operator->()
273 {
274 return m_poFieldDefn;
275 }
276 };
277
280 TemporaryUnsealer GetTemporaryUnsealer();
281
282 private:
283 CPL_DISALLOW_COPY_ASSIGN(OGRFieldDefn)
284};
285
286#ifdef GDAL_COMPILATION
298 inline OGRFieldDefn::TemporaryUnsealer whileUnsealing(OGRFieldDefn *object)
299{
300 return object->GetTemporaryUnsealer();
301}
302#endif
303
304/************************************************************************/
305/* OGRGeomFieldDefn */
306/************************************************************************/
307
329 class CPL_DLL OGRGeomFieldDefn
330{
331 protected:
333 char *pszName = nullptr;
334 OGRwkbGeometryType eGeomType =
335 wkbUnknown; /* all values possible except wkbNone */
336 mutable const OGRSpatialReference *poSRS = nullptr;
337
338 int bIgnore = false;
339 mutable int bNullable = true;
340 bool m_bSealed = false;
341 OGRGeomCoordinatePrecision m_oCoordPrecision{};
342
343 void Initialize(const char *, OGRwkbGeometryType);
345
346 public:
347 OGRGeomFieldDefn(const char *pszNameIn, OGRwkbGeometryType eGeomTypeIn);
348 explicit OGRGeomFieldDefn(const OGRGeomFieldDefn *);
349 virtual ~OGRGeomFieldDefn();
350
351 void SetName(const char *);
352
353 const char *GetNameRef() const
354 {
355 return pszName;
356 }
357
358 OGRwkbGeometryType GetType() const
359 {
360 return eGeomType;
361 }
362
363 void SetType(OGRwkbGeometryType eTypeIn);
364
365 virtual const OGRSpatialReference *GetSpatialRef() const;
366 void SetSpatialRef(const OGRSpatialReference *poSRSIn);
367
368 int IsIgnored() const
369 {
370 return bIgnore;
371 }
372
373 void SetIgnored(int bIgnoreIn)
374 {
375 bIgnore = bIgnoreIn;
376 }
377
378 int IsNullable() const
379 {
380 return bNullable;
381 }
382
383 void SetNullable(int bNullableIn);
384
385 const OGRGeomCoordinatePrecision &GetCoordinatePrecision() const
386 {
387 return m_oCoordPrecision;
388 }
389
390 void SetCoordinatePrecision(const OGRGeomCoordinatePrecision &prec);
391
392 int IsSame(const OGRGeomFieldDefn *) const;
393
397 static inline OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
398 {
399 return reinterpret_cast<OGRGeomFieldDefnH>(poGeomFieldDefn);
400 }
401
405 static inline OGRGeomFieldDefn *FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
406 {
407 return reinterpret_cast<OGRGeomFieldDefn *>(hGeomFieldDefn);
408 }
409
410 void Seal();
411
412 void Unseal();
413
415 struct CPL_DLL TemporaryUnsealer
416 {
417 private:
418 OGRGeomFieldDefn *m_poFieldDefn = nullptr;
419 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
420 public:
421 explicit TemporaryUnsealer(OGRGeomFieldDefn *poFieldDefn)
422 : m_poFieldDefn(poFieldDefn)
423 {
424 m_poFieldDefn->Unseal();
425 }
426
427 TemporaryUnsealer(TemporaryUnsealer &&) = default;
428 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
429
430 ~TemporaryUnsealer()
431 {
432 m_poFieldDefn->Seal();
433 }
434
435 OGRGeomFieldDefn *operator->()
436 {
437 return m_poFieldDefn;
438 }
439 };
440
443 TemporaryUnsealer GetTemporaryUnsealer();
444
445 private:
446 CPL_DISALLOW_COPY_ASSIGN(OGRGeomFieldDefn)
447};
448
449#ifdef GDAL_COMPILATION
461 inline OGRGeomFieldDefn::TemporaryUnsealer
462whileUnsealing(OGRGeomFieldDefn *object)
463{
464 return object->GetTemporaryUnsealer();
465}
466#endif
467
468/************************************************************************/
469/* OGRFeatureDefn */
470/************************************************************************/
471
500 class CPL_DLL OGRFeatureDefn
501{
502 protected:
504 volatile int nRefCount = 0;
505
506 mutable std::vector<std::unique_ptr<OGRFieldDefn>> apoFieldDefn{};
507 mutable std::vector<std::unique_ptr<OGRGeomFieldDefn>> apoGeomFieldDefn{};
508
509 char *pszFeatureClassName = nullptr;
510
511 bool bIgnoreStyle = false;
512
513 friend class TemporaryUnsealer;
514 bool m_bSealed = false;
515 int m_nTemporaryUnsealCount = 0;
517
518 public:
519 explicit OGRFeatureDefn(const char *pszName = nullptr);
520 virtual ~OGRFeatureDefn();
521
522 void SetName(const char *pszName);
523 virtual const char *GetName() const;
524
525 virtual int GetFieldCount() const;
526 virtual OGRFieldDefn *GetFieldDefn(int i);
527 virtual const OGRFieldDefn *GetFieldDefn(int i) const;
528 virtual int GetFieldIndex(const char *) const;
529 int GetFieldIndexCaseSensitive(const char *) const;
530
532
536 struct CPL_DLL Fields
537 {
538 private:
539 OGRFeatureDefn *m_poFDefn;
540
541 public:
542 inline explicit Fields(OGRFeatureDefn *poFDefn) : m_poFDefn(poFDefn)
543 {
544 }
545
546 struct CPL_DLL ConstIterator
547 {
548 private:
549 OGRFeatureDefn *m_poFDefn;
550 int m_nIdx;
551
552 public:
553 inline ConstIterator(OGRFeatureDefn *poFDefn, int nIdx)
554 : m_poFDefn(poFDefn), m_nIdx(nIdx)
555 {
556 }
557
558 inline const OGRFieldDefn *operator*() const
559 {
560 return m_poFDefn->GetFieldDefn(m_nIdx);
561 }
562
563 inline ConstIterator &operator++()
564 {
565 m_nIdx++;
566 return *this;
567 }
568
569 inline bool operator!=(const ConstIterator &it) const
570 {
571 return m_nIdx != it.m_nIdx;
572 }
573 };
574
575 inline ConstIterator begin()
576 {
577 return ConstIterator(m_poFDefn, 0);
578 }
579
580 inline ConstIterator end()
581 {
582 return ConstIterator(m_poFDefn, m_poFDefn->GetFieldCount());
583 }
584
585 inline size_t size() const
586 {
587 return static_cast<std::size_t>(m_poFDefn->GetFieldCount());
588 }
589
590 inline OGRFieldDefn *operator[](size_t i)
591 {
592 return m_poFDefn->GetFieldDefn(static_cast<int>(i));
593 }
594
595 inline const OGRFieldDefn *operator[](size_t i) const
596 {
597 return m_poFDefn->GetFieldDefn(static_cast<int>(i));
598 }
599 };
600
602
613 inline Fields GetFields()
614 {
615 return Fields(this);
616 }
617
619 // That method should only be called if there's a guarantee that
620 // GetFieldCount() has been called before
621 int GetFieldCountUnsafe() const
622 {
623 return static_cast<int>(apoFieldDefn.size());
624 }
625
626 // Those methods don't check i is n range.
627 OGRFieldDefn *GetFieldDefnUnsafe(int i)
628 {
629 if (apoFieldDefn.empty())
630 GetFieldDefn(i);
631 return apoFieldDefn[static_cast<std::size_t>(i)].get();
632 }
633
634 const OGRFieldDefn *GetFieldDefnUnsafe(int i) const
635 {
636 if (apoFieldDefn.empty())
637 GetFieldDefn(i);
638 return apoFieldDefn[static_cast<std::size_t>(i)].get();
639 }
640
642
643 virtual void AddFieldDefn(const OGRFieldDefn *);
644 virtual OGRErr DeleteFieldDefn(int iField);
645 virtual OGRErr ReorderFieldDefns(const int *panMap);
646
647 virtual int GetGeomFieldCount() const;
648 virtual OGRGeomFieldDefn *GetGeomFieldDefn(int i);
649 virtual const OGRGeomFieldDefn *GetGeomFieldDefn(int i) const;
650 virtual int GetGeomFieldIndex(const char *) const;
651
653
657 struct CPL_DLL GeomFields
658 {
659 private:
660 OGRFeatureDefn *m_poFDefn;
661
662 public:
663 inline explicit GeomFields(OGRFeatureDefn *poFDefn) : m_poFDefn(poFDefn)
664 {
665 }
666
667 struct CPL_DLL ConstIterator
668 {
669 private:
670 OGRFeatureDefn *m_poFDefn;
671 int m_nIdx;
672
673 public:
674 inline ConstIterator(OGRFeatureDefn *poFDefn, int nIdx)
675 : m_poFDefn(poFDefn), m_nIdx(nIdx)
676 {
677 }
678
679 inline const OGRGeomFieldDefn *operator*() const
680 {
681 return m_poFDefn->GetGeomFieldDefn(m_nIdx);
682 }
683
684 inline ConstIterator &operator++()
685 {
686 m_nIdx++;
687 return *this;
688 }
689
690 inline bool operator!=(const ConstIterator &it) const
691 {
692 return m_nIdx != it.m_nIdx;
693 }
694 };
695
696 inline ConstIterator begin()
697 {
698 return ConstIterator(m_poFDefn, 0);
699 }
700
701 inline ConstIterator end()
702 {
703 return ConstIterator(m_poFDefn, m_poFDefn->GetGeomFieldCount());
704 }
705
706 inline size_t size() const
707 {
708 return static_cast<std::size_t>(m_poFDefn->GetGeomFieldCount());
709 }
710
711 inline OGRGeomFieldDefn *operator[](size_t i)
712 {
713 return m_poFDefn->GetGeomFieldDefn(static_cast<int>(i));
714 }
715
716 inline const OGRGeomFieldDefn *operator[](size_t i) const
717 {
718 return m_poFDefn->GetGeomFieldDefn(static_cast<int>(i));
719 }
720 };
721
723
734 inline GeomFields GetGeomFields()
735 {
736 return GeomFields(this);
737 }
738
739 virtual void AddGeomFieldDefn(const OGRGeomFieldDefn *);
740 virtual void AddGeomFieldDefn(std::unique_ptr<OGRGeomFieldDefn> &&);
741 virtual OGRErr DeleteGeomFieldDefn(int iGeomField);
742
743 virtual OGRwkbGeometryType GetGeomType() const;
744 virtual void SetGeomType(OGRwkbGeometryType);
745
746 virtual OGRFeatureDefn *Clone() const;
747
748 int Reference()
749 {
750 return CPLAtomicInc(&nRefCount);
751 }
752
753 int Dereference()
754 {
755 return CPLAtomicDec(&nRefCount);
756 }
757
758 int GetReferenceCount() const
759 {
760 return nRefCount;
761 }
762
763 void Release();
764
765 virtual int IsGeometryIgnored() const;
766 virtual void SetGeometryIgnored(int bIgnore);
767
768 virtual bool IsStyleIgnored() const
769 {
770 return bIgnoreStyle;
771 }
772
773 virtual void SetStyleIgnored(bool bIgnore)
774 {
775 bIgnoreStyle = bIgnore;
776 }
777
778 virtual int IsSame(const OGRFeatureDefn *poOtherFeatureDefn) const;
779
781 void ReserveSpaceForFields(int nFieldCountIn);
783
784 std::vector<int> ComputeMapForSetFrom(const OGRFeatureDefn *poSrcFDefn,
785 bool bForgiving = true) const;
786
787 static OGRFeatureDefn *CreateFeatureDefn(const char *pszName = nullptr);
788 static void DestroyFeatureDefn(OGRFeatureDefn *);
789
793 static inline OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
794 {
795 return reinterpret_cast<OGRFeatureDefnH>(poFeatureDefn);
796 }
797
801 static inline OGRFeatureDefn *FromHandle(OGRFeatureDefnH hFeatureDefn)
802 {
803 return reinterpret_cast<OGRFeatureDefn *>(hFeatureDefn);
804 }
805
806 void Seal(bool bSealFields);
807
808 void Unseal(bool bUnsealFields);
809
811 struct CPL_DLL TemporaryUnsealer
812 {
813 private:
814 OGRFeatureDefn *m_poFeatureDefn = nullptr;
815 bool m_bSealFields = false;
816 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
817 public:
818 explicit TemporaryUnsealer(OGRFeatureDefn *poFeatureDefn,
819 bool bSealFields);
820
821 TemporaryUnsealer(TemporaryUnsealer &&) = default;
822 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
823
824 ~TemporaryUnsealer();
825
826 OGRFeatureDefn *operator->()
827 {
828 return m_poFeatureDefn;
829 }
830 };
831
834 TemporaryUnsealer GetTemporaryUnsealer(bool bSealFields = true);
835
836 private:
837 CPL_DISALLOW_COPY_ASSIGN(OGRFeatureDefn)
838};
839
840#ifdef GDAL_COMPILATION
861 inline OGRFeatureDefn::TemporaryUnsealer whileUnsealing(OGRFeatureDefn *object,
862 bool bSealFields = true)
863{
864 return object->GetTemporaryUnsealer(bSealFields);
865}
866#endif
867
868/************************************************************************/
869/* OGRFeature */
870/************************************************************************/
871
876 class CPL_DLL OGRFeature
877{
878 private:
879 GIntBig nFID;
880 OGRFeatureDefn *poDefn;
881 OGRGeometry **papoGeometries;
882 OGRField *pauFields;
883 char *m_pszNativeData;
884 char *m_pszNativeMediaType;
885
886 bool SetFieldInternal(int i, const OGRField *puValue);
887
888 protected:
890 mutable char *m_pszStyleString;
891 mutable OGRStyleTable *m_poStyleTable;
892 mutable char *m_pszTmpFieldValue;
894
895 bool CopySelfTo(OGRFeature *poNew) const;
896
897 public:
898 explicit OGRFeature(OGRFeatureDefn *);
899 virtual ~OGRFeature();
900
902 class CPL_DLL FieldValue
903 {
904 friend class OGRFeature;
905 struct Private;
906 std::unique_ptr<Private> m_poPrivate;
907
908 FieldValue(OGRFeature *poFeature, int iFieldIndex);
909 FieldValue(const OGRFeature *poFeature, int iFieldIndex);
910 FieldValue(const FieldValue &oOther) = delete;
911 FieldValue &Assign(const FieldValue &oOther);
912
913 public:
915 ~FieldValue();
916
917 FieldValue &operator=(FieldValue &&oOther);
919
921 FieldValue &operator=(const FieldValue &oOther);
923 FieldValue &operator=(int nVal);
925 FieldValue &operator=(GIntBig nVal);
927 FieldValue &operator=(double dfVal);
929 FieldValue &operator=(const char *pszVal);
931 FieldValue &operator=(const std::string &osVal);
933 FieldValue &operator=(const std::vector<int> &oArray);
935 FieldValue &operator=(const std::vector<GIntBig> &oArray);
937 FieldValue &operator=(const std::vector<double> &oArray);
939 FieldValue &operator=(const std::vector<std::string> &oArray);
941 FieldValue &operator=(CSLConstList papszValues);
943 void SetNull();
945 void clear();
946
948 void Unset()
949 {
950 clear();
951 }
952
954 void SetDateTime(int nYear, int nMonth, int nDay, int nHour = 0,
955 int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0);
956
958 int GetIndex() const;
960 const OGRFieldDefn *GetDefn() const;
961
963 const char *GetName() const
964 {
965 return GetDefn()->GetNameRef();
966 }
967
969 OGRFieldType GetType() const
970 {
971 return GetDefn()->GetType();
972 }
973
975 OGRFieldSubType GetSubType() const
976 {
977 return GetDefn()->GetSubType();
978 }
979
981 // cppcheck-suppress functionStatic
982 bool empty() const
983 {
984 return IsUnset();
985 }
986
988 // cppcheck-suppress functionStatic
989 bool IsUnset() const;
990
992 // cppcheck-suppress functionStatic
993 bool IsNull() const;
994
996 const OGRField *GetRawValue() const;
997
1001 // cppcheck-suppress functionStatic
1002 int GetInteger() const
1003 {
1004 return GetRawValue()->Integer;
1005 }
1006
1010 // cppcheck-suppress functionStatic
1011 GIntBig GetInteger64() const
1012 {
1013 return GetRawValue()->Integer64;
1014 }
1015
1019 // cppcheck-suppress functionStatic
1020 double GetDouble() const
1021 {
1022 return GetRawValue()->Real;
1023 }
1024
1028 // cppcheck-suppress functionStatic
1029 const char *GetString() const
1030 {
1031 return GetRawValue()->String;
1032 }
1033
1035 bool GetDateTime(int *pnYear, int *pnMonth, int *pnDay, int *pnHour,
1036 int *pnMinute, float *pfSecond, int *pnTZFlag) const;
1037
1039 operator int() const
1040 {
1041 return GetAsInteger();
1042 }
1043
1046 operator GIntBig() const
1047 {
1048 return GetAsInteger64();
1049 }
1050
1052 operator double() const
1053 {
1054 return GetAsDouble();
1055 }
1056
1058 operator const char *() const
1059 {
1060 return GetAsString();
1061 }
1062
1064 operator const std::vector<int> &() const
1065 {
1066 return GetAsIntegerList();
1067 }
1068
1071 operator const std::vector<GIntBig> &() const
1072 {
1073 return GetAsInteger64List();
1074 }
1075
1077 operator const std::vector<double> &() const
1078 {
1079 return GetAsDoubleList();
1080 }
1081
1083 operator const std::vector<std::string> &() const
1084 {
1085 return GetAsStringList();
1086 }
1087
1089 operator CSLConstList() const;
1090
1092 int GetAsInteger() const;
1095 GIntBig GetAsInteger64() const;
1097 double GetAsDouble() const;
1099 const char *GetAsString() const;
1101 const std::vector<int> &GetAsIntegerList() const;
1104 const std::vector<GIntBig> &GetAsInteger64List() const;
1106 const std::vector<double> &GetAsDoubleList() const;
1108 const std::vector<std::string> &GetAsStringList() const;
1109 };
1110
1112 class CPL_DLL ConstFieldIterator
1113 {
1114 friend class OGRFeature;
1115 struct Private;
1116 std::unique_ptr<Private> m_poPrivate;
1117
1118 ConstFieldIterator(const OGRFeature *poSelf, int nPos);
1119
1120 public:
1122 ConstFieldIterator(
1123 ConstFieldIterator &&oOther) noexcept; // declared but not defined.
1124 // Needed for gcc 5.4 at least
1125 ~ConstFieldIterator();
1126 const FieldValue &operator*() const;
1127 ConstFieldIterator &operator++();
1128 bool operator!=(const ConstFieldIterator &it) const;
1130 };
1131
1149 ConstFieldIterator begin() const;
1151 ConstFieldIterator end() const;
1152
1153 const FieldValue operator[](int iField) const;
1154 FieldValue operator[](int iField);
1155
1158 class FieldNotFoundException : public std::exception
1159 {
1160 };
1161
1162 const FieldValue operator[](const char *pszFieldName) const;
1163 FieldValue operator[](const char *pszFieldName);
1164
1165 OGRFeatureDefn *GetDefnRef()
1166 {
1167 return poDefn;
1168 }
1169
1170 const OGRFeatureDefn *GetDefnRef() const
1171 {
1172 return poDefn;
1173 }
1174
1176 void SetFDefnUnsafe(OGRFeatureDefn *poNewFDefn);
1178
1179 OGRErr SetGeometryDirectly(OGRGeometry *);
1180 OGRErr SetGeometry(const OGRGeometry *);
1181 OGRGeometry *GetGeometryRef();
1182 const OGRGeometry *GetGeometryRef() const;
1183 OGRGeometry *StealGeometry() CPL_WARN_UNUSED_RESULT;
1184
1185 int GetGeomFieldCount() const
1186 {
1187 return poDefn->GetGeomFieldCount();
1188 }
1189
1190 OGRGeomFieldDefn *GetGeomFieldDefnRef(int iField)
1191 {
1192 return poDefn->GetGeomFieldDefn(iField);
1193 }
1194
1195 const OGRGeomFieldDefn *GetGeomFieldDefnRef(int iField) const
1196 {
1197 return poDefn->GetGeomFieldDefn(iField);
1198 }
1199
1200 int GetGeomFieldIndex(const char *pszName) const
1201 {
1202 return poDefn->GetGeomFieldIndex(pszName);
1203 }
1204
1205 OGRGeometry *GetGeomFieldRef(int iField);
1206 const OGRGeometry *GetGeomFieldRef(int iField) const;
1207 OGRGeometry *StealGeometry(int iField);
1208 OGRGeometry *GetGeomFieldRef(const char *pszFName);
1209 const OGRGeometry *GetGeomFieldRef(const char *pszFName) const;
1210 OGRErr SetGeomFieldDirectly(int iField, OGRGeometry *);
1211 OGRErr SetGeomField(int iField, const OGRGeometry *);
1212
1213 void Reset();
1214
1215 OGRFeature *Clone() const CPL_WARN_UNUSED_RESULT;
1216 virtual OGRBoolean Equal(const OGRFeature *poFeature) const;
1217
1218 int GetFieldCount() const
1219 {
1220 return poDefn->GetFieldCount();
1221 }
1222
1223 const OGRFieldDefn *GetFieldDefnRef(int iField) const
1224 {
1225 return poDefn->GetFieldDefn(iField);
1226 }
1227
1228 OGRFieldDefn *GetFieldDefnRef(int iField)
1229 {
1230 return poDefn->GetFieldDefn(iField);
1231 }
1232
1233 int GetFieldIndex(const char *pszName) const
1234 {
1235 return poDefn->GetFieldIndex(pszName);
1236 }
1237
1238 int IsFieldSet(int iField) const;
1239
1240 void UnsetField(int iField);
1241
1242 bool IsFieldNull(int iField) const;
1243
1244 void SetFieldNull(int iField);
1245
1246 bool IsFieldSetAndNotNull(int iField) const;
1247
1248 OGRField *GetRawFieldRef(int i)
1249 {
1250 return pauFields + i;
1251 }
1252
1253 const OGRField *GetRawFieldRef(int i) const
1254 {
1255 return pauFields + i;
1256 }
1257
1258 int GetFieldAsInteger(int i) const;
1259 GIntBig GetFieldAsInteger64(int i) const;
1260 double GetFieldAsDouble(int i) const;
1261 const char *GetFieldAsString(int i) const;
1262 const char *GetFieldAsISO8601DateTime(int i,
1263 CSLConstList papszOptions) const;
1264 const int *GetFieldAsIntegerList(int i, int *pnCount) const;
1265 const GIntBig *GetFieldAsInteger64List(int i, int *pnCount) const;
1266 const double *GetFieldAsDoubleList(int i, int *pnCount) const;
1267 char **GetFieldAsStringList(int i) const;
1268 GByte *GetFieldAsBinary(int i, int *pnCount) const;
1269 int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay,
1270 int *pnHour, int *pnMinute, int *pnSecond,
1271 int *pnTZFlag) const;
1272 int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay,
1273 int *pnHour, int *pnMinute, float *pfSecond,
1274 int *pnTZFlag) const;
1275 char *GetFieldAsSerializedJSon(int i) const;
1276
1278 bool IsFieldSetUnsafe(int i) const
1279 {
1280 return !(pauFields[i].Set.nMarker1 == OGRUnsetMarker &&
1281 pauFields[i].Set.nMarker2 == OGRUnsetMarker &&
1282 pauFields[i].Set.nMarker3 == OGRUnsetMarker);
1283 }
1284
1285 bool IsFieldNullUnsafe(int i) const
1286 {
1287 return (pauFields[i].Set.nMarker1 == OGRNullMarker &&
1288 pauFields[i].Set.nMarker2 == OGRNullMarker &&
1289 pauFields[i].Set.nMarker3 == OGRNullMarker);
1290 }
1291
1292 bool IsFieldSetAndNotNullUnsafe(int i) const
1293 {
1294 return IsFieldSetUnsafe(i) && !IsFieldNullUnsafe(i);
1295 }
1296
1297 // Those methods should only be called on a field that is of the type
1298 // consistent with the value, and that is set.
1299 int GetFieldAsIntegerUnsafe(int i) const
1300 {
1301 return pauFields[i].Integer;
1302 }
1303
1304 GIntBig GetFieldAsInteger64Unsafe(int i) const
1305 {
1306 return pauFields[i].Integer64;
1307 }
1308
1309 double GetFieldAsDoubleUnsafe(int i) const
1310 {
1311 return pauFields[i].Real;
1312 }
1313
1314 const char *GetFieldAsStringUnsafe(int i) const
1315 {
1316 return pauFields[i].String;
1317 }
1318
1320
1321 int GetFieldAsInteger(const char *pszFName) const
1322 {
1323 return GetFieldAsInteger(GetFieldIndex(pszFName));
1324 }
1325
1326 GIntBig GetFieldAsInteger64(const char *pszFName) const
1327 {
1328 return GetFieldAsInteger64(GetFieldIndex(pszFName));
1329 }
1330
1331 double GetFieldAsDouble(const char *pszFName) const
1332 {
1333 return GetFieldAsDouble(GetFieldIndex(pszFName));
1334 }
1335
1336 const char *GetFieldAsString(const char *pszFName) const
1337 {
1338 return GetFieldAsString(GetFieldIndex(pszFName));
1339 }
1340
1341 const char *GetFieldAsISO8601DateTime(const char *pszFName,
1342 CSLConstList papszOptions) const
1343 {
1344 return GetFieldAsISO8601DateTime(GetFieldIndex(pszFName), papszOptions);
1345 }
1346
1347 const int *GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
1348 {
1349 return GetFieldAsIntegerList(GetFieldIndex(pszFName), pnCount);
1350 }
1351
1352 const GIntBig *GetFieldAsInteger64List(const char *pszFName,
1353 int *pnCount) const
1354 {
1355 return GetFieldAsInteger64List(GetFieldIndex(pszFName), pnCount);
1356 }
1357
1358 const double *GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
1359 {
1360 return GetFieldAsDoubleList(GetFieldIndex(pszFName), pnCount);
1361 }
1362
1363 char **GetFieldAsStringList(const char *pszFName) const
1364 {
1365 return GetFieldAsStringList(GetFieldIndex(pszFName));
1366 }
1367
1368 void SetField(int i, int nValue);
1369 void SetField(int i, GIntBig nValue);
1370 void SetField(int i, double dfValue);
1371 void SetField(int i, const char *pszValue);
1372 void SetField(int i, int nCount, const int *panValues);
1373 void SetField(int i, int nCount, const GIntBig *panValues);
1374 void SetField(int i, int nCount, const double *padfValues);
1375 void SetField(int i, const char *const *papszValues);
1376 void SetField(int i, const OGRField *puValue);
1377 void SetField(int i, int nCount, const void *pabyBinary);
1378 void SetField(int i, int nYear, int nMonth, int nDay, int nHour = 0,
1379 int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0);
1380
1382 // Those methods should only be called on a field that is of the type
1383 // consistent with the value, and in a unset state.
1384 void SetFieldSameTypeUnsafe(int i, int nValue)
1385 {
1386 pauFields[i].Integer = nValue;
1387 pauFields[i].Set.nMarker2 = 0;
1388 pauFields[i].Set.nMarker3 = 0;
1389 }
1390
1391 void SetFieldSameTypeUnsafe(int i, GIntBig nValue)
1392 {
1393 pauFields[i].Integer64 = nValue;
1394 }
1395
1396 void SetFieldSameTypeUnsafe(int i, double dfValue)
1397 {
1398 pauFields[i].Real = dfValue;
1399 }
1400
1401 void SetFieldSameTypeUnsafe(int i, char *pszValueTransferred)
1402 {
1403 pauFields[i].String = pszValueTransferred;
1404 }
1405
1407
1408 void SetField(const char *pszFName, int nValue)
1409 {
1410 SetField(GetFieldIndex(pszFName), nValue);
1411 }
1412
1413 void SetField(const char *pszFName, GIntBig nValue)
1414 {
1415 SetField(GetFieldIndex(pszFName), nValue);
1416 }
1417
1418 void SetField(const char *pszFName, double dfValue)
1419 {
1420 SetField(GetFieldIndex(pszFName), dfValue);
1421 }
1422
1423 void SetField(const char *pszFName, const char *pszValue)
1424 {
1425 SetField(GetFieldIndex(pszFName), pszValue);
1426 }
1427
1428 void SetField(const char *pszFName, int nCount, const int *panValues)
1429 {
1430 SetField(GetFieldIndex(pszFName), nCount, panValues);
1431 }
1432
1433 void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
1434 {
1435 SetField(GetFieldIndex(pszFName), nCount, panValues);
1436 }
1437
1438 void SetField(const char *pszFName, int nCount, const double *padfValues)
1439 {
1440 SetField(GetFieldIndex(pszFName), nCount, padfValues);
1441 }
1442
1443 void SetField(const char *pszFName, const char *const *papszValues)
1444 {
1445 SetField(GetFieldIndex(pszFName), papszValues);
1446 }
1447
1448 void SetField(const char *pszFName, const OGRField *puValue)
1449 {
1450 SetField(GetFieldIndex(pszFName), puValue);
1451 }
1452
1453 void SetField(const char *pszFName, int nYear, int nMonth, int nDay,
1454 int nHour = 0, int nMinute = 0, float fSecond = 0.f,
1455 int nTZFlag = 0)
1456 {
1457 SetField(GetFieldIndex(pszFName), nYear, nMonth, nDay, nHour, nMinute,
1458 fSecond, nTZFlag);
1459 }
1460
1461 GIntBig GetFID() const
1462 {
1463 return nFID;
1464 }
1465
1466 virtual OGRErr SetFID(GIntBig nFIDIn);
1467
1468 void DumpReadable(FILE *, CSLConstList papszOptions = nullptr) const;
1469 std::string DumpReadableAsString(CSLConstList papszOptions = nullptr) const;
1470
1471 OGRErr SetFrom(const OGRFeature *, int bForgiving = TRUE);
1472 OGRErr SetFrom(const OGRFeature *, const int *panMap, int bForgiving = TRUE,
1473 bool bUseISO8601ForDateTimeAsString = false);
1474 OGRErr SetFieldsFrom(const OGRFeature *, const int *panMap,
1475 int bForgiving = TRUE,
1476 bool bUseISO8601ForDateTimeAsString = false);
1477
1479 OGRErr RemapFields(OGRFeatureDefn *poNewDefn, const int *panRemapSource);
1480 void AppendField();
1481 OGRErr RemapGeomFields(OGRFeatureDefn *poNewDefn,
1482 const int *panRemapSource);
1484
1485 int Validate(int nValidateFlags, int bEmitError) const;
1486 void FillUnsetWithDefault(int bNotNullableOnly, char **papszOptions);
1487
1488 bool SerializeToBinary(std::vector<GByte> &abyBuffer) const;
1489 bool DeserializeFromBinary(const GByte *pabyBuffer, size_t nSize);
1490
1491 virtual const char *GetStyleString() const;
1492 virtual void SetStyleString(const char *);
1493 virtual void SetStyleStringDirectly(char *);
1494
1498 virtual OGRStyleTable *GetStyleTable() const
1499 {
1500 return m_poStyleTable;
1501 } /* f.i.x.m.e: add a const qualifier for return type */
1502
1503 virtual void SetStyleTable(OGRStyleTable *poStyleTable);
1504 virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable);
1505
1506 const char *GetNativeData() const
1507 {
1508 return m_pszNativeData;
1509 }
1510
1511 const char *GetNativeMediaType() const
1512 {
1513 return m_pszNativeMediaType;
1514 }
1515
1516 void SetNativeData(const char *pszNativeData);
1517 void SetNativeMediaType(const char *pszNativeMediaType);
1518
1519 static OGRFeature *CreateFeature(OGRFeatureDefn *);
1520 static void DestroyFeature(OGRFeature *);
1521
1525 static inline OGRFeatureH ToHandle(OGRFeature *poFeature)
1526 {
1527 return reinterpret_cast<OGRFeatureH>(poFeature);
1528 }
1529
1533 static inline OGRFeature *FromHandle(OGRFeatureH hFeature)
1534 {
1535 return reinterpret_cast<OGRFeature *>(hFeature);
1536 }
1537
1538 private:
1539 CPL_DISALLOW_COPY_ASSIGN(OGRFeature)
1540};
1541
1543 struct CPL_DLL OGRFeatureUniquePtrDeleter
1544{
1545 void operator()(OGRFeature *) const;
1546};
1547
1549
1553 typedef std::unique_ptr<OGRFeature, OGRFeatureUniquePtrDeleter>
1554 OGRFeatureUniquePtr;
1555
1557
1558 inline OGRFeature::ConstFieldIterator begin(const OGRFeature *poFeature)
1559{
1560 return poFeature->begin();
1561}
1562
1564 inline OGRFeature::ConstFieldIterator end(const OGRFeature *poFeature)
1565{
1566 return poFeature->end();
1567}
1568
1570 inline OGRFeature::ConstFieldIterator
1571 begin(const OGRFeatureUniquePtr &poFeature)
1572{
1573 return poFeature->begin();
1574}
1575
1577 inline OGRFeature::ConstFieldIterator end(const OGRFeatureUniquePtr &poFeature)
1578{
1579 return poFeature->end();
1580}
1581
1583
1584/************************************************************************/
1585/* OGRFieldDomain */
1586/************************************************************************/
1587
1588/* clang-format off */
1608/* clang-format on */
1609
1610 class CPL_DLL OGRFieldDomain
1611{
1612 protected:
1614 std::string m_osName;
1615 std::string m_osDescription;
1616 OGRFieldDomainType m_eDomainType;
1617 OGRFieldType m_eFieldType;
1618 OGRFieldSubType m_eFieldSubType;
1619 OGRFieldDomainSplitPolicy m_eSplitPolicy = OFDSP_DEFAULT_VALUE;
1620 OGRFieldDomainMergePolicy m_eMergePolicy = OFDMP_DEFAULT_VALUE;
1621
1622 OGRFieldDomain(const std::string &osName, const std::string &osDescription,
1623 OGRFieldDomainType eDomainType, OGRFieldType eFieldType,
1624 OGRFieldSubType eFieldSubType);
1627 public:
1632 virtual ~OGRFieldDomain() = 0;
1633
1638 virtual OGRFieldDomain *Clone() const = 0;
1639
1644 const std::string &GetName() const
1645 {
1646 return m_osName;
1647 }
1648
1654 const std::string &GetDescription() const
1655 {
1656 return m_osDescription;
1657 }
1658
1663 OGRFieldDomainType GetDomainType() const
1664 {
1665 return m_eDomainType;
1666 }
1667
1672 OGRFieldType GetFieldType() const
1673 {
1674 return m_eFieldType;
1675 }
1676
1681 OGRFieldSubType GetFieldSubType() const
1682 {
1683 return m_eFieldSubType;
1684 }
1685
1687 static inline OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)
1688 {
1689 return reinterpret_cast<OGRFieldDomainH>(poFieldDomain);
1690 }
1691
1693 static inline OGRFieldDomain *FromHandle(OGRFieldDomainH hFieldDomain)
1694 {
1695 return reinterpret_cast<OGRFieldDomain *>(hFieldDomain);
1696 }
1697
1702 OGRFieldDomainSplitPolicy GetSplitPolicy() const
1703 {
1704 return m_eSplitPolicy;
1705 }
1706
1711 void SetSplitPolicy(OGRFieldDomainSplitPolicy policy)
1712 {
1713 m_eSplitPolicy = policy;
1714 }
1715
1720 OGRFieldDomainMergePolicy GetMergePolicy() const
1721 {
1722 return m_eMergePolicy;
1723 }
1724
1729 void SetMergePolicy(OGRFieldDomainMergePolicy policy)
1730 {
1731 m_eMergePolicy = policy;
1732 }
1733};
1734
1741 class CPL_DLL OGRCodedFieldDomain final : public OGRFieldDomain
1742{
1743 private:
1744 std::vector<OGRCodedValue> m_asValues{};
1745
1746 OGRCodedFieldDomain(const OGRCodedFieldDomain &) = delete;
1747 OGRCodedFieldDomain &operator=(const OGRCodedFieldDomain &) = delete;
1748
1749 public:
1765 OGRCodedFieldDomain(const std::string &osName,
1766 const std::string &osDescription,
1767 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1768 std::vector<OGRCodedValue> &&asValues);
1769
1770 ~OGRCodedFieldDomain() override;
1771
1772 OGRCodedFieldDomain *Clone() const override;
1773
1779 const OGRCodedValue *GetEnumeration() const
1780 {
1781 return m_asValues.data();
1782 }
1783};
1784
1787 class CPL_DLL OGRRangeFieldDomain final : public OGRFieldDomain
1788{
1789 private:
1790 OGRField m_sMin;
1791 OGRField m_sMax;
1792 bool m_bMinIsInclusive;
1793 bool m_bMaxIsInclusive;
1794
1795 OGRRangeFieldDomain(const OGRRangeFieldDomain &) = delete;
1796 OGRRangeFieldDomain &operator=(const OGRRangeFieldDomain &) = delete;
1797
1798 public:
1826 OGRRangeFieldDomain(const std::string &osName,
1827 const std::string &osDescription,
1828 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1829 const OGRField &sMin, bool bMinIsInclusive,
1830 const OGRField &sMax, bool bMaxIsInclusive);
1831
1832 OGRRangeFieldDomain *Clone() const override
1833 {
1834 auto poDomain = new OGRRangeFieldDomain(
1835 m_osName, m_osDescription, m_eFieldType, m_eFieldSubType, m_sMin,
1836 m_bMinIsInclusive, m_sMax, m_bMaxIsInclusive);
1837 poDomain->SetMergePolicy(m_eMergePolicy);
1838 poDomain->SetSplitPolicy(m_eSplitPolicy);
1839 return poDomain;
1840 }
1841
1855 const OGRField &GetMin(bool &bIsInclusiveOut) const
1856 {
1857 bIsInclusiveOut = m_bMinIsInclusive;
1858 return m_sMin;
1859 }
1860
1874 const OGRField &GetMax(bool &bIsInclusiveOut) const
1875 {
1876 bIsInclusiveOut = m_bMaxIsInclusive;
1877 return m_sMax;
1878 }
1879};
1880
1885 class CPL_DLL OGRGlobFieldDomain final : public OGRFieldDomain
1886{
1887 private:
1888 std::string m_osGlob;
1889
1890 OGRGlobFieldDomain(const OGRGlobFieldDomain &) = delete;
1891 OGRGlobFieldDomain &operator=(const OGRGlobFieldDomain &) = delete;
1892
1893 public:
1904 OGRGlobFieldDomain(const std::string &osName,
1905 const std::string &osDescription,
1906 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1907 const std::string &osBlob);
1908
1909 OGRGlobFieldDomain *Clone() const override
1910 {
1911 auto poDomain = new OGRGlobFieldDomain(
1912 m_osName, m_osDescription, m_eFieldType, m_eFieldSubType, m_osGlob);
1913 poDomain->SetMergePolicy(m_eMergePolicy);
1914 poDomain->SetSplitPolicy(m_eSplitPolicy);
1915 return poDomain;
1916 }
1917
1922 const std::string &GetGlob() const
1923 {
1924 return m_osGlob;
1925 }
1926};
1927
1928/************************************************************************/
1929/* OGRFeatureQuery */
1930/************************************************************************/
1931
1933 class OGRLayer;
1934 class swq_expr_node;
1935 class swq_custom_func_registrar;
1936 struct swq_evaluation_context;
1937
1938 class CPL_DLL OGRFeatureQuery
1939{
1940 private:
1941 OGRFeatureDefn *poTargetDefn;
1942 void *pSWQExpr;
1943 swq_evaluation_context *m_psContext = nullptr;
1944
1945 char **FieldCollector(void *, char **);
1946
1947 static GIntBig *EvaluateAgainstIndices(const swq_expr_node *, OGRLayer *,
1948 GIntBig &nFIDCount);
1949
1950 static int CanUseIndex(const swq_expr_node *, OGRLayer *);
1951
1952 OGRErr Compile(OGRLayer *, OGRFeatureDefn *, const char *, int bCheck,
1953 swq_custom_func_registrar *poCustomFuncRegistrar);
1954
1955 CPL_DISALLOW_COPY_ASSIGN(OGRFeatureQuery)
1956
1957 public:
1958 OGRFeatureQuery();
1959 ~OGRFeatureQuery();
1960
1961 OGRErr Compile(OGRLayer *, const char *, int bCheck = TRUE,
1962 swq_custom_func_registrar *poCustomFuncRegistrar = nullptr);
1963 OGRErr Compile(OGRFeatureDefn *, const char *, int bCheck = TRUE,
1964 swq_custom_func_registrar *poCustomFuncRegistrar = nullptr);
1965 int Evaluate(OGRFeature *);
1966
1967 GIntBig *EvaluateAgainstIndices(OGRLayer *, OGRErr *);
1968
1969 int CanUseIndex(OGRLayer *);
1970
1971 char **GetUsedFields();
1972
1973 void *GetSWQExpr()
1974 {
1975 return pSWQExpr;
1976 }
1977};
1978
1980
1981#endif /* ndef OGR_FEATURE_H_INCLUDED */
OGRCodedFieldDomain
Definition of a coded / enumerated field domain.
Definition: ogr_feature.h:1742
OGRCodedFieldDomain::GetEnumeration
const OGRCodedValue * GetEnumeration() const
Get the enumeration as (code, value) pairs.
Definition: ogr_feature.h:1779
OGRFeatureDefn
Definition of a feature class or feature layer.
Definition: ogr_feature.h:501
OGRFeatureDefn::Reference
int Reference()
Increments the reference count by one.
Definition: ogr_feature.h:748
OGRFeatureDefn::GetFieldCount
virtual int GetFieldCount() const
Fetch number of fields on this feature.
Definition: ogrfeaturedefn.cpp:262
OGRFeatureDefn::GetFieldDefn
virtual OGRFieldDefn * GetFieldDefn(int i)
Fetch field definition.
Definition: ogrfeaturedefn.cpp:306
OGRFeatureDefn::GetGeomFields
GeomFields GetGeomFields()
Return an object that can be used to iterate over geometry fields.
Definition: ogr_feature.h:734
OGRFeatureDefn::IsStyleIgnored
virtual bool IsStyleIgnored() const
Determine whether the style can be omitted when fetching features.
Definition: ogr_feature.h:768
OGRFeatureDefn::GetFields
Fields GetFields()
Return an object that can be used to iterate over non-geometry fields.
Definition: ogr_feature.h:613
OGRFeatureDefn::Dereference
int Dereference()
Decrements the reference count by one.
Definition: ogr_feature.h:753
OGRFeatureDefn::ToHandle
static OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
Convert a OGRFeatureDefn* to a OGRFeatureDefnH.
Definition: ogr_feature.h:793
OGRFeatureDefn::FromHandle
static OGRFeatureDefn * FromHandle(OGRFeatureDefnH hFeatureDefn)
Convert a OGRFeatureDefnH to a OGRFeatureDefn*.
Definition: ogr_feature.h:801
OGRFeatureDefn::GetGeomFieldDefn
virtual OGRGeomFieldDefn * GetGeomFieldDefn(int i)
Fetch geometry field definition.
Definition: ogrfeaturedefn.cpp:656
OGRFeatureDefn::GetGeomFieldCount
virtual int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition: ogrfeaturedefn.cpp:607
OGRFeatureDefn::GetFieldIndex
virtual int GetFieldIndex(const char *) const
Find field by name.
Definition: ogrfeaturedefn.cpp:1215
OGRFeatureDefn::GetReferenceCount
int GetReferenceCount() const
Fetch current reference count.
Definition: ogr_feature.h:758
OGRFeatureDefn::GetGeomFieldIndex
virtual int GetGeomFieldIndex(const char *) const
Find geometry field by name.
Definition: ogrfeaturedefn.cpp:906
OGRFeatureDefn::SetStyleIgnored
virtual void SetStyleIgnored(bool bIgnore)
Set whether the style can be omitted when fetching features.
Definition: ogr_feature.h:773
OGRFeature::ConstFieldIterator
Field value iterator class.
Definition: ogr_feature.h:1113
OGRFeature::FieldNotFoundException
Exception raised by operator[](const char*) when a field is not found.
Definition: ogr_feature.h:1159
OGRFeature::FieldValue
Field value.
Definition: ogr_feature.h:903
OGRFeature::FieldValue::empty
bool empty() const
Return whether the field value is unset/empty.
Definition: ogr_feature.h:982
OGRFeature::FieldValue::GetInteger
int GetInteger() const
Return the integer value.
Definition: ogr_feature.h:1002
OGRFeature::FieldValue::GetType
OGRFieldType GetType() const
Return field type.
Definition: ogr_feature.h:969
OGRFeature::FieldValue::Unset
void Unset()
Unset the field.
Definition: ogr_feature.h:948
OGRFeature::FieldValue::GetDouble
double GetDouble() const
Return the double value.
Definition: ogr_feature.h:1020
OGRFeature::FieldValue::GetName
const char * GetName() const
Return field name.
Definition: ogr_feature.h:963
OGRFeature::FieldValue::GetInteger64
GIntBig GetInteger64() const
Return the 64-bit integer value.
Definition: ogr_feature.h:1011
OGRFeature::FieldValue::GetSubType
OGRFieldSubType GetSubType() const
Return field subtype.
Definition: ogr_feature.h:975
OGRFeature::FieldValue::GetString
const char * GetString() const
Return the string value.
Definition: ogr_feature.h:1029
OGRFeature
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:877
OGRFeature::GetDefnRef
OGRFeatureDefn * GetDefnRef()
Fetch feature definition.
Definition: ogr_feature.h:1165
OGRFeature::GetFieldAsISO8601DateTime
const char * GetFieldAsISO8601DateTime(const char *pszFName, CSLConstList papszOptions) const
Fetch OFTDateTime field value as a ISO8601 representation.
Definition: ogr_feature.h:1341
OGRFeature::ToHandle
static OGRFeatureH ToHandle(OGRFeature *poFeature)
Convert a OGRFeature* to a OGRFeatureH.
Definition: ogr_feature.h:1525
OGRFeature::GetFieldAsStringList
char ** GetFieldAsStringList(const char *pszFName) const
Fetch field value as a list of strings.
Definition: ogr_feature.h:1363
OGRFeature::end
ConstFieldIterator end() const
Return end of field value iterator.
Definition: ogrfeature.cpp:8361
OGRFeature::begin
ConstFieldIterator begin() const
Return begin of field value iterator.
Definition: ogrfeature.cpp:8356
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:1433
OGRFeature::GetDefnRef
const OGRFeatureDefn * GetDefnRef() const
Fetch feature definition.
Definition: ogr_feature.h:1170
OGRFeature::GetFieldDefnRef
OGRFieldDefn * GetFieldDefnRef(int iField)
Fetch definition for this field.
Definition: ogr_feature.h:1228
OGRFeature::GetFieldAsDoubleList
const double * GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
Fetch field value as a list of doubles.
Definition: ogr_feature.h:1358
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:1428
OGRFeature::SetField
void SetField(const char *pszFName, GIntBig nValue)
Set field to 64 bit integer value.
Definition: ogr_feature.h:1413
OGRFeature::SetField
void SetField(const char *pszFName, const char *pszValue)
Set field to string value.
Definition: ogr_feature.h:1423
OGRFeature::SetField
void SetField(const char *pszFName, int nValue)
Set field to integer value.
Definition: ogr_feature.h:1408
OGRFeature::GetFieldDefnRef
const OGRFieldDefn * GetFieldDefnRef(int iField) const
Fetch definition for this field.
Definition: ogr_feature.h:1223
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:1453
OGRFeature::GetGeomFieldDefnRef
const OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField) const
Fetch definition for this geometry field.
Definition: ogr_feature.h:1195
OGRFeature::GetNativeData
const char * GetNativeData() const
Returns the native data for the feature.
Definition: ogr_feature.h:1506
OGRFeature::GetFieldIndex
int GetFieldIndex(const char *pszName) const
Fetch the field index given field name.
Definition: ogr_feature.h:1233
OGRFeature::GetGeomFieldIndex
int GetGeomFieldIndex(const char *pszName) const
Fetch the geometry field index given geometry field name.
Definition: ogr_feature.h:1200
OGRFeature::GetGeomFieldDefnRef
OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField)
Fetch definition for this geometry field.
Definition: ogr_feature.h:1190
OGRFeature::GetFieldAsInteger64
GIntBig GetFieldAsInteger64(const char *pszFName) const
Fetch field value as integer 64 bit.
Definition: ogr_feature.h:1326
OGRFeature::GetFieldAsIntegerList
const int * GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
Fetch field value as a list of integers.
Definition: ogr_feature.h:1347
OGRFeature::SetField
void SetField(const char *pszFName, double dfValue)
Set field to double value.
Definition: ogr_feature.h:1418
OGRFeature::GetFieldAsString
const char * GetFieldAsString(const char *pszFName) const
Fetch field value as a string.
Definition: ogr_feature.h:1336
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:1443
OGRFeature::GetRawFieldRef
const OGRField * GetRawFieldRef(int i) const
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:1253
OGRFeature::GetFieldAsInteger
int GetFieldAsInteger(const char *pszFName) const
Fetch field value as integer.
Definition: ogr_feature.h:1321
OGRFeature::GetNativeMediaType
const char * GetNativeMediaType() const
Returns the native media type for the feature.
Definition: ogr_feature.h:1511
OGRFeature::SetField
void SetField(const char *pszFName, const OGRField *puValue)
Set field.
Definition: ogr_feature.h:1448
OGRFeature::GetFID
GIntBig GetFID() const
Get feature identifier.
Definition: ogr_feature.h:1461
OGRFeature::GetRawFieldRef
OGRField * GetRawFieldRef(int i)
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:1248
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:1438
OGRFeature::GetStyleTable
virtual OGRStyleTable * GetStyleTable() const
Return style table.
Definition: ogr_feature.h:1498
OGRFeature::GetFieldAsDouble
double GetFieldAsDouble(const char *pszFName) const
Fetch field value as a double.
Definition: ogr_feature.h:1331
OGRFeature::FromHandle
static OGRFeature * FromHandle(OGRFeatureH hFeature)
Convert a OGRFeatureH to a OGRFeature*.
Definition: ogr_feature.h:1533
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:1352
OGRFieldDefn
Definition of an attribute of an OGRFeatureDefn.
Definition: ogr_feature.h:95
OGRFieldDefn::GetNameRef
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:125
OGRFieldDefn::Unseal
void Unseal()
Unseal a OGRFieldDefn.
Definition: ogrfielddefn.cpp:2104
OGRFieldDefn::IsNullable
int IsNullable() const
Return whether this field can receive null values.
Definition: ogr_feature.h:201
OGRFieldDefn::Seal
void Seal()
Seal a OGRFieldDefn.
Definition: ogrfielddefn.cpp:2085
OGRFieldDefn::IsUnique
int IsUnique() const
Return whether this field has a unique constraint.
Definition: ogr_feature.h:208
OGRFieldDefn::GetSubType
OGRFieldSubType GetSubType() const
Fetch subtype of this field.
Definition: ogr_feature.h:145
OGRFieldDefn::GetJustify
OGRJustification GetJustify() const
Get the justification for this field.
Definition: ogr_feature.h:153
OGRFieldDefn::SetIgnored
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:196
OGRFieldDefn::GetPrecision
int GetPrecision() const
Get the formatting precision for this field.
Definition: ogr_feature.h:170
OGRFieldDefn::GetType
OGRFieldType GetType() const
Fetch type of this field.
Definition: ogr_feature.h:137
OGRFieldDefn::GetWidth
int GetWidth() const
Get the formatting width for this field.
Definition: ogr_feature.h:163
OGRFieldDefn::GetComment
const std::string & GetComment() const
Return the (optional) comment for this field.
Definition: ogr_feature.h:222
OGRFieldDefn::GetTZFlag
int GetTZFlag() const
Get the time zone flag.
Definition: ogr_feature.h:177
OGRFieldDefn::SetJustify
void SetJustify(OGRJustification eJustifyIn)
Set the justification for this field.
Definition: ogr_feature.h:158
OGRFieldDefn::GetAlternativeNameRef
const char * GetAlternativeNameRef() const
Fetch the alternative name (or "alias") for this field.
Definition: ogr_feature.h:132
OGRFieldDefn::ToHandle
static OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
Convert a OGRFieldDefn* to a OGRFieldDefnH.
Definition: ogr_feature.h:234
OGRFieldDefn::GetDomainName
const std::string & GetDomainName() const
Return the name of the field domain for this field.
Definition: ogr_feature.h:215
OGRFieldDefn::IsIgnored
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:191
OGRFieldDefn::FromHandle
static OGRFieldDefn * FromHandle(OGRFieldDefnH hFieldDefn)
Convert a OGRFieldDefnH to a OGRFieldDefn*.
Definition: ogr_feature.h:242
OGRFieldDomain
Definition of a field domain.
Definition: ogr_feature.h:1611
OGRFieldDomain::GetMergePolicy
OGRFieldDomainMergePolicy GetMergePolicy() const
Get the merge policy.
Definition: ogr_feature.h:1720
OGRFieldDomain::SetMergePolicy
void SetMergePolicy(OGRFieldDomainMergePolicy policy)
Set the merge policy.
Definition: ogr_feature.h:1729
OGRFieldDomain::FromHandle
static OGRFieldDomain * FromHandle(OGRFieldDomainH hFieldDomain)
Convert a OGRFieldDomainH to a OGRFieldDomain*.
Definition: ogr_feature.h:1693
OGRFieldDomain::Clone
virtual OGRFieldDomain * Clone() const =0
Clone.
OGRFieldDomain::GetFieldSubType
OGRFieldSubType GetFieldSubType() const
Get the field subtype.
Definition: ogr_feature.h:1681
OGRFieldDomain::GetName
const std::string & GetName() const
Get the name of the field domain.
Definition: ogr_feature.h:1644
OGRFieldDomain::~OGRFieldDomain
virtual ~OGRFieldDomain()=0
Destructor.
OGRFieldDomain::GetDescription
const std::string & GetDescription() const
Get the description of the field domain.
Definition: ogr_feature.h:1654
OGRFieldDomain::GetSplitPolicy
OGRFieldDomainSplitPolicy GetSplitPolicy() const
Get the split policy.
Definition: ogr_feature.h:1702
OGRFieldDomain::ToHandle
static OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)
Convert a OGRFieldDomain* to a OGRFieldDomainH.
Definition: ogr_feature.h:1687
OGRFieldDomain::GetFieldType
OGRFieldType GetFieldType() const
Get the field type.
Definition: ogr_feature.h:1672
OGRFieldDomain::GetDomainType
OGRFieldDomainType GetDomainType() const
Get the type of the field domain.
Definition: ogr_feature.h:1663
OGRFieldDomain::SetSplitPolicy
void SetSplitPolicy(OGRFieldDomainSplitPolicy policy)
Set the split policy.
Definition: ogr_feature.h:1711
OGRGeomFieldDefn
Definition of a geometry field of an OGRFeatureDefn.
Definition: ogr_feature.h:330
OGRGeomFieldDefn::SetIgnored
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:373
OGRGeomFieldDefn::Seal
void Seal()
Seal a OGRGeomFieldDefn.
Definition: ogrgeomfielddefn.cpp:825
OGRGeomFieldDefn::Unseal
void Unseal()
Unseal a OGRGeomFieldDefn.
Definition: ogrgeomfielddefn.cpp:844
OGRGeomFieldDefn::FromHandle
static OGRGeomFieldDefn * FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
Convert a OGRGeomFieldDefnH to a OGRGeomFieldDefn*.
Definition: ogr_feature.h:405
OGRGeomFieldDefn::IsNullable
int IsNullable() const
Return whether this geometry field can receive null values.
Definition: ogr_feature.h:378
OGRGeomFieldDefn::GetType
OGRwkbGeometryType GetType() const
Fetch geometry type of this field.
Definition: ogr_feature.h:358
OGRGeomFieldDefn::GetCoordinatePrecision
const OGRGeomCoordinatePrecision & GetCoordinatePrecision() const
Return the coordinate precision associated to this geometry field.
Definition: ogr_feature.h:385
OGRGeomFieldDefn::IsIgnored
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:368
OGRGeomFieldDefn::ToHandle
static OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
Convert a OGRGeomFieldDefn* to a OGRGeomFieldDefnH.
Definition: ogr_feature.h:397
OGRGeomFieldDefn::GetNameRef
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:353
OGRGeometry
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:361
OGRGlobFieldDomain
Definition of a field domain for field content validated by a glob.
Definition: ogr_feature.h:1886
OGRGlobFieldDomain::Clone
OGRGlobFieldDomain * Clone() const override
Clone.
Definition: ogr_feature.h:1909
OGRGlobFieldDomain::GetGlob
const std::string & GetGlob() const
Get the glob expression.
Definition: ogr_feature.h:1922
OGRLayer
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:58
OGRRangeFieldDomain
Definition of a numeric field domain with a range of validity for values.
Definition: ogr_feature.h:1788
OGRRangeFieldDomain::Clone
OGRRangeFieldDomain * Clone() const override
Clone.
Definition: ogr_feature.h:1832
OGRRangeFieldDomain::GetMax
const OGRField & GetMax(bool &bIsInclusiveOut) const
Get the maximum value.
Definition: ogr_feature.h:1874
OGRRangeFieldDomain::GetMin
const OGRField & GetMin(bool &bIsInclusiveOut) const
Get the minimum value.
Definition: ogr_feature.h:1855
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:153
OGRStyleTable
This class represents a style table.
Definition: ogr_featurestyle.h:70
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:1030
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1179
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:964
GByte
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:169
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:199
OGRFieldDefnH
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_api.h:406
OGRFeatureDefnH
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_api.h:408
OGRFeatureH
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_api.h:410
OGRFieldDomainH
struct OGRFieldDomainHS * OGRFieldDomainH
Opaque type for a field domain definition (OGRFieldDomain)
Definition: ogr_api.h:418
OGRGeomFieldDefnH
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_api.h:415
OGRUnsetMarker
#define OGRUnsetMarker
Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for a unset field.
Definition: ogr_core.h:863
OGR_TZFLAG_UNKNOWN
#define OGR_TZFLAG_UNKNOWN
Time zone flag indicating unknown timezone.
Definition: ogr_core.h:877
OGRBoolean
int OGRBoolean
Type for a OGR boolean.
Definition: ogr_core.h:388
OGRFieldSubType
OGRFieldSubType
List of field subtypes.
Definition: ogr_core.h:816
OGRFieldDomainMergePolicy
OGRFieldDomainMergePolicy
Merge policy for field domains.
Definition: ogr_core.h:1271
OFDMP_DEFAULT_VALUE
@ OFDMP_DEFAULT_VALUE
Default value.
Definition: ogr_core.h:1273
OGRFieldDomainType
OGRFieldDomainType
Type of field domain.
Definition: ogr_core.h:1236
OGRJustification
OGRJustification
Display justification for field values.
Definition: ogr_core.h:841
OGRFieldType
OGRFieldType
List of feature field types.
Definition: ogr_core.h:788
OGRNullMarker
#define OGRNullMarker
Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for a null field.
Definition: ogr_core.h:871
OGRwkbGeometryType
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:407
wkbUnknown
@ wkbUnknown
unknown type, non-standard
Definition: ogr_core.h:408
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:371
OGRFieldDomainSplitPolicy
OGRFieldDomainSplitPolicy
Split policy for field domains.
Definition: ogr_core.h:1253
OFDSP_DEFAULT_VALUE
@ OFDSP_DEFAULT_VALUE
Default value.
Definition: ogr_core.h:1255
OGRFeatureUniquePtr
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:1554
OGRFieldDefnH
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_feature.h:47
OGRFeatureDefnH
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_feature.h:49
OGRFeatureH
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_feature.h:51
OGRFieldDomainH
struct OGRFieldDomainHS * OGRFieldDomainH
Opaque type for a field domain definition (OGRFieldDomain)
Definition: ogr_feature.h:59
OGRGeomFieldDefnH
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_feature.h:56
OGRStyleTableH
void * OGRStyleTableH
Opaque type for a style table (OGRStyleTable)
Definition: ogr_feature.h:53
ogr_featurestyle.h
Simple feature style classes.
ogr_geometry.h
Simple feature geometry classes.
begin
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:421
end
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:429
OGRCodedValue
Associates a code and a value.
Definition: ogr_core.h:1223
OGRGeomCoordinatePrecision
Geometry coordinate precision.
Definition: ogr_geomcoordinateprecision.h:34
OGRField
OGRFeature field attribute value union.
Definition: ogr_core.h:905