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 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
29 ****************************************************************************/
30
31#ifndef OGR_FEATURE_H_INCLUDED
32#define OGR_FEATURE_H_INCLUDED
33
34#include "cpl_atomic_ops.h"
35#include "ogr_featurestyle.h"
36#include "ogr_geometry.h"
37#include "ogr_geomcoordinateprecision.h"
38
39#include <cstddef>
40
41#include <exception>
42#include <memory>
43#include <string>
44#include <vector>
45
52#ifndef DEFINE_OGRFeatureH
54#define DEFINE_OGRFeatureH
56#ifdef DEBUG
57typedef struct OGRFieldDefnHS *OGRFieldDefnH;
58typedef struct OGRFeatureDefnHS *OGRFeatureDefnH;
59typedef struct OGRFeatureHS *OGRFeatureH;
60typedef struct OGRStyleTableHS *OGRStyleTableH;
61#else
63typedef void *OGRFieldDefnH;
65typedef void *OGRFeatureDefnH;
67typedef void *OGRFeatureH;
69typedef void *OGRStyleTableH;
70#endif
72typedef struct OGRGeomFieldDefnHS *OGRGeomFieldDefnH;
73
75typedef struct OGRFieldDomainHS *OGRFieldDomainH;
76#endif /* DEFINE_OGRFeatureH */
77
78class OGRStyleTable;
79
80/************************************************************************/
81/* OGRFieldDefn */
82/************************************************************************/
83
110class CPL_DLL OGRFieldDefn
111{
112 private:
113 char *pszName;
114 char *pszAlternativeName;
115 OGRFieldType eType;
116 OGRJustification eJustify;
117 int nWidth; // Zero is variable.
118 int nPrecision;
119 char *pszDefault;
120
121 int bIgnore;
122 OGRFieldSubType eSubType;
123
124 int bNullable;
125 int bUnique;
126
127 std::string m_osDomainName{}; // field domain name. Might be empty
128
129 std::string m_osComment{}; // field comment. Might be empty
130
131 int m_nTZFlag = OGR_TZFLAG_UNKNOWN;
132 bool m_bSealed = false;
133
134 public:
135 OGRFieldDefn(const char *, OGRFieldType);
136 explicit OGRFieldDefn(const OGRFieldDefn *);
138
139 void SetName(const char *);
140
141 const char *GetNameRef() const
142 {
143 return pszName;
144 }
145
146 void SetAlternativeName(const char *);
147
148 const char *GetAlternativeNameRef() const
149 {
150 return pszAlternativeName;
151 }
152
154 {
155 return eType;
156 }
157
158 void SetType(OGRFieldType eTypeIn);
159 static const char *GetFieldTypeName(OGRFieldType);
160
162 {
163 return eSubType;
164 }
165
166 void SetSubType(OGRFieldSubType eSubTypeIn);
167 static const char *GetFieldSubTypeName(OGRFieldSubType);
168
170 {
171 return eJustify;
172 }
173
175 {
176 eJustify = eJustifyIn;
177 }
178
179 int GetWidth() const
180 {
181 return nWidth;
182 }
183
184 void SetWidth(int nWidthIn);
185
186 int GetPrecision() const
187 {
188 return nPrecision;
189 }
190
191 void SetPrecision(int nPrecisionIn);
192
193 int GetTZFlag() const
194 {
195 return m_nTZFlag;
196 }
197
198 void SetTZFlag(int nTZFlag);
199
200 void Set(const char *, OGRFieldType, int = 0, int = 0,
201 OGRJustification = OJUndefined);
202
203 void SetDefault(const char *);
204 const char *GetDefault() const;
205 int IsDefaultDriverSpecific() const;
206
207 int IsIgnored() const
208 {
209 return bIgnore;
210 }
211
212 void SetIgnored(int bIgnoreIn)
213 {
214 bIgnore = bIgnoreIn;
215 }
216
217 int IsNullable() const
218 {
219 return bNullable;
220 }
221
222 void SetNullable(int bNullableIn);
223
224 int IsUnique() const
225 {
226 return bUnique;
227 }
228
229 void SetUnique(int bUniqueIn);
230
231 const std::string &GetDomainName() const
232 {
233 return m_osDomainName;
234 }
235
236 void SetDomainName(const std::string &osDomainName);
237
238 const std::string &GetComment() const
239 {
240 return m_osComment;
241 }
242
243 void SetComment(const std::string &osComment);
244
245 int IsSame(const OGRFieldDefn *) const;
246
250 static inline OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
251 {
252 return reinterpret_cast<OGRFieldDefnH>(poFieldDefn);
253 }
254
258 static inline OGRFieldDefn *FromHandle(OGRFieldDefnH hFieldDefn)
259 {
260 return reinterpret_cast<OGRFieldDefn *>(hFieldDefn);
261 }
262
263 void Seal();
264
265 void Unseal();
266
268 struct CPL_DLL TemporaryUnsealer
269 {
270 private:
271 OGRFieldDefn *m_poFieldDefn = nullptr;
272 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
273 public:
274 explicit TemporaryUnsealer(OGRFieldDefn *poFieldDefn)
275 : m_poFieldDefn(poFieldDefn)
276 {
277 m_poFieldDefn->Unseal();
278 }
279
280 TemporaryUnsealer(TemporaryUnsealer &&) = default;
281 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
282
283 ~TemporaryUnsealer()
284 {
285 m_poFieldDefn->Seal();
286 }
287
288 OGRFieldDefn *operator->()
289 {
290 return m_poFieldDefn;
291 }
292 };
293
296 TemporaryUnsealer GetTemporaryUnsealer();
297
298 private:
300};
301
302#ifdef GDAL_COMPILATION
314inline OGRFieldDefn::TemporaryUnsealer whileUnsealing(OGRFieldDefn *object)
315{
316 return object->GetTemporaryUnsealer();
317}
318#endif
319
320/************************************************************************/
321/* OGRGeomFieldDefn */
322/************************************************************************/
323
345class CPL_DLL OGRGeomFieldDefn
346{
347 protected:
349 char *pszName = nullptr;
350 OGRwkbGeometryType eGeomType =
351 wkbUnknown; /* all values possible except wkbNone */
352 mutable const OGRSpatialReference *poSRS = nullptr;
353
354 int bIgnore = false;
355 mutable int bNullable = true;
356 bool m_bSealed = false;
357 OGRGeomCoordinatePrecision m_oCoordPrecision{};
358
359 void Initialize(const char *, OGRwkbGeometryType);
361
362 public:
363 OGRGeomFieldDefn(const char *pszNameIn, OGRwkbGeometryType eGeomTypeIn);
364 explicit OGRGeomFieldDefn(const OGRGeomFieldDefn *);
365 virtual ~OGRGeomFieldDefn();
366
367 void SetName(const char *);
368
369 const char *GetNameRef() const
370 {
371 return pszName;
372 }
373
375 {
376 return eGeomType;
377 }
378
379 void SetType(OGRwkbGeometryType eTypeIn);
380
381 virtual const OGRSpatialReference *GetSpatialRef() const;
382 void SetSpatialRef(const OGRSpatialReference *poSRSIn);
383
384 int IsIgnored() const
385 {
386 return bIgnore;
387 }
388
389 void SetIgnored(int bIgnoreIn)
390 {
391 bIgnore = bIgnoreIn;
392 }
393
394 int IsNullable() const
395 {
396 return bNullable;
397 }
398
399 void SetNullable(int bNullableIn);
400
402 {
403 return m_oCoordPrecision;
404 }
405
406 void SetCoordinatePrecision(const OGRGeomCoordinatePrecision &prec);
407
408 int IsSame(const OGRGeomFieldDefn *) const;
409
413 static inline OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
414 {
415 return reinterpret_cast<OGRGeomFieldDefnH>(poGeomFieldDefn);
416 }
417
421 static inline OGRGeomFieldDefn *FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
422 {
423 return reinterpret_cast<OGRGeomFieldDefn *>(hGeomFieldDefn);
424 }
425
426 void Seal();
427
428 void Unseal();
429
431 struct CPL_DLL TemporaryUnsealer
432 {
433 private:
434 OGRGeomFieldDefn *m_poFieldDefn = nullptr;
435 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
436 public:
437 explicit TemporaryUnsealer(OGRGeomFieldDefn *poFieldDefn)
438 : m_poFieldDefn(poFieldDefn)
439 {
440 m_poFieldDefn->Unseal();
441 }
442
443 TemporaryUnsealer(TemporaryUnsealer &&) = default;
444 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
445
446 ~TemporaryUnsealer()
447 {
448 m_poFieldDefn->Seal();
449 }
450
451 OGRGeomFieldDefn *operator->()
452 {
453 return m_poFieldDefn;
454 }
455 };
456
459 TemporaryUnsealer GetTemporaryUnsealer();
460
461 private:
463};
464
465#ifdef GDAL_COMPILATION
477inline OGRGeomFieldDefn::TemporaryUnsealer
478whileUnsealing(OGRGeomFieldDefn *object)
479{
480 return object->GetTemporaryUnsealer();
481}
482#endif
483
484/************************************************************************/
485/* OGRFeatureDefn */
486/************************************************************************/
487
516class CPL_DLL OGRFeatureDefn
517{
518 protected:
520 volatile int nRefCount = 0;
521
522 mutable std::vector<std::unique_ptr<OGRFieldDefn>> apoFieldDefn{};
523 mutable std::vector<std::unique_ptr<OGRGeomFieldDefn>> apoGeomFieldDefn{};
524
525 char *pszFeatureClassName = nullptr;
526
527 bool bIgnoreStyle = false;
528
529 friend class TemporaryUnsealer;
530 bool m_bSealed = false;
531 int m_nTemporaryUnsealCount = 0;
533
534 public:
535 explicit OGRFeatureDefn(const char *pszName = nullptr);
536 virtual ~OGRFeatureDefn();
537
538 void SetName(const char *pszName);
539 virtual const char *GetName() const;
540
541 virtual int GetFieldCount() const;
542 virtual OGRFieldDefn *GetFieldDefn(int i);
543 virtual const OGRFieldDefn *GetFieldDefn(int i) const;
544 virtual int GetFieldIndex(const char *) const;
545 int GetFieldIndexCaseSensitive(const char *) const;
546
548
552 struct CPL_DLL Fields
553 {
554 private:
555 OGRFeatureDefn *m_poFDefn;
556
557 public:
558 inline explicit Fields(OGRFeatureDefn *poFDefn) : m_poFDefn(poFDefn)
559 {
560 }
561
562 struct CPL_DLL ConstIterator
563 {
564 private:
565 OGRFeatureDefn *m_poFDefn;
566 int m_nIdx;
567
568 public:
569 inline ConstIterator(OGRFeatureDefn *poFDefn, int nIdx)
570 : m_poFDefn(poFDefn), m_nIdx(nIdx)
571 {
572 }
573
574 inline const OGRFieldDefn *operator*() const
575 {
576 return m_poFDefn->GetFieldDefn(m_nIdx);
577 }
578
579 inline ConstIterator &operator++()
580 {
581 m_nIdx++;
582 return *this;
583 }
584
585 inline bool operator!=(const ConstIterator &it) const
586 {
587 return m_nIdx != it.m_nIdx;
588 }
589 };
590
591 inline ConstIterator begin()
592 {
593 return ConstIterator(m_poFDefn, 0);
594 }
595
596 inline ConstIterator end()
597 {
598 return ConstIterator(m_poFDefn, m_poFDefn->GetFieldCount());
599 }
600
601 inline size_t size() const
602 {
603 return static_cast<std::size_t>(m_poFDefn->GetFieldCount());
604 }
605
606 inline OGRFieldDefn *operator[](size_t i)
607 {
608 return m_poFDefn->GetFieldDefn(static_cast<int>(i));
609 }
610
611 inline const OGRFieldDefn *operator[](size_t i) const
612 {
613 return m_poFDefn->GetFieldDefn(static_cast<int>(i));
614 }
615 };
616
618
629 inline Fields GetFields()
630 {
631 return Fields(this);
632 }
633
635 // That method should only be called if there's a guarantee that
636 // GetFieldCount() has been called before
637 int GetFieldCountUnsafe() const
638 {
639 return static_cast<int>(apoFieldDefn.size());
640 }
641
642 // Those methods don't check i is n range.
643 OGRFieldDefn *GetFieldDefnUnsafe(int i)
644 {
645 if (apoFieldDefn.empty())
646 GetFieldDefn(i);
647 return apoFieldDefn[static_cast<std::size_t>(i)].get();
648 }
649
650 const OGRFieldDefn *GetFieldDefnUnsafe(int i) const
651 {
652 if (apoFieldDefn.empty())
653 GetFieldDefn(i);
654 return apoFieldDefn[static_cast<std::size_t>(i)].get();
655 }
656
658
659 virtual void AddFieldDefn(const OGRFieldDefn *);
660 virtual OGRErr DeleteFieldDefn(int iField);
661 virtual OGRErr ReorderFieldDefns(const int *panMap);
662
663 virtual int GetGeomFieldCount() const;
664 virtual OGRGeomFieldDefn *GetGeomFieldDefn(int i);
665 virtual const OGRGeomFieldDefn *GetGeomFieldDefn(int i) const;
666 virtual int GetGeomFieldIndex(const char *) const;
667
669
673 struct CPL_DLL GeomFields
674 {
675 private:
676 OGRFeatureDefn *m_poFDefn;
677
678 public:
679 inline explicit GeomFields(OGRFeatureDefn *poFDefn) : m_poFDefn(poFDefn)
680 {
681 }
682
683 struct CPL_DLL ConstIterator
684 {
685 private:
686 OGRFeatureDefn *m_poFDefn;
687 int m_nIdx;
688
689 public:
690 inline ConstIterator(OGRFeatureDefn *poFDefn, int nIdx)
691 : m_poFDefn(poFDefn), m_nIdx(nIdx)
692 {
693 }
694
695 inline const OGRGeomFieldDefn *operator*() const
696 {
697 return m_poFDefn->GetGeomFieldDefn(m_nIdx);
698 }
699
700 inline ConstIterator &operator++()
701 {
702 m_nIdx++;
703 return *this;
704 }
705
706 inline bool operator!=(const ConstIterator &it) const
707 {
708 return m_nIdx != it.m_nIdx;
709 }
710 };
711
712 inline ConstIterator begin()
713 {
714 return ConstIterator(m_poFDefn, 0);
715 }
716
717 inline ConstIterator end()
718 {
719 return ConstIterator(m_poFDefn, m_poFDefn->GetGeomFieldCount());
720 }
721
722 inline size_t size() const
723 {
724 return static_cast<std::size_t>(m_poFDefn->GetGeomFieldCount());
725 }
726
727 inline OGRGeomFieldDefn *operator[](size_t i)
728 {
729 return m_poFDefn->GetGeomFieldDefn(static_cast<int>(i));
730 }
731
732 inline const OGRGeomFieldDefn *operator[](size_t i) const
733 {
734 return m_poFDefn->GetGeomFieldDefn(static_cast<int>(i));
735 }
736 };
737
739
750 inline GeomFields GetGeomFields()
751 {
752 return GeomFields(this);
753 }
754
755 virtual void AddGeomFieldDefn(const OGRGeomFieldDefn *);
756 virtual void AddGeomFieldDefn(std::unique_ptr<OGRGeomFieldDefn> &&);
757 virtual OGRErr DeleteGeomFieldDefn(int iGeomField);
758
759 virtual OGRwkbGeometryType GetGeomType() const;
760 virtual void SetGeomType(OGRwkbGeometryType);
761
762 virtual OGRFeatureDefn *Clone() const;
763
765 {
766 return CPLAtomicInc(&nRefCount);
767 }
768
770 {
771 return CPLAtomicDec(&nRefCount);
772 }
773
775 {
776 return nRefCount;
777 }
778
779 void Release();
780
781 virtual int IsGeometryIgnored() const;
782 virtual void SetGeometryIgnored(int bIgnore);
783
784 virtual bool IsStyleIgnored() const
785 {
786 return bIgnoreStyle;
787 }
788
789 virtual void SetStyleIgnored(bool bIgnore)
790 {
791 bIgnoreStyle = bIgnore;
792 }
793
794 virtual int IsSame(const OGRFeatureDefn *poOtherFeatureDefn) const;
795
797 void ReserveSpaceForFields(int nFieldCountIn);
799
800 std::vector<int> ComputeMapForSetFrom(const OGRFeatureDefn *poSrcFDefn,
801 bool bForgiving = true) const;
802
803 static OGRFeatureDefn *CreateFeatureDefn(const char *pszName = nullptr);
804 static void DestroyFeatureDefn(OGRFeatureDefn *);
805
809 static inline OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
810 {
811 return reinterpret_cast<OGRFeatureDefnH>(poFeatureDefn);
812 }
813
817 static inline OGRFeatureDefn *FromHandle(OGRFeatureDefnH hFeatureDefn)
818 {
819 return reinterpret_cast<OGRFeatureDefn *>(hFeatureDefn);
820 }
821
822 void Seal(bool bSealFields);
823
824 void Unseal(bool bUnsealFields);
825
827 struct CPL_DLL TemporaryUnsealer
828 {
829 private:
830 OGRFeatureDefn *m_poFeatureDefn = nullptr;
831 bool m_bSealFields = false;
832 CPL_DISALLOW_COPY_ASSIGN(TemporaryUnsealer)
833 public:
834 explicit TemporaryUnsealer(OGRFeatureDefn *poFeatureDefn,
835 bool bSealFields);
836
837 TemporaryUnsealer(TemporaryUnsealer &&) = default;
838 TemporaryUnsealer &operator=(TemporaryUnsealer &&) = default;
839
840 ~TemporaryUnsealer();
841
842 OGRFeatureDefn *operator->()
843 {
844 return m_poFeatureDefn;
845 }
846 };
847
850 TemporaryUnsealer GetTemporaryUnsealer(bool bSealFields = true);
851
852 private:
854};
855
856#ifdef GDAL_COMPILATION
877inline OGRFeatureDefn::TemporaryUnsealer whileUnsealing(OGRFeatureDefn *object,
878 bool bSealFields = true)
879{
880 return object->GetTemporaryUnsealer(bSealFields);
881}
882#endif
883
884/************************************************************************/
885/* OGRFeature */
886/************************************************************************/
887
892class CPL_DLL OGRFeature
893{
894 private:
895 GIntBig nFID;
896 OGRFeatureDefn *poDefn;
897 OGRGeometry **papoGeometries;
898 OGRField *pauFields;
899 char *m_pszNativeData;
900 char *m_pszNativeMediaType;
901
902 bool SetFieldInternal(int i, const OGRField *puValue);
903
904 protected:
906 mutable char *m_pszStyleString;
907 mutable OGRStyleTable *m_poStyleTable;
908 mutable char *m_pszTmpFieldValue;
910
911 bool CopySelfTo(OGRFeature *poNew) const;
912
913 public:
914 explicit OGRFeature(OGRFeatureDefn *);
915 virtual ~OGRFeature();
916
918 class CPL_DLL FieldValue
919 {
920 friend class OGRFeature;
921 struct Private;
922 std::unique_ptr<Private> m_poPrivate;
923
924 FieldValue(OGRFeature *poFeature, int iFieldIndex);
925 FieldValue(const OGRFeature *poFeature, int iFieldIndex);
926 FieldValue(const FieldValue &oOther) = delete;
927 FieldValue &Assign(const FieldValue &oOther);
928
929 public:
931 ~FieldValue();
932
933 FieldValue &operator=(FieldValue &&oOther);
935
937 FieldValue &operator=(const FieldValue &oOther);
939 FieldValue &operator=(int nVal);
941 FieldValue &operator=(GIntBig nVal);
943 FieldValue &operator=(double dfVal);
945 FieldValue &operator=(const char *pszVal);
947 FieldValue &operator=(const std::string &osVal);
949 FieldValue &operator=(const std::vector<int> &oArray);
951 FieldValue &operator=(const std::vector<GIntBig> &oArray);
953 FieldValue &operator=(const std::vector<double> &oArray);
955 FieldValue &operator=(const std::vector<std::string> &oArray);
957 FieldValue &operator=(CSLConstList papszValues);
959 void SetNull();
961 void clear();
962
964 void Unset()
965 {
966 clear();
967 }
968
970 void SetDateTime(int nYear, int nMonth, int nDay, int nHour = 0,
971 int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0);
972
974 int GetIndex() const;
976 const OGRFieldDefn *GetDefn() const;
977
979 const char *GetName() const
980 {
981 return GetDefn()->GetNameRef();
982 }
983
986 {
987 return GetDefn()->GetType();
988 }
989
992 {
993 return GetDefn()->GetSubType();
994 }
995
997 // cppcheck-suppress functionStatic
998 bool empty() const
999 {
1000 return IsUnset();
1001 }
1002
1004 // cppcheck-suppress functionStatic
1005 bool IsUnset() const;
1006
1008 // cppcheck-suppress functionStatic
1009 bool IsNull() const;
1010
1012 const OGRField *GetRawValue() const;
1013
1017 // cppcheck-suppress functionStatic
1018 int GetInteger() const
1019 {
1020 return GetRawValue()->Integer;
1021 }
1022
1026 // cppcheck-suppress functionStatic
1028 {
1029 return GetRawValue()->Integer64;
1030 }
1031
1035 // cppcheck-suppress functionStatic
1036 double GetDouble() const
1037 {
1038 return GetRawValue()->Real;
1039 }
1040
1044 // cppcheck-suppress functionStatic
1045 const char *GetString() const
1046 {
1047 return GetRawValue()->String;
1048 }
1049
1051 bool GetDateTime(int *pnYear, int *pnMonth, int *pnDay, int *pnHour,
1052 int *pnMinute, float *pfSecond, int *pnTZFlag) const;
1053
1055 operator int() const
1056 {
1057 return GetAsInteger();
1058 }
1059
1062 operator GIntBig() const
1063 {
1064 return GetAsInteger64();
1065 }
1066
1068 operator double() const
1069 {
1070 return GetAsDouble();
1071 }
1072
1074 operator const char *() const
1075 {
1076 return GetAsString();
1077 }
1078
1080 operator const std::vector<int> &() const
1081 {
1082 return GetAsIntegerList();
1083 }
1084
1087 operator const std::vector<GIntBig> &() const
1088 {
1089 return GetAsInteger64List();
1090 }
1091
1093 operator const std::vector<double> &() const
1094 {
1095 return GetAsDoubleList();
1096 }
1097
1099 operator const std::vector<std::string> &() const
1100 {
1101 return GetAsStringList();
1102 }
1103
1105 operator CSLConstList() const;
1106
1108 int GetAsInteger() const;
1111 GIntBig GetAsInteger64() const;
1113 double GetAsDouble() const;
1115 const char *GetAsString() const;
1117 const std::vector<int> &GetAsIntegerList() const;
1120 const std::vector<GIntBig> &GetAsInteger64List() const;
1122 const std::vector<double> &GetAsDoubleList() const;
1124 const std::vector<std::string> &GetAsStringList() const;
1125 };
1126
1129 {
1130 friend class OGRFeature;
1131 struct Private;
1132 std::unique_ptr<Private> m_poPrivate;
1133
1134 ConstFieldIterator(const OGRFeature *poSelf, int nPos);
1135
1136 public:
1139 ConstFieldIterator &&oOther) noexcept; // declared but not defined.
1140 // Needed for gcc 5.4 at least
1142 const FieldValue &operator*() const;
1143 ConstFieldIterator &operator++();
1144 bool operator!=(const ConstFieldIterator &it) const;
1146 };
1147
1165 ConstFieldIterator begin() const;
1167 ConstFieldIterator end() const;
1168
1169 const FieldValue operator[](int iField) const;
1170 FieldValue operator[](int iField);
1171
1174 class FieldNotFoundException : public std::exception
1175 {
1176 };
1177
1178 const FieldValue operator[](const char *pszFieldName) const;
1179 FieldValue operator[](const char *pszFieldName);
1180
1182 {
1183 return poDefn;
1184 }
1185
1187 {
1188 return poDefn;
1189 }
1190
1192 void SetFDefnUnsafe(OGRFeatureDefn *poNewFDefn);
1194
1195 OGRErr SetGeometryDirectly(OGRGeometry *);
1196 OGRErr SetGeometry(const OGRGeometry *);
1197 OGRGeometry *GetGeometryRef();
1198 const OGRGeometry *GetGeometryRef() const;
1199 OGRGeometry *StealGeometry() CPL_WARN_UNUSED_RESULT;
1200
1201 int GetGeomFieldCount() const
1202 {
1203 return poDefn->GetGeomFieldCount();
1204 }
1205
1207 {
1208 return poDefn->GetGeomFieldDefn(iField);
1209 }
1210
1211 const OGRGeomFieldDefn *GetGeomFieldDefnRef(int iField) const
1212 {
1213 return poDefn->GetGeomFieldDefn(iField);
1214 }
1215
1216 int GetGeomFieldIndex(const char *pszName) const
1217 {
1218 return poDefn->GetGeomFieldIndex(pszName);
1219 }
1220
1221 OGRGeometry *GetGeomFieldRef(int iField);
1222 const OGRGeometry *GetGeomFieldRef(int iField) const;
1223 OGRGeometry *StealGeometry(int iField);
1224 OGRGeometry *GetGeomFieldRef(const char *pszFName);
1225 const OGRGeometry *GetGeomFieldRef(const char *pszFName) const;
1226 OGRErr SetGeomFieldDirectly(int iField, OGRGeometry *);
1227 OGRErr SetGeomField(int iField, const OGRGeometry *);
1228
1229 void Reset();
1230
1231 OGRFeature *Clone() const CPL_WARN_UNUSED_RESULT;
1232 virtual OGRBoolean Equal(const OGRFeature *poFeature) const;
1233
1234 int GetFieldCount() const
1235 {
1236 return poDefn->GetFieldCount();
1237 }
1238
1239 const OGRFieldDefn *GetFieldDefnRef(int iField) const
1240 {
1241 return poDefn->GetFieldDefn(iField);
1242 }
1243
1245 {
1246 return poDefn->GetFieldDefn(iField);
1247 }
1248
1249 int GetFieldIndex(const char *pszName) const
1250 {
1251 return poDefn->GetFieldIndex(pszName);
1252 }
1253
1254 int IsFieldSet(int iField) const;
1255
1256 void UnsetField(int iField);
1257
1258 bool IsFieldNull(int iField) const;
1259
1260 void SetFieldNull(int iField);
1261
1262 bool IsFieldSetAndNotNull(int iField) const;
1263
1265 {
1266 return pauFields + i;
1267 }
1268
1269 const OGRField *GetRawFieldRef(int i) const
1270 {
1271 return pauFields + i;
1272 }
1273
1274 int GetFieldAsInteger(int i) const;
1275 GIntBig GetFieldAsInteger64(int i) const;
1276 double GetFieldAsDouble(int i) const;
1277 const char *GetFieldAsString(int i) const;
1278 const char *GetFieldAsISO8601DateTime(int i,
1279 CSLConstList papszOptions) const;
1280 const int *GetFieldAsIntegerList(int i, int *pnCount) const;
1281 const GIntBig *GetFieldAsInteger64List(int i, int *pnCount) const;
1282 const double *GetFieldAsDoubleList(int i, int *pnCount) const;
1283 char **GetFieldAsStringList(int i) const;
1284 GByte *GetFieldAsBinary(int i, int *pnCount) const;
1285 int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay,
1286 int *pnHour, int *pnMinute, int *pnSecond,
1287 int *pnTZFlag) const;
1288 int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay,
1289 int *pnHour, int *pnMinute, float *pfSecond,
1290 int *pnTZFlag) const;
1291 char *GetFieldAsSerializedJSon(int i) const;
1292
1294 bool IsFieldSetUnsafe(int i) const
1295 {
1296 return !(pauFields[i].Set.nMarker1 == OGRUnsetMarker &&
1297 pauFields[i].Set.nMarker2 == OGRUnsetMarker &&
1298 pauFields[i].Set.nMarker3 == OGRUnsetMarker);
1299 }
1300
1301 bool IsFieldNullUnsafe(int i) const
1302 {
1303 return (pauFields[i].Set.nMarker1 == OGRNullMarker &&
1304 pauFields[i].Set.nMarker2 == OGRNullMarker &&
1305 pauFields[i].Set.nMarker3 == OGRNullMarker);
1306 }
1307
1308 bool IsFieldSetAndNotNullUnsafe(int i) const
1309 {
1310 return IsFieldSetUnsafe(i) && !IsFieldNullUnsafe(i);
1311 }
1312
1313 // Those methods should only be called on a field that is of the type
1314 // consistent with the value, and that is set.
1315 int GetFieldAsIntegerUnsafe(int i) const
1316 {
1317 return pauFields[i].Integer;
1318 }
1319
1320 GIntBig GetFieldAsInteger64Unsafe(int i) const
1321 {
1322 return pauFields[i].Integer64;
1323 }
1324
1325 double GetFieldAsDoubleUnsafe(int i) const
1326 {
1327 return pauFields[i].Real;
1328 }
1329
1330 const char *GetFieldAsStringUnsafe(int i) const
1331 {
1332 return pauFields[i].String;
1333 }
1334
1336
1337 int GetFieldAsInteger(const char *pszFName) const
1338 {
1339 return GetFieldAsInteger(GetFieldIndex(pszFName));
1340 }
1341
1342 GIntBig GetFieldAsInteger64(const char *pszFName) const
1343 {
1344 return GetFieldAsInteger64(GetFieldIndex(pszFName));
1345 }
1346
1347 double GetFieldAsDouble(const char *pszFName) const
1348 {
1349 return GetFieldAsDouble(GetFieldIndex(pszFName));
1350 }
1351
1352 const char *GetFieldAsString(const char *pszFName) const
1353 {
1354 return GetFieldAsString(GetFieldIndex(pszFName));
1355 }
1356
1357 const char *GetFieldAsISO8601DateTime(const char *pszFName,
1358 CSLConstList papszOptions) const
1359 {
1360 return GetFieldAsISO8601DateTime(GetFieldIndex(pszFName), papszOptions);
1361 }
1362
1363 const int *GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
1364 {
1365 return GetFieldAsIntegerList(GetFieldIndex(pszFName), pnCount);
1366 }
1367
1368 const GIntBig *GetFieldAsInteger64List(const char *pszFName,
1369 int *pnCount) const
1370 {
1371 return GetFieldAsInteger64List(GetFieldIndex(pszFName), pnCount);
1372 }
1373
1374 const double *GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
1375 {
1376 return GetFieldAsDoubleList(GetFieldIndex(pszFName), pnCount);
1377 }
1378
1379 char **GetFieldAsStringList(const char *pszFName) const
1380 {
1381 return GetFieldAsStringList(GetFieldIndex(pszFName));
1382 }
1383
1384 void SetField(int i, int nValue);
1385 void SetField(int i, GIntBig nValue);
1386 void SetField(int i, double dfValue);
1387 void SetField(int i, const char *pszValue);
1388 void SetField(int i, int nCount, const int *panValues);
1389 void SetField(int i, int nCount, const GIntBig *panValues);
1390 void SetField(int i, int nCount, const double *padfValues);
1391 void SetField(int i, const char *const *papszValues);
1392 void SetField(int i, const OGRField *puValue);
1393 void SetField(int i, int nCount, const void *pabyBinary);
1394 void SetField(int i, int nYear, int nMonth, int nDay, int nHour = 0,
1395 int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0);
1396
1398 // Those methods should only be called on a field that is of the type
1399 // consistent with the value, and in a unset state.
1400 void SetFieldSameTypeUnsafe(int i, int nValue)
1401 {
1402 pauFields[i].Integer = nValue;
1403 pauFields[i].Set.nMarker2 = 0;
1404 pauFields[i].Set.nMarker3 = 0;
1405 }
1406
1407 void SetFieldSameTypeUnsafe(int i, GIntBig nValue)
1408 {
1409 pauFields[i].Integer64 = nValue;
1410 }
1411
1412 void SetFieldSameTypeUnsafe(int i, double dfValue)
1413 {
1414 pauFields[i].Real = dfValue;
1415 }
1416
1417 void SetFieldSameTypeUnsafe(int i, char *pszValueTransferred)
1418 {
1419 pauFields[i].String = pszValueTransferred;
1420 }
1421
1423
1424 void SetField(const char *pszFName, int nValue)
1425 {
1426 SetField(GetFieldIndex(pszFName), nValue);
1427 }
1428
1429 void SetField(const char *pszFName, GIntBig nValue)
1430 {
1431 SetField(GetFieldIndex(pszFName), nValue);
1432 }
1433
1434 void SetField(const char *pszFName, double dfValue)
1435 {
1436 SetField(GetFieldIndex(pszFName), dfValue);
1437 }
1438
1439 void SetField(const char *pszFName, const char *pszValue)
1440 {
1441 SetField(GetFieldIndex(pszFName), pszValue);
1442 }
1443
1444 void SetField(const char *pszFName, int nCount, const int *panValues)
1445 {
1446 SetField(GetFieldIndex(pszFName), nCount, panValues);
1447 }
1448
1449 void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
1450 {
1451 SetField(GetFieldIndex(pszFName), nCount, panValues);
1452 }
1453
1454 void SetField(const char *pszFName, int nCount, const double *padfValues)
1455 {
1456 SetField(GetFieldIndex(pszFName), nCount, padfValues);
1457 }
1458
1459 void SetField(const char *pszFName, const char *const *papszValues)
1460 {
1461 SetField(GetFieldIndex(pszFName), papszValues);
1462 }
1463
1464 void SetField(const char *pszFName, const OGRField *puValue)
1465 {
1466 SetField(GetFieldIndex(pszFName), puValue);
1467 }
1468
1469 void SetField(const char *pszFName, int nYear, int nMonth, int nDay,
1470 int nHour = 0, int nMinute = 0, float fSecond = 0.f,
1471 int nTZFlag = 0)
1472 {
1473 SetField(GetFieldIndex(pszFName), nYear, nMonth, nDay, nHour, nMinute,
1474 fSecond, nTZFlag);
1475 }
1476
1478 {
1479 return nFID;
1480 }
1481
1482 virtual OGRErr SetFID(GIntBig nFIDIn);
1483
1484 void DumpReadable(FILE *, CSLConstList papszOptions = nullptr) const;
1485 std::string DumpReadableAsString(CSLConstList papszOptions = nullptr) const;
1486
1487 OGRErr SetFrom(const OGRFeature *, int bForgiving = TRUE);
1488 OGRErr SetFrom(const OGRFeature *, const int *panMap, int bForgiving = TRUE,
1489 bool bUseISO8601ForDateTimeAsString = false);
1490 OGRErr SetFieldsFrom(const OGRFeature *, const int *panMap,
1491 int bForgiving = TRUE,
1492 bool bUseISO8601ForDateTimeAsString = false);
1493
1495 OGRErr RemapFields(OGRFeatureDefn *poNewDefn, const int *panRemapSource);
1496 void AppendField();
1497 OGRErr RemapGeomFields(OGRFeatureDefn *poNewDefn,
1498 const int *panRemapSource);
1500
1501 int Validate(int nValidateFlags, int bEmitError) const;
1502 void FillUnsetWithDefault(int bNotNullableOnly, char **papszOptions);
1503
1504 bool SerializeToBinary(std::vector<GByte> &abyBuffer) const;
1505 bool DeserializeFromBinary(const GByte *pabyBuffer, size_t nSize);
1506
1507 virtual const char *GetStyleString() const;
1508 virtual void SetStyleString(const char *);
1509 virtual void SetStyleStringDirectly(char *);
1510
1515 {
1516 return m_poStyleTable;
1517 } /* f.i.x.m.e: add a const qualifier for return type */
1518
1519 virtual void SetStyleTable(OGRStyleTable *poStyleTable);
1520 virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable);
1521
1522 const char *GetNativeData() const
1523 {
1524 return m_pszNativeData;
1525 }
1526
1527 const char *GetNativeMediaType() const
1528 {
1529 return m_pszNativeMediaType;
1530 }
1531
1532 void SetNativeData(const char *pszNativeData);
1533 void SetNativeMediaType(const char *pszNativeMediaType);
1534
1535 static OGRFeature *CreateFeature(OGRFeatureDefn *);
1536 static void DestroyFeature(OGRFeature *);
1537
1541 static inline OGRFeatureH ToHandle(OGRFeature *poFeature)
1542 {
1543 return reinterpret_cast<OGRFeatureH>(poFeature);
1544 }
1545
1549 static inline OGRFeature *FromHandle(OGRFeatureH hFeature)
1550 {
1551 return reinterpret_cast<OGRFeature *>(hFeature);
1552 }
1553
1554 private:
1556};
1557
1559struct CPL_DLL OGRFeatureUniquePtrDeleter
1560{
1561 void operator()(OGRFeature *) const;
1562};
1563
1565
1569typedef std::unique_ptr<OGRFeature, OGRFeatureUniquePtrDeleter>
1571
1573
1574inline OGRFeature::ConstFieldIterator begin(const OGRFeature *poFeature)
1575{
1576 return poFeature->begin();
1577}
1578
1580inline OGRFeature::ConstFieldIterator end(const OGRFeature *poFeature)
1581{
1582 return poFeature->end();
1583}
1584
1587begin(const OGRFeatureUniquePtr &poFeature)
1588{
1589 return poFeature->begin();
1590}
1591
1594{
1595 return poFeature->end();
1596}
1597
1599
1600/************************************************************************/
1601/* OGRFieldDomain */
1602/************************************************************************/
1603
1604/* clang-format off */
1624/* clang-format on */
1625
1626class CPL_DLL OGRFieldDomain
1627{
1628 protected:
1630 std::string m_osName;
1631 std::string m_osDescription;
1632 OGRFieldDomainType m_eDomainType;
1633 OGRFieldType m_eFieldType;
1634 OGRFieldSubType m_eFieldSubType;
1637
1638 OGRFieldDomain(const std::string &osName, const std::string &osDescription,
1639 OGRFieldDomainType eDomainType, OGRFieldType eFieldType,
1640 OGRFieldSubType eFieldSubType);
1643 public:
1648 virtual ~OGRFieldDomain() = 0;
1649
1654 virtual OGRFieldDomain *Clone() const = 0;
1655
1660 const std::string &GetName() const
1661 {
1662 return m_osName;
1663 }
1664
1670 const std::string &GetDescription() const
1671 {
1672 return m_osDescription;
1673 }
1674
1680 {
1681 return m_eDomainType;
1682 }
1683
1689 {
1690 return m_eFieldType;
1691 }
1692
1698 {
1699 return m_eFieldSubType;
1700 }
1701
1703 static inline OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)
1704 {
1705 return reinterpret_cast<OGRFieldDomainH>(poFieldDomain);
1706 }
1707
1709 static inline OGRFieldDomain *FromHandle(OGRFieldDomainH hFieldDomain)
1710 {
1711 return reinterpret_cast<OGRFieldDomain *>(hFieldDomain);
1712 }
1713
1719 {
1720 return m_eSplitPolicy;
1721 }
1722
1728 {
1729 m_eSplitPolicy = policy;
1730 }
1731
1737 {
1738 return m_eMergePolicy;
1739 }
1740
1746 {
1747 m_eMergePolicy = policy;
1748 }
1749};
1750
1757class CPL_DLL OGRCodedFieldDomain final : public OGRFieldDomain
1758{
1759 private:
1760 std::vector<OGRCodedValue> m_asValues{};
1761
1762 OGRCodedFieldDomain(const OGRCodedFieldDomain &) = delete;
1763 OGRCodedFieldDomain &operator=(const OGRCodedFieldDomain &) = delete;
1764
1765 public:
1781 OGRCodedFieldDomain(const std::string &osName,
1782 const std::string &osDescription,
1783 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1784 std::vector<OGRCodedValue> &&asValues);
1785
1786 ~OGRCodedFieldDomain() override;
1787
1788 OGRCodedFieldDomain *Clone() const override;
1789
1796 {
1797 return m_asValues.data();
1798 }
1799};
1800
1803class CPL_DLL OGRRangeFieldDomain final : public OGRFieldDomain
1804{
1805 private:
1806 OGRField m_sMin;
1807 OGRField m_sMax;
1808 bool m_bMinIsInclusive;
1809 bool m_bMaxIsInclusive;
1810
1811 OGRRangeFieldDomain(const OGRRangeFieldDomain &) = delete;
1812 OGRRangeFieldDomain &operator=(const OGRRangeFieldDomain &) = delete;
1813
1814 public:
1842 OGRRangeFieldDomain(const std::string &osName,
1843 const std::string &osDescription,
1844 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1845 const OGRField &sMin, bool bMinIsInclusive,
1846 const OGRField &sMax, bool bMaxIsInclusive);
1847
1848 OGRRangeFieldDomain *Clone() const override
1849 {
1850 auto poDomain = new OGRRangeFieldDomain(
1851 m_osName, m_osDescription, m_eFieldType, m_eFieldSubType, m_sMin,
1852 m_bMinIsInclusive, m_sMax, m_bMaxIsInclusive);
1853 poDomain->SetMergePolicy(m_eMergePolicy);
1854 poDomain->SetSplitPolicy(m_eSplitPolicy);
1855 return poDomain;
1856 }
1857
1871 const OGRField &GetMin(bool &bIsInclusiveOut) const
1872 {
1873 bIsInclusiveOut = m_bMinIsInclusive;
1874 return m_sMin;
1875 }
1876
1890 const OGRField &GetMax(bool &bIsInclusiveOut) const
1891 {
1892 bIsInclusiveOut = m_bMaxIsInclusive;
1893 return m_sMax;
1894 }
1895};
1896
1901class CPL_DLL OGRGlobFieldDomain final : public OGRFieldDomain
1902{
1903 private:
1904 std::string m_osGlob;
1905
1906 OGRGlobFieldDomain(const OGRGlobFieldDomain &) = delete;
1907 OGRGlobFieldDomain &operator=(const OGRGlobFieldDomain &) = delete;
1908
1909 public:
1920 OGRGlobFieldDomain(const std::string &osName,
1921 const std::string &osDescription,
1922 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1923 const std::string &osBlob);
1924
1925 OGRGlobFieldDomain *Clone() const override
1926 {
1927 auto poDomain = new OGRGlobFieldDomain(
1928 m_osName, m_osDescription, m_eFieldType, m_eFieldSubType, m_osGlob);
1929 poDomain->SetMergePolicy(m_eMergePolicy);
1930 poDomain->SetSplitPolicy(m_eSplitPolicy);
1931 return poDomain;
1932 }
1933
1938 const std::string &GetGlob() const
1939 {
1940 return m_osGlob;
1941 }
1942};
1943
1944/************************************************************************/
1945/* OGRFeatureQuery */
1946/************************************************************************/
1947
1949class OGRLayer;
1950class swq_expr_node;
1951class swq_custom_func_registrar;
1952struct swq_evaluation_context;
1953
1954class CPL_DLL OGRFeatureQuery
1955{
1956 private:
1957 OGRFeatureDefn *poTargetDefn;
1958 void *pSWQExpr;
1959 swq_evaluation_context *m_psContext = nullptr;
1960
1961 char **FieldCollector(void *, char **);
1962
1963 static GIntBig *EvaluateAgainstIndices(const swq_expr_node *, OGRLayer *,
1964 GIntBig &nFIDCount);
1965
1966 static int CanUseIndex(const swq_expr_node *, OGRLayer *);
1967
1968 OGRErr Compile(OGRLayer *, OGRFeatureDefn *, const char *, int bCheck,
1969 swq_custom_func_registrar *poCustomFuncRegistrar);
1970
1971 CPL_DISALLOW_COPY_ASSIGN(OGRFeatureQuery)
1972
1973 public:
1974 OGRFeatureQuery();
1975 ~OGRFeatureQuery();
1976
1977 OGRErr Compile(OGRLayer *, const char *, int bCheck = TRUE,
1978 swq_custom_func_registrar *poCustomFuncRegistrar = nullptr);
1979 OGRErr Compile(OGRFeatureDefn *, const char *, int bCheck = TRUE,
1980 swq_custom_func_registrar *poCustomFuncRegistrar = nullptr);
1981 int Evaluate(OGRFeature *);
1982
1983 GIntBig *EvaluateAgainstIndices(OGRLayer *, OGRErr *);
1984
1985 int CanUseIndex(OGRLayer *);
1986
1987 char **GetUsedFields();
1988
1989 void *GetSWQExpr()
1990 {
1991 return pSWQExpr;
1992 }
1993};
1994
1996
1997#endif /* ndef OGR_FEATURE_H_INCLUDED */
Definition of a coded / enumerated field domain.
Definition: ogr_feature.h:1758
const OGRCodedValue * GetEnumeration() const
Get the enumeration as (code, value) pairs.
Definition: ogr_feature.h:1795
Definition of a feature class or feature layer.
Definition: ogr_feature.h:517
int Reference()
Increments the reference count by one.
Definition: ogr_feature.h:764
virtual int GetFieldCount() const
Fetch number of fields on this feature.
Definition: ogrfeaturedefn.cpp:277
virtual OGRFieldDefn * GetFieldDefn(int i)
Fetch field definition.
Definition: ogrfeaturedefn.cpp:321
GeomFields GetGeomFields()
Return an object that can be used to iterate over geometry fields.
Definition: ogr_feature.h:750
virtual bool IsStyleIgnored() const
Determine whether the style can be omitted when fetching features.
Definition: ogr_feature.h:784
Fields GetFields()
Return an object that can be used to iterate over non-geometry fields.
Definition: ogr_feature.h:629
int Dereference()
Decrements the reference count by one.
Definition: ogr_feature.h:769
static OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
Convert a OGRFeatureDefn* to a OGRFeatureDefnH.
Definition: ogr_feature.h:809
static OGRFeatureDefn * FromHandle(OGRFeatureDefnH hFeatureDefn)
Convert a OGRFeatureDefnH to a OGRFeatureDefn*.
Definition: ogr_feature.h:817
virtual OGRGeomFieldDefn * GetGeomFieldDefn(int i)
Fetch geometry field definition.
Definition: ogrfeaturedefn.cpp:671
virtual int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition: ogrfeaturedefn.cpp:622
virtual int GetFieldIndex(const char *) const
Find field by name.
Definition: ogrfeaturedefn.cpp:1230
int GetReferenceCount() const
Fetch current reference count.
Definition: ogr_feature.h:774
virtual int GetGeomFieldIndex(const char *) const
Find geometry field by name.
Definition: ogrfeaturedefn.cpp:921
virtual void SetStyleIgnored(bool bIgnore)
Set whether the style can be omitted when fetching features.
Definition: ogr_feature.h:789
Field value iterator class.
Definition: ogr_feature.h:1129
Exception raised by operator[](const char*) when a field is not found.
Definition: ogr_feature.h:1175
Field value.
Definition: ogr_feature.h:919
bool empty() const
Return whether the field value is unset/empty.
Definition: ogr_feature.h:998
int GetInteger() const
Return the integer value.
Definition: ogr_feature.h:1018
OGRFieldType GetType() const
Return field type.
Definition: ogr_feature.h:985
void Unset()
Unset the field.
Definition: ogr_feature.h:964
double GetDouble() const
Return the double value.
Definition: ogr_feature.h:1036
const char * GetName() const
Return field name.
Definition: ogr_feature.h:979
GIntBig GetInteger64() const
Return the 64-bit integer value.
Definition: ogr_feature.h:1027
OGRFieldSubType GetSubType() const
Return field subtype.
Definition: ogr_feature.h:991
const char * GetString() const
Return the string value.
Definition: ogr_feature.h:1045
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:893
OGRFeatureDefn * GetDefnRef()
Fetch feature definition.
Definition: ogr_feature.h:1181
const char * GetFieldAsISO8601DateTime(const char *pszFName, CSLConstList papszOptions) const
Fetch OFTDateTime field value as a ISO8601 representation.
Definition: ogr_feature.h:1357
static OGRFeatureH ToHandle(OGRFeature *poFeature)
Convert a OGRFeature* to a OGRFeatureH.
Definition: ogr_feature.h:1541
char ** GetFieldAsStringList(const char *pszFName) const
Fetch field value as a list of strings.
Definition: ogr_feature.h:1379
ConstFieldIterator end() const
Return end of field value iterator.
Definition: ogrfeature.cpp:8289
ConstFieldIterator begin() const
Return begin of field value iterator.
Definition: ogrfeature.cpp:8284
void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
Set field to list of 64 bit integers value.
Definition: ogr_feature.h:1449
const OGRFeatureDefn * GetDefnRef() const
Fetch feature definition.
Definition: ogr_feature.h:1186
OGRFieldDefn * GetFieldDefnRef(int iField)
Fetch definition for this field.
Definition: ogr_feature.h:1244
const double * GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
Fetch field value as a list of doubles.
Definition: ogr_feature.h:1374
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:1444
void SetField(const char *pszFName, GIntBig nValue)
Set field to 64 bit integer value.
Definition: ogr_feature.h:1429
void SetField(const char *pszFName, const char *pszValue)
Set field to string value.
Definition: ogr_feature.h:1439
void SetField(const char *pszFName, int nValue)
Set field to integer value.
Definition: ogr_feature.h:1424
const OGRFieldDefn * GetFieldDefnRef(int iField) const
Fetch definition for this field.
Definition: ogr_feature.h:1239
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:1469
const OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField) const
Fetch definition for this geometry field.
Definition: ogr_feature.h:1211
const char * GetNativeData() const
Returns the native data for the feature.
Definition: ogr_feature.h:1522
int GetFieldIndex(const char *pszName) const
Fetch the field index given field name.
Definition: ogr_feature.h:1249
int GetGeomFieldIndex(const char *pszName) const
Fetch the geometry field index given geometry field name.
Definition: ogr_feature.h:1216
OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField)
Fetch definition for this geometry field.
Definition: ogr_feature.h:1206
GIntBig GetFieldAsInteger64(const char *pszFName) const
Fetch field value as integer 64 bit.
Definition: ogr_feature.h:1342
const int * GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
Fetch field value as a list of integers.
Definition: ogr_feature.h:1363
void SetField(const char *pszFName, double dfValue)
Set field to double value.
Definition: ogr_feature.h:1434
const char * GetFieldAsString(const char *pszFName) const
Fetch field value as a string.
Definition: ogr_feature.h:1352
void SetField(const char *pszFName, const char *const *papszValues)
This method currently on has an effect of OFTStringList fields.
Definition: ogr_feature.h:1459
const OGRField * GetRawFieldRef(int i) const
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:1269
int GetFieldAsInteger(const char *pszFName) const
Fetch field value as integer.
Definition: ogr_feature.h:1337
const char * GetNativeMediaType() const
Returns the native media type for the feature.
Definition: ogr_feature.h:1527
void SetField(const char *pszFName, const OGRField *puValue)
Set field.
Definition: ogr_feature.h:1464
GIntBig GetFID() const
Get feature identifier.
Definition: ogr_feature.h:1477
OGRField * GetRawFieldRef(int i)
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:1264
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:1454
virtual OGRStyleTable * GetStyleTable() const
Return style table.
Definition: ogr_feature.h:1514
double GetFieldAsDouble(const char *pszFName) const
Fetch field value as a double.
Definition: ogr_feature.h:1347
static OGRFeature * FromHandle(OGRFeatureH hFeature)
Convert a OGRFeatureH to a OGRFeature*.
Definition: ogr_feature.h:1549
const GIntBig * GetFieldAsInteger64List(const char *pszFName, int *pnCount) const
Fetch field value as a list of 64 bit integers.
Definition: ogr_feature.h:1368
Definition of an attribute of an OGRFeatureDefn.
Definition: ogr_feature.h:111
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:141
void Unseal()
Unseal a OGRFieldDefn.
Definition: ogrfielddefn.cpp:2120
int IsNullable() const
Return whether this field can receive null values.
Definition: ogr_feature.h:217
void Seal()
Seal a OGRFieldDefn.
Definition: ogrfielddefn.cpp:2101
int IsUnique() const
Return whether this field has a unique constraint.
Definition: ogr_feature.h:224
OGRFieldSubType GetSubType() const
Fetch subtype of this field.
Definition: ogr_feature.h:161
OGRJustification GetJustify() const
Get the justification for this field.
Definition: ogr_feature.h:169
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:212
int GetPrecision() const
Get the formatting precision for this field.
Definition: ogr_feature.h:186
OGRFieldType GetType() const
Fetch type of this field.
Definition: ogr_feature.h:153
int GetWidth() const
Get the formatting width for this field.
Definition: ogr_feature.h:179
const std::string & GetComment() const
Return the (optional) comment for this field.
Definition: ogr_feature.h:238
int GetTZFlag() const
Get the time zone flag.
Definition: ogr_feature.h:193
void SetJustify(OGRJustification eJustifyIn)
Set the justification for this field.
Definition: ogr_feature.h:174
const char * GetAlternativeNameRef() const
Fetch the alternative name (or "alias") for this field.
Definition: ogr_feature.h:148
static OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
Convert a OGRFieldDefn* to a OGRFieldDefnH.
Definition: ogr_feature.h:250
const std::string & GetDomainName() const
Return the name of the field domain for this field.
Definition: ogr_feature.h:231
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:207
static OGRFieldDefn * FromHandle(OGRFieldDefnH hFieldDefn)
Convert a OGRFieldDefnH to a OGRFieldDefn*.
Definition: ogr_feature.h:258
Definition of a field domain.
Definition: ogr_feature.h:1627
OGRFieldDomainMergePolicy GetMergePolicy() const
Get the merge policy.
Definition: ogr_feature.h:1736
void SetMergePolicy(OGRFieldDomainMergePolicy policy)
Set the merge policy.
Definition: ogr_feature.h:1745
static OGRFieldDomain * FromHandle(OGRFieldDomainH hFieldDomain)
Convert a OGRFieldDomainH to a OGRFieldDomain*.
Definition: ogr_feature.h:1709
virtual OGRFieldDomain * Clone() const =0
Clone.
OGRFieldSubType GetFieldSubType() const
Get the field subtype.
Definition: ogr_feature.h:1697
const std::string & GetName() const
Get the name of the field domain.
Definition: ogr_feature.h:1660
virtual ~OGRFieldDomain()=0
Destructor.
const std::string & GetDescription() const
Get the description of the field domain.
Definition: ogr_feature.h:1670
OGRFieldDomainSplitPolicy GetSplitPolicy() const
Get the split policy.
Definition: ogr_feature.h:1718
static OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)
Convert a OGRFieldDomain* to a OGRFieldDomainH.
Definition: ogr_feature.h:1703
OGRFieldType GetFieldType() const
Get the field type.
Definition: ogr_feature.h:1688
OGRFieldDomainType GetDomainType() const
Get the type of the field domain.
Definition: ogr_feature.h:1679
void SetSplitPolicy(OGRFieldDomainSplitPolicy policy)
Set the split policy.
Definition: ogr_feature.h:1727
Definition of a geometry field of an OGRFeatureDefn.
Definition: ogr_feature.h:346
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:389
void Seal()
Seal a OGRGeomFieldDefn.
Definition: ogrgeomfielddefn.cpp:841
void Unseal()
Unseal a OGRGeomFieldDefn.
Definition: ogrgeomfielddefn.cpp:860
static OGRGeomFieldDefn * FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
Convert a OGRGeomFieldDefnH to a OGRGeomFieldDefn*.
Definition: ogr_feature.h:421
int IsNullable() const
Return whether this geometry field can receive null values.
Definition: ogr_feature.h:394
OGRwkbGeometryType GetType() const
Fetch geometry type of this field.
Definition: ogr_feature.h:374
const OGRGeomCoordinatePrecision & GetCoordinatePrecision() const
Return the coordinate precision associated to this geometry field.
Definition: ogr_feature.h:401
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:384
static OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
Convert a OGRGeomFieldDefn* to a OGRGeomFieldDefnH.
Definition: ogr_feature.h:413
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:369
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:377
Definition of a field domain for field content validated by a glob.
Definition: ogr_feature.h:1902
OGRGlobFieldDomain * Clone() const override
Clone.
Definition: ogr_feature.h:1925
const std::string & GetGlob() const
Get the glob expression.
Definition: ogr_feature.h:1938
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:74
Definition of a numeric field domain with a range of validity for values.
Definition: ogr_feature.h:1804
OGRRangeFieldDomain * Clone() const override
Clone.
Definition: ogr_feature.h:1848
const OGRField & GetMax(bool &bIsInclusiveOut) const
Get the maximum value.
Definition: ogr_feature.h:1890
const OGRField & GetMin(bool &bIsInclusiveOut) const
Get the minimum value.
Definition: ogr_feature.h:1871
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:169
This class represents a style table.
Definition: ogr_featurestyle.h:86
#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:1042
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1183
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:976
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:185
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:215
#define OGRUnsetMarker
Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for a unset field.
Definition: ogr_core.h:868
#define OGR_TZFLAG_UNKNOWN
Time zone flag indicating unknown timezone.
Definition: ogr_core.h:882
int OGRBoolean
Type for a OGR boolean.
Definition: ogr_core.h:404
OGRFieldSubType
List of field subtypes.
Definition: ogr_core.h:821
OGRFieldDomainMergePolicy
Merge policy for field domains.
Definition: ogr_core.h:1288
@ OFDMP_DEFAULT_VALUE
Default value.
Definition: ogr_core.h:1290
OGRFieldDomainType
Type of field domain.
Definition: ogr_core.h:1253
OGRJustification
Display justification for field values.
Definition: ogr_core.h:846
OGRFieldType
List of feature field types.
Definition: ogr_core.h:793
#define OGRNullMarker
Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for a null field.
Definition: ogr_core.h:876
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:416
@ wkbUnknown
unknown type, non-standard
Definition: ogr_core.h:417
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:387
OGRFieldDomainSplitPolicy
Split policy for field domains.
Definition: ogr_core.h:1270
@ OFDSP_DEFAULT_VALUE
Default value.
Definition: ogr_core.h:1272
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:1570
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_feature.h:63
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_feature.h:65
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_feature.h:67
struct OGRFieldDomainHS * OGRFieldDomainH
Opaque type for a field domain definition (OGRFieldDomain)
Definition: ogr_feature.h:75
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_feature.h:72
void * OGRStyleTableH
Opaque type for a style table (OGRStyleTable)
Definition: ogr_feature.h:69
Simple feature style classes.
Simple feature geometry classes.
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:426
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:434
Associates a code and a value.
Definition: ogr_core.h:1240
Geometry coordinate precision.
Definition: ogr_geomcoordinateprecision.h:50
OGRFeature field attribute value union.
Definition: ogr_core.h:910