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
38 #include <cstddef>
39
40 #include <exception>
41 #include <memory>
42 #include <string>
43 #include <vector>
44
51 #ifndef DEFINE_OGRFeatureH
52
53 #define DEFINE_OGRFeatureH
54
55 #ifdef DEBUG
56 typedef struct OGRFieldDefnHS *OGRFieldDefnH;
57 typedef struct OGRFeatureDefnHS *OGRFeatureDefnH;
58 typedef struct OGRFeatureHS *OGRFeatureH;
59 typedef struct OGRStyleTableHS *OGRStyleTableH;
60 #else
61
62 typedef void *OGRFieldDefnH;
64 typedef void *OGRFeatureDefnH;
66 typedef void *OGRFeatureH;
68 typedef void *OGRStyleTableH;
69 #endif
70
71 typedef struct OGRGeomFieldDefnHS *OGRGeomFieldDefnH;
72
74 typedef struct OGRFieldDomainHS *OGRFieldDomainH;
75 #endif /* DEFINE_OGRFeatureH */
76
77 class OGRStyleTable;
78
79 /************************************************************************/
80 /* OGRFieldDefn */
81 /************************************************************************/
82
103 class CPL_DLL OGRFieldDefn
104 {
105 private:
106 char *pszName;
107 char *pszAlternativeName;
108 OGRFieldType eType;
109 OGRJustification eJustify;
110 int nWidth; // Zero is variable.
111 int nPrecision;
112 char *pszDefault;
113
114 int bIgnore;
115 OGRFieldSubType eSubType;
116
117 int bNullable;
118 int bUnique;
119
120 std::string m_osDomainName{}; // field domain name. Might be empty
121
122 std::string m_osComment{}; // field comment. Might be empty
123
124 int m_nTZFlag = OGR_TZFLAG_UNKNOWN;
125
126 public:
127 OGRFieldDefn(const char *, OGRFieldType);
128 explicit OGRFieldDefn(const OGRFieldDefn *);
129 ~OGRFieldDefn();
130
131 void SetName(const char *);
132 const char *GetNameRef() const
133 {
134 return pszName;
135 }
136
137 void SetAlternativeName(const char *);
138 const char *GetAlternativeNameRef() const
139 {
140 return pszAlternativeName;
141 }
142
143 OGRFieldType GetType() const
144 {
145 return eType;
146 }
147 void SetType(OGRFieldType eTypeIn);
148 static const char *GetFieldTypeName(OGRFieldType);
149
150 OGRFieldSubType GetSubType() const
151 {
152 return eSubType;
153 }
154 void SetSubType(OGRFieldSubType eSubTypeIn);
155 static const char *GetFieldSubTypeName(OGRFieldSubType);
156
157 OGRJustification GetJustify() const
158 {
159 return eJustify;
160 }
161 void SetJustify(OGRJustification eJustifyIn)
162 {
163 eJustify = eJustifyIn;
164 }
165
166 int GetWidth() const
167 {
168 return nWidth;
169 }
170 void SetWidth(int nWidthIn)
171 {
172 nWidth = MAX(0, nWidthIn);
173 }
174
175 int GetPrecision() const
176 {
177 return nPrecision;
178 }
179 void SetPrecision(int nPrecisionIn)
180 {
181 nPrecision = nPrecisionIn;
182 }
183
184 int GetTZFlag() const
185 {
186 return m_nTZFlag;
187 }
188 void SetTZFlag(int nTZFlag)
189 {
190 m_nTZFlag = nTZFlag;
191 }
192
193 void Set(const char *, OGRFieldType, int = 0, int = 0,
194 OGRJustification = OJUndefined);
195
196 void SetDefault(const char *);
197 const char *GetDefault() const;
198 int IsDefaultDriverSpecific() const;
199
200 int IsIgnored() const
201 {
202 return bIgnore;
203 }
204 void SetIgnored(int bIgnoreIn)
205 {
206 bIgnore = bIgnoreIn;
207 }
208
209 int IsNullable() const
210 {
211 return bNullable;
212 }
213 void SetNullable(int bNullableIn)
214 {
215 bNullable = bNullableIn;
216 }
217
218 int IsUnique() const
219 {
220 return bUnique;
221 }
222 void SetUnique(int bUniqueIn)
223 {
224 bUnique = bUniqueIn;
225 }
226
227 const std::string &GetDomainName() const
228 {
229 return m_osDomainName;
230 }
231 void SetDomainName(const std::string &osDomainName)
232 {
233 m_osDomainName = osDomainName;
234 }
235
236 const std::string &GetComment() const
237 {
238 return m_osComment;
239 }
240 void SetComment(const std::string &osComment)
241 {
242 m_osComment = osComment;
243 }
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 private:
264 CPL_DISALLOW_COPY_ASSIGN(OGRFieldDefn)
265 };
266
267 /************************************************************************/
268 /* OGRGeomFieldDefn */
269 /************************************************************************/
270
286 class CPL_DLL OGRGeomFieldDefn
287 {
288 protected:
290 char *pszName = nullptr;
291 OGRwkbGeometryType eGeomType =
292 wkbUnknown; /* all values possible except wkbNone */
293 mutable const OGRSpatialReference *poSRS = nullptr;
294
295 int bIgnore = false;
296 mutable int bNullable = true;
297
298 void Initialize(const char *, OGRwkbGeometryType);
300
301 public:
302 OGRGeomFieldDefn(const char *pszNameIn, OGRwkbGeometryType eGeomTypeIn);
303 explicit OGRGeomFieldDefn(const OGRGeomFieldDefn *);
304 virtual ~OGRGeomFieldDefn();
305
306 void SetName(const char *);
307 const char *GetNameRef() const
308 {
309 return pszName;
310 }
311
312 OGRwkbGeometryType GetType() const
313 {
314 return eGeomType;
315 }
316 void SetType(OGRwkbGeometryType eTypeIn);
317
318 virtual const OGRSpatialReference *GetSpatialRef() const;
319 void SetSpatialRef(const OGRSpatialReference *poSRSIn);
320
321 int IsIgnored() const
322 {
323 return bIgnore;
324 }
325 void SetIgnored(int bIgnoreIn)
326 {
327 bIgnore = bIgnoreIn;
328 }
329
330 int IsNullable() const
331 {
332 return bNullable;
333 }
334 void SetNullable(int bNullableIn)
335 {
336 bNullable = bNullableIn;
337 }
338
339 int IsSame(const OGRGeomFieldDefn *) const;
340
344 static inline OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
345 {
346 return reinterpret_cast<OGRGeomFieldDefnH>(poGeomFieldDefn);
347 }
348
352 static inline OGRGeomFieldDefn *FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
353 {
354 return reinterpret_cast<OGRGeomFieldDefn *>(hGeomFieldDefn);
355 }
356
357 private:
358 CPL_DISALLOW_COPY_ASSIGN(OGRGeomFieldDefn)
359 };
360
361 /************************************************************************/
362 /* OGRFeatureDefn */
363 /************************************************************************/
364
385 class CPL_DLL OGRFeatureDefn
386 {
387 protected:
389 volatile int nRefCount = 0;
390
391 mutable std::vector<std::unique_ptr<OGRFieldDefn>> apoFieldDefn{};
392 mutable std::vector<std::unique_ptr<OGRGeomFieldDefn>> apoGeomFieldDefn{};
393
394 char *pszFeatureClassName = nullptr;
395
396 bool bIgnoreStyle = false;
398
399 public:
400 explicit OGRFeatureDefn(const char *pszName = nullptr);
401 virtual ~OGRFeatureDefn();
402
403 void SetName(const char *pszName);
404 virtual const char *GetName() const;
405
406 virtual int GetFieldCount() const;
407 virtual OGRFieldDefn *GetFieldDefn(int i);
408 virtual const OGRFieldDefn *GetFieldDefn(int i) const;
409 virtual int GetFieldIndex(const char *) const;
410 int GetFieldIndexCaseSensitive(const char *) const;
411
413
417 struct CPL_DLL Fields
418 {
419 private:
420 OGRFeatureDefn *m_poFDefn;
421
422 public:
423 inline explicit Fields(OGRFeatureDefn *poFDefn) : m_poFDefn(poFDefn)
424 {
425 }
426
427 struct CPL_DLL ConstIterator
428 {
429 private:
430 OGRFeatureDefn *m_poFDefn;
431 int m_nIdx;
432
433 public:
434 inline ConstIterator(OGRFeatureDefn *poFDefn, int nIdx)
435 : m_poFDefn(poFDefn), m_nIdx(nIdx)
436 {
437 }
438
439 inline const OGRFieldDefn *operator*() const
440 {
441 return m_poFDefn->GetFieldDefn(m_nIdx);
442 }
443 inline ConstIterator &operator++()
444 {
445 m_nIdx++;
446 return *this;
447 }
448 inline bool operator!=(const ConstIterator &it) const
449 {
450 return m_nIdx != it.m_nIdx;
451 }
452 };
453
454 inline ConstIterator begin()
455 {
456 return ConstIterator(m_poFDefn, 0);
457 }
458 inline ConstIterator end()
459 {
460 return ConstIterator(m_poFDefn, m_poFDefn->GetFieldCount());
461 }
462
463 inline size_t size() const
464 {
465 return static_cast<std::size_t>(m_poFDefn->GetFieldCount());
466 }
467 inline OGRFieldDefn *operator[](size_t i)
468 {
469 return m_poFDefn->GetFieldDefn(static_cast<int>(i));
470 }
471 inline const OGRFieldDefn *operator[](size_t i) const
472 {
473 return m_poFDefn->GetFieldDefn(static_cast<int>(i));
474 }
475 };
477
488 inline Fields GetFields()
489 {
490 return Fields(this);
491 }
492
494 // That method should only be called if there's a guarantee that
495 // GetFieldCount() has been called before
496 int GetFieldCountUnsafe() const
497 {
498 return static_cast<int>(apoFieldDefn.size());
499 }
500
501 // Those methods don't check i is n range.
502 OGRFieldDefn *GetFieldDefnUnsafe(int i)
503 {
504 if (apoFieldDefn.empty())
505 GetFieldDefn(i);
506 return apoFieldDefn[static_cast<std::size_t>(i)].get();
507 }
508 const OGRFieldDefn *GetFieldDefnUnsafe(int i) const
509 {
510 if (apoFieldDefn.empty())
511 GetFieldDefn(i);
512 return apoFieldDefn[static_cast<std::size_t>(i)].get();
513 }
515
516 virtual void AddFieldDefn(const OGRFieldDefn *);
517 virtual OGRErr DeleteFieldDefn(int iField);
518 virtual OGRErr ReorderFieldDefns(const int *panMap);
519
520 virtual int GetGeomFieldCount() const;
521 virtual OGRGeomFieldDefn *GetGeomFieldDefn(int i);
522 virtual const OGRGeomFieldDefn *GetGeomFieldDefn(int i) const;
523 virtual int GetGeomFieldIndex(const char *) const;
524
526
530 struct CPL_DLL GeomFields
531 {
532 private:
533 OGRFeatureDefn *m_poFDefn;
534
535 public:
536 inline explicit GeomFields(OGRFeatureDefn *poFDefn) : m_poFDefn(poFDefn)
537 {
538 }
539
540 struct CPL_DLL ConstIterator
541 {
542 private:
543 OGRFeatureDefn *m_poFDefn;
544 int m_nIdx;
545
546 public:
547 inline ConstIterator(OGRFeatureDefn *poFDefn, int nIdx)
548 : m_poFDefn(poFDefn), m_nIdx(nIdx)
549 {
550 }
551
552 inline const OGRGeomFieldDefn *operator*() const
553 {
554 return m_poFDefn->GetGeomFieldDefn(m_nIdx);
555 }
556 inline ConstIterator &operator++()
557 {
558 m_nIdx++;
559 return *this;
560 }
561 inline bool operator!=(const ConstIterator &it) const
562 {
563 return m_nIdx != it.m_nIdx;
564 }
565 };
566
567 inline ConstIterator begin()
568 {
569 return ConstIterator(m_poFDefn, 0);
570 }
571 inline ConstIterator end()
572 {
573 return ConstIterator(m_poFDefn, m_poFDefn->GetGeomFieldCount());
574 }
575
576 inline size_t size() const
577 {
578 return static_cast<std::size_t>(m_poFDefn->GetGeomFieldCount());
579 }
580 inline OGRGeomFieldDefn *operator[](size_t i)
581 {
582 return m_poFDefn->GetGeomFieldDefn(static_cast<int>(i));
583 }
584 inline const OGRGeomFieldDefn *operator[](size_t i) const
585 {
586 return m_poFDefn->GetGeomFieldDefn(static_cast<int>(i));
587 }
588 };
590
601 inline GeomFields GetGeomFields()
602 {
603 return GeomFields(this);
604 }
605
606 virtual void AddGeomFieldDefn(const OGRGeomFieldDefn *);
607 virtual void AddGeomFieldDefn(std::unique_ptr<OGRGeomFieldDefn> &&);
608 virtual OGRErr DeleteGeomFieldDefn(int iGeomField);
609
610 virtual OGRwkbGeometryType GetGeomType() const;
611 virtual void SetGeomType(OGRwkbGeometryType);
612
613 virtual OGRFeatureDefn *Clone() const;
614
615 int Reference()
616 {
617 return CPLAtomicInc(&nRefCount);
618 }
619 int Dereference()
620 {
621 return CPLAtomicDec(&nRefCount);
622 }
623 int GetReferenceCount() const
624 {
625 return nRefCount;
626 }
627 void Release();
628
629 virtual int IsGeometryIgnored() const;
630 virtual void SetGeometryIgnored(int bIgnore);
631 virtual bool IsStyleIgnored() const
632 {
633 return bIgnoreStyle;
634 }
635 virtual void SetStyleIgnored(bool bIgnore)
636 {
637 bIgnoreStyle = bIgnore;
638 }
639
640 virtual int IsSame(const OGRFeatureDefn *poOtherFeatureDefn) const;
641
643 void ReserveSpaceForFields(int nFieldCountIn);
645
646 std::vector<int> ComputeMapForSetFrom(const OGRFeatureDefn *poSrcFDefn,
647 bool bForgiving = true) const;
648
649 static OGRFeatureDefn *CreateFeatureDefn(const char *pszName = nullptr);
650 static void DestroyFeatureDefn(OGRFeatureDefn *);
651
655 static inline OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
656 {
657 return reinterpret_cast<OGRFeatureDefnH>(poFeatureDefn);
658 }
659
663 static inline OGRFeatureDefn *FromHandle(OGRFeatureDefnH hFeatureDefn)
664 {
665 return reinterpret_cast<OGRFeatureDefn *>(hFeatureDefn);
666 }
667
668 private:
669 CPL_DISALLOW_COPY_ASSIGN(OGRFeatureDefn)
670 };
671
672 /************************************************************************/
673 /* OGRFeature */
674 /************************************************************************/
675
680 class CPL_DLL OGRFeature
681 {
682 private:
683 GIntBig nFID;
684 OGRFeatureDefn *poDefn;
685 OGRGeometry **papoGeometries;
686 OGRField *pauFields;
687 char *m_pszNativeData;
688 char *m_pszNativeMediaType;
689
690 bool SetFieldInternal(int i, const OGRField *puValue);
691
692 protected:
694 mutable char *m_pszStyleString;
695 mutable OGRStyleTable *m_poStyleTable;
696 mutable char *m_pszTmpFieldValue;
698
699 bool CopySelfTo(OGRFeature *poNew) const;
700
701 public:
702 explicit OGRFeature(OGRFeatureDefn *);
703 virtual ~OGRFeature();
704
706 class CPL_DLL FieldValue
707 {
708 friend class OGRFeature;
709 struct Private;
710 std::unique_ptr<Private> m_poPrivate;
711
712 FieldValue(OGRFeature *poFeature, int iFieldIndex);
713 FieldValue(const OGRFeature *poFeature, int iFieldIndex);
714 FieldValue(const FieldValue &oOther) = delete;
715 FieldValue &Assign(const FieldValue &oOther);
716
717 public:
719 ~FieldValue();
720
721 FieldValue &operator=(FieldValue &&oOther);
723
725 FieldValue &operator=(const FieldValue &oOther);
727 FieldValue &operator=(int nVal);
729 FieldValue &operator=(GIntBig nVal);
731 FieldValue &operator=(double dfVal);
733 FieldValue &operator=(const char *pszVal);
735 FieldValue &operator=(const std::string &osVal);
737 FieldValue &operator=(const std::vector<int> &oArray);
739 FieldValue &operator=(const std::vector<GIntBig> &oArray);
741 FieldValue &operator=(const std::vector<double> &oArray);
743 FieldValue &operator=(const std::vector<std::string> &oArray);
745 FieldValue &operator=(CSLConstList papszValues);
747 void SetNull();
749 void clear();
751 void Unset()
752 {
753 clear();
754 }
756 void SetDateTime(int nYear, int nMonth, int nDay, int nHour = 0,
757 int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0);
758
760 int GetIndex() const;
762 const OGRFieldDefn *GetDefn() const;
764 const char *GetName() const
765 {
766 return GetDefn()->GetNameRef();
767 }
769 OGRFieldType GetType() const
770 {
771 return GetDefn()->GetType();
772 }
774 OGRFieldSubType GetSubType() const
775 {
776 return GetDefn()->GetSubType();
777 }
778
780 // cppcheck-suppress functionStatic
781 bool empty() const
782 {
783 return IsUnset();
784 }
785
787 // cppcheck-suppress functionStatic
788 bool IsUnset() const;
789
791 // cppcheck-suppress functionStatic
792 bool IsNull() const;
793
795 const OGRField *GetRawValue() const;
796
800 // cppcheck-suppress functionStatic
801 int GetInteger() const
802 {
803 return GetRawValue()->Integer;
804 }
805
809 // cppcheck-suppress functionStatic
810 GIntBig GetInteger64() const
811 {
812 return GetRawValue()->Integer64;
813 }
814
818 // cppcheck-suppress functionStatic
819 double GetDouble() const
820 {
821 return GetRawValue()->Real;
822 }
823
827 // cppcheck-suppress functionStatic
828 const char *GetString() const
829 {
830 return GetRawValue()->String;
831 }
832
834 bool GetDateTime(int *pnYear, int *pnMonth, int *pnDay, int *pnHour,
835 int *pnMinute, float *pfSecond, int *pnTZFlag) const;
836
838 operator int() const
839 {
840 return GetAsInteger();
841 }
844 operator GIntBig() const
845 {
846 return GetAsInteger64();
847 }
849 operator double() const
850 {
851 return GetAsDouble();
852 }
854 operator const char *() const
855 {
856 return GetAsString();
857 }
859 operator const std::vector<int> &() const
860 {
861 return GetAsIntegerList();
862 }
865 operator const std::vector<GIntBig> &() const
866 {
867 return GetAsInteger64List();
868 }
870 operator const std::vector<double> &() const
871 {
872 return GetAsDoubleList();
873 }
875 operator const std::vector<std::string> &() const
876 {
877 return GetAsStringList();
878 }
880 operator CSLConstList() const;
881
883 int GetAsInteger() const;
886 GIntBig GetAsInteger64() const;
888 double GetAsDouble() const;
890 const char *GetAsString() const;
892 const std::vector<int> &GetAsIntegerList() const;
895 const std::vector<GIntBig> &GetAsInteger64List() const;
897 const std::vector<double> &GetAsDoubleList() const;
899 const std::vector<std::string> &GetAsStringList() const;
900 };
901
903 class CPL_DLL ConstFieldIterator
904 {
905 friend class OGRFeature;
906 struct Private;
907 std::unique_ptr<Private> m_poPrivate;
908
909 ConstFieldIterator(const OGRFeature *poSelf, int nPos);
910
911 public:
913 ConstFieldIterator(
914 ConstFieldIterator &&oOther) noexcept; // declared but not defined.
915 // Needed for gcc 5.4 at least
916 ~ConstFieldIterator();
917 const FieldValue &operator*() const;
918 ConstFieldIterator &operator++();
919 bool operator!=(const ConstFieldIterator &it) const;
921 };
922
940 ConstFieldIterator begin() const;
942 ConstFieldIterator end() const;
943
944 const FieldValue operator[](int iField) const;
945 FieldValue operator[](int iField);
946
949 class FieldNotFoundException : public std::exception
950 {
951 };
952
953 const FieldValue operator[](const char *pszFieldName) const;
954 FieldValue operator[](const char *pszFieldName);
955
956 OGRFeatureDefn *GetDefnRef()
957 {
958 return poDefn;
959 }
960 const OGRFeatureDefn *GetDefnRef() const
961 {
962 return poDefn;
963 }
964
966 void SetFDefnUnsafe(OGRFeatureDefn *poNewFDefn);
968
969 OGRErr SetGeometryDirectly(OGRGeometry *);
970 OGRErr SetGeometry(const OGRGeometry *);
971 OGRGeometry *GetGeometryRef();
972 const OGRGeometry *GetGeometryRef() const;
973 OGRGeometry *StealGeometry() CPL_WARN_UNUSED_RESULT;
974
975 int GetGeomFieldCount() const
976 {
977 return poDefn->GetGeomFieldCount();
978 }
979 OGRGeomFieldDefn *GetGeomFieldDefnRef(int iField)
980 {
981 return poDefn->GetGeomFieldDefn(iField);
982 }
983 const OGRGeomFieldDefn *GetGeomFieldDefnRef(int iField) const
984 {
985 return poDefn->GetGeomFieldDefn(iField);
986 }
987 int GetGeomFieldIndex(const char *pszName) const
988 {
989 return poDefn->GetGeomFieldIndex(pszName);
990 }
991
992 OGRGeometry *GetGeomFieldRef(int iField);
993 const OGRGeometry *GetGeomFieldRef(int iField) const;
994 OGRGeometry *StealGeometry(int iField);
995 OGRGeometry *GetGeomFieldRef(const char *pszFName);
996 const OGRGeometry *GetGeomFieldRef(const char *pszFName) const;
997 OGRErr SetGeomFieldDirectly(int iField, OGRGeometry *);
998 OGRErr SetGeomField(int iField, const OGRGeometry *);
999
1000 void Reset();
1001
1002 OGRFeature *Clone() const CPL_WARN_UNUSED_RESULT;
1003 virtual OGRBoolean Equal(const OGRFeature *poFeature) const;
1004
1005 int GetFieldCount() const
1006 {
1007 return poDefn->GetFieldCount();
1008 }
1009 const OGRFieldDefn *GetFieldDefnRef(int iField) const
1010 {
1011 return poDefn->GetFieldDefn(iField);
1012 }
1013 OGRFieldDefn *GetFieldDefnRef(int iField)
1014 {
1015 return poDefn->GetFieldDefn(iField);
1016 }
1017 int GetFieldIndex(const char *pszName) const
1018 {
1019 return poDefn->GetFieldIndex(pszName);
1020 }
1021
1022 int IsFieldSet(int iField) const;
1023
1024 void UnsetField(int iField);
1025
1026 bool IsFieldNull(int iField) const;
1027
1028 void SetFieldNull(int iField);
1029
1030 bool IsFieldSetAndNotNull(int iField) const;
1031
1032 OGRField *GetRawFieldRef(int i)
1033 {
1034 return pauFields + i;
1035 }
1036 const OGRField *GetRawFieldRef(int i) const
1037 {
1038 return pauFields + i;
1039 }
1040
1041 int GetFieldAsInteger(int i) const;
1042 GIntBig GetFieldAsInteger64(int i) const;
1043 double GetFieldAsDouble(int i) const;
1044 const char *GetFieldAsString(int i) const;
1045 const char *GetFieldAsISO8601DateTime(int i,
1046 CSLConstList papszOptions) const;
1047 const int *GetFieldAsIntegerList(int i, int *pnCount) const;
1048 const GIntBig *GetFieldAsInteger64List(int i, int *pnCount) const;
1049 const double *GetFieldAsDoubleList(int i, int *pnCount) const;
1050 char **GetFieldAsStringList(int i) const;
1051 GByte *GetFieldAsBinary(int i, int *pnCount) const;
1052 int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay,
1053 int *pnHour, int *pnMinute, int *pnSecond,
1054 int *pnTZFlag) const;
1055 int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay,
1056 int *pnHour, int *pnMinute, float *pfSecond,
1057 int *pnTZFlag) const;
1058 char *GetFieldAsSerializedJSon(int i) const;
1059
1061 bool IsFieldSetUnsafe(int i) const
1062 {
1063 return !(pauFields[i].Set.nMarker1 == OGRUnsetMarker &&
1064 pauFields[i].Set.nMarker2 == OGRUnsetMarker &&
1065 pauFields[i].Set.nMarker3 == OGRUnsetMarker);
1066 }
1067 bool IsFieldNullUnsafe(int i) const
1068 {
1069 return (pauFields[i].Set.nMarker1 == OGRNullMarker &&
1070 pauFields[i].Set.nMarker2 == OGRNullMarker &&
1071 pauFields[i].Set.nMarker3 == OGRNullMarker);
1072 }
1073 bool IsFieldSetAndNotNullUnsafe(int i) const
1074 {
1075 return IsFieldSetUnsafe(i) && !IsFieldNullUnsafe(i);
1076 }
1077 // Those methods should only be called on a field that is of the type
1078 // consistent with the value, and that is set.
1079 int GetFieldAsIntegerUnsafe(int i) const
1080 {
1081 return pauFields[i].Integer;
1082 }
1083 GIntBig GetFieldAsInteger64Unsafe(int i) const
1084 {
1085 return pauFields[i].Integer64;
1086 }
1087 double GetFieldAsDoubleUnsafe(int i) const
1088 {
1089 return pauFields[i].Real;
1090 }
1091 const char *GetFieldAsStringUnsafe(int i) const
1092 {
1093 return pauFields[i].String;
1094 }
1096
1097 int GetFieldAsInteger(const char *pszFName) const
1098 {
1099 return GetFieldAsInteger(GetFieldIndex(pszFName));
1100 }
1101 GIntBig GetFieldAsInteger64(const char *pszFName) const
1102 {
1103 return GetFieldAsInteger64(GetFieldIndex(pszFName));
1104 }
1105 double GetFieldAsDouble(const char *pszFName) const
1106 {
1107 return GetFieldAsDouble(GetFieldIndex(pszFName));
1108 }
1109 const char *GetFieldAsString(const char *pszFName) const
1110 {
1111 return GetFieldAsString(GetFieldIndex(pszFName));
1112 }
1113 const char *GetFieldAsISO8601DateTime(const char *pszFName,
1114 CSLConstList papszOptions) const
1115 {
1116 return GetFieldAsISO8601DateTime(GetFieldIndex(pszFName), papszOptions);
1117 }
1118 const int *GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
1119 {
1120 return GetFieldAsIntegerList(GetFieldIndex(pszFName), pnCount);
1121 }
1122 const GIntBig *GetFieldAsInteger64List(const char *pszFName,
1123 int *pnCount) const
1124 {
1125 return GetFieldAsInteger64List(GetFieldIndex(pszFName), pnCount);
1126 }
1127 const double *GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
1128 {
1129 return GetFieldAsDoubleList(GetFieldIndex(pszFName), pnCount);
1130 }
1131 char **GetFieldAsStringList(const char *pszFName) const
1132 {
1133 return GetFieldAsStringList(GetFieldIndex(pszFName));
1134 }
1135
1136 void SetField(int i, int nValue);
1137 void SetField(int i, GIntBig nValue);
1138 void SetField(int i, double dfValue);
1139 void SetField(int i, const char *pszValue);
1140 void SetField(int i, int nCount, const int *panValues);
1141 void SetField(int i, int nCount, const GIntBig *panValues);
1142 void SetField(int i, int nCount, const double *padfValues);
1143 void SetField(int i, const char *const *papszValues);
1144 void SetField(int i, const OGRField *puValue);
1145 void SetField(int i, int nCount, const void *pabyBinary);
1146 void SetField(int i, int nYear, int nMonth, int nDay, int nHour = 0,
1147 int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0);
1148
1150 // Those methods should only be called on a field that is of the type
1151 // consistent with the value, and in a unset state.
1152 void SetFieldSameTypeUnsafe(int i, int nValue)
1153 {
1154 pauFields[i].Integer = nValue;
1155 pauFields[i].Set.nMarker2 = 0;
1156 pauFields[i].Set.nMarker3 = 0;
1157 }
1158 void SetFieldSameTypeUnsafe(int i, GIntBig nValue)
1159 {
1160 pauFields[i].Integer64 = nValue;
1161 }
1162 void SetFieldSameTypeUnsafe(int i, double dfValue)
1163 {
1164 pauFields[i].Real = dfValue;
1165 }
1166 void SetFieldSameTypeUnsafe(int i, char *pszValueTransferred)
1167 {
1168 pauFields[i].String = pszValueTransferred;
1169 }
1171
1172 void SetField(const char *pszFName, int nValue)
1173 {
1174 SetField(GetFieldIndex(pszFName), nValue);
1175 }
1176 void SetField(const char *pszFName, GIntBig nValue)
1177 {
1178 SetField(GetFieldIndex(pszFName), nValue);
1179 }
1180 void SetField(const char *pszFName, double dfValue)
1181 {
1182 SetField(GetFieldIndex(pszFName), dfValue);
1183 }
1184 void SetField(const char *pszFName, const char *pszValue)
1185 {
1186 SetField(GetFieldIndex(pszFName), pszValue);
1187 }
1188 void SetField(const char *pszFName, int nCount, const int *panValues)
1189 {
1190 SetField(GetFieldIndex(pszFName), nCount, panValues);
1191 }
1192 void SetField(const char *pszFName, int nCount, const GIntBig *panValues)
1193 {
1194 SetField(GetFieldIndex(pszFName), nCount, panValues);
1195 }
1196 void SetField(const char *pszFName, int nCount, const double *padfValues)
1197 {
1198 SetField(GetFieldIndex(pszFName), nCount, padfValues);
1199 }
1200 void SetField(const char *pszFName, const char *const *papszValues)
1201 {
1202 SetField(GetFieldIndex(pszFName), papszValues);
1203 }
1204 void SetField(const char *pszFName, const OGRField *puValue)
1205 {
1206 SetField(GetFieldIndex(pszFName), puValue);
1207 }
1208 void SetField(const char *pszFName, int nYear, int nMonth, int nDay,
1209 int nHour = 0, int nMinute = 0, float fSecond = 0.f,
1210 int nTZFlag = 0)
1211 {
1212 SetField(GetFieldIndex(pszFName), nYear, nMonth, nDay, nHour, nMinute,
1213 fSecond, nTZFlag);
1214 }
1215
1216 GIntBig GetFID() const
1217 {
1218 return nFID;
1219 }
1220 virtual OGRErr SetFID(GIntBig nFIDIn);
1221
1222 void DumpReadable(FILE *, CSLConstList papszOptions = nullptr) const;
1223 std::string DumpReadableAsString(CSLConstList papszOptions = nullptr) const;
1224
1225 OGRErr SetFrom(const OGRFeature *, int bForgiving = TRUE);
1226 OGRErr SetFrom(const OGRFeature *, const int *panMap, int bForgiving = TRUE,
1227 bool bUseISO8601ForDateTimeAsString = false);
1228 OGRErr SetFieldsFrom(const OGRFeature *, const int *panMap,
1229 int bForgiving = TRUE,
1230 bool bUseISO8601ForDateTimeAsString = false);
1231
1233 OGRErr RemapFields(OGRFeatureDefn *poNewDefn, const int *panRemapSource);
1234 void AppendField();
1235 OGRErr RemapGeomFields(OGRFeatureDefn *poNewDefn,
1236 const int *panRemapSource);
1238
1239 int Validate(int nValidateFlags, int bEmitError) const;
1240 void FillUnsetWithDefault(int bNotNullableOnly, char **papszOptions);
1241
1242 virtual const char *GetStyleString() const;
1243 virtual void SetStyleString(const char *);
1244 virtual void SetStyleStringDirectly(char *);
1245
1249 virtual OGRStyleTable *GetStyleTable() const
1250 {
1251 return m_poStyleTable;
1252 } /* f.i.x.m.e: add a const qualifier for return type */
1253 virtual void SetStyleTable(OGRStyleTable *poStyleTable);
1254 virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable);
1255
1256 const char *GetNativeData() const
1257 {
1258 return m_pszNativeData;
1259 }
1260 const char *GetNativeMediaType() const
1261 {
1262 return m_pszNativeMediaType;
1263 }
1264 void SetNativeData(const char *pszNativeData);
1265 void SetNativeMediaType(const char *pszNativeMediaType);
1266
1267 static OGRFeature *CreateFeature(OGRFeatureDefn *);
1268 static void DestroyFeature(OGRFeature *);
1269
1273 static inline OGRFeatureH ToHandle(OGRFeature *poFeature)
1274 {
1275 return reinterpret_cast<OGRFeatureH>(poFeature);
1276 }
1277
1281 static inline OGRFeature *FromHandle(OGRFeatureH hFeature)
1282 {
1283 return reinterpret_cast<OGRFeature *>(hFeature);
1284 }
1285
1286 private:
1287 CPL_DISALLOW_COPY_ASSIGN(OGRFeature)
1288 };
1289
1291 struct CPL_DLL OGRFeatureUniquePtrDeleter
1292 {
1293 void operator()(OGRFeature *) const;
1294 };
1296
1300 typedef std::unique_ptr<OGRFeature, OGRFeatureUniquePtrDeleter>
1301 OGRFeatureUniquePtr;
1302
1304
1305 inline OGRFeature::ConstFieldIterator begin(const OGRFeature *poFeature)
1306 {
1307 return poFeature->begin();
1308 }
1310 inline OGRFeature::ConstFieldIterator end(const OGRFeature *poFeature)
1311 {
1312 return poFeature->end();
1313 }
1314
1316 inline OGRFeature::ConstFieldIterator
1317 begin(const OGRFeatureUniquePtr &poFeature)
1318 {
1319 return poFeature->begin();
1320 }
1322 inline OGRFeature::ConstFieldIterator end(const OGRFeatureUniquePtr &poFeature)
1323 {
1324 return poFeature->end();
1325 }
1326
1328
1329 /************************************************************************/
1330 /* OGRFieldDomain */
1331 /************************************************************************/
1332
1333 /* clang-format off */
1353 /* clang-format on */
1354
1355 class CPL_DLL OGRFieldDomain
1356 {
1357 protected:
1359 std::string m_osName;
1360 std::string m_osDescription;
1361 OGRFieldDomainType m_eDomainType;
1362 OGRFieldType m_eFieldType;
1363 OGRFieldSubType m_eFieldSubType;
1364 OGRFieldDomainSplitPolicy m_eSplitPolicy = OFDSP_DEFAULT_VALUE;
1365 OGRFieldDomainMergePolicy m_eMergePolicy = OFDMP_DEFAULT_VALUE;
1366
1367 OGRFieldDomain(const std::string &osName, const std::string &osDescription,
1368 OGRFieldDomainType eDomainType, OGRFieldType eFieldType,
1369 OGRFieldSubType eFieldSubType);
1372 public:
1377 virtual ~OGRFieldDomain() = 0;
1378
1383 virtual OGRFieldDomain *Clone() const = 0;
1384
1389 const std::string &GetName() const
1390 {
1391 return m_osName;
1392 }
1393
1399 const std::string &GetDescription() const
1400 {
1401 return m_osDescription;
1402 }
1403
1408 OGRFieldDomainType GetDomainType() const
1409 {
1410 return m_eDomainType;
1411 }
1412
1417 OGRFieldType GetFieldType() const
1418 {
1419 return m_eFieldType;
1420 }
1421
1426 OGRFieldSubType GetFieldSubType() const
1427 {
1428 return m_eFieldSubType;
1429 }
1430
1432 static inline OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)
1433 {
1434 return reinterpret_cast<OGRFieldDomainH>(poFieldDomain);
1435 }
1436
1438 static inline OGRFieldDomain *FromHandle(OGRFieldDomainH hFieldDomain)
1439 {
1440 return reinterpret_cast<OGRFieldDomain *>(hFieldDomain);
1441 }
1442
1447 OGRFieldDomainSplitPolicy GetSplitPolicy() const
1448 {
1449 return m_eSplitPolicy;
1450 }
1451
1456 void SetSplitPolicy(OGRFieldDomainSplitPolicy policy)
1457 {
1458 m_eSplitPolicy = policy;
1459 }
1460
1465 OGRFieldDomainMergePolicy GetMergePolicy() const
1466 {
1467 return m_eMergePolicy;
1468 }
1469
1474 void SetMergePolicy(OGRFieldDomainMergePolicy policy)
1475 {
1476 m_eMergePolicy = policy;
1477 }
1478 };
1479
1486 class CPL_DLL OGRCodedFieldDomain final : public OGRFieldDomain
1487 {
1488 private:
1489 std::vector<OGRCodedValue> m_asValues{};
1490
1491 OGRCodedFieldDomain(const OGRCodedFieldDomain &) = delete;
1492 OGRCodedFieldDomain &operator=(const OGRCodedFieldDomain &) = delete;
1493
1494 public:
1510 OGRCodedFieldDomain(const std::string &osName,
1511 const std::string &osDescription,
1512 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1513 std::vector<OGRCodedValue> &&asValues);
1514
1515 ~OGRCodedFieldDomain() override;
1516
1517 OGRCodedFieldDomain *Clone() const override;
1518
1524 const OGRCodedValue *GetEnumeration() const
1525 {
1526 return m_asValues.data();
1527 }
1528 };
1529
1532 class CPL_DLL OGRRangeFieldDomain final : public OGRFieldDomain
1533 {
1534 private:
1535 OGRField m_sMin;
1536 OGRField m_sMax;
1537 bool m_bMinIsInclusive;
1538 bool m_bMaxIsInclusive;
1539
1540 OGRRangeFieldDomain(const OGRRangeFieldDomain &) = delete;
1541 OGRRangeFieldDomain &operator=(const OGRRangeFieldDomain &) = delete;
1542
1543 public:
1571 OGRRangeFieldDomain(const std::string &osName,
1572 const std::string &osDescription,
1573 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1574 const OGRField &sMin, bool bMinIsInclusive,
1575 const OGRField &sMax, bool bMaxIsInclusive);
1576
1577 OGRRangeFieldDomain *Clone() const override
1578 {
1579 auto poDomain = new OGRRangeFieldDomain(
1580 m_osName, m_osDescription, m_eFieldType, m_eFieldSubType, m_sMin,
1581 m_bMinIsInclusive, m_sMax, m_bMaxIsInclusive);
1582 poDomain->SetMergePolicy(m_eMergePolicy);
1583 poDomain->SetSplitPolicy(m_eSplitPolicy);
1584 return poDomain;
1585 }
1586
1600 const OGRField &GetMin(bool &bIsInclusiveOut) const
1601 {
1602 bIsInclusiveOut = m_bMinIsInclusive;
1603 return m_sMin;
1604 }
1605
1619 const OGRField &GetMax(bool &bIsInclusiveOut) const
1620 {
1621 bIsInclusiveOut = m_bMaxIsInclusive;
1622 return m_sMax;
1623 }
1624 };
1625
1630 class CPL_DLL OGRGlobFieldDomain final : public OGRFieldDomain
1631 {
1632 private:
1633 std::string m_osGlob;
1634
1635 OGRGlobFieldDomain(const OGRGlobFieldDomain &) = delete;
1636 OGRGlobFieldDomain &operator=(const OGRGlobFieldDomain &) = delete;
1637
1638 public:
1649 OGRGlobFieldDomain(const std::string &osName,
1650 const std::string &osDescription,
1651 OGRFieldType eFieldType, OGRFieldSubType eFieldSubType,
1652 const std::string &osBlob);
1653
1654 OGRGlobFieldDomain *Clone() const override
1655 {
1656 auto poDomain = new OGRGlobFieldDomain(
1657 m_osName, m_osDescription, m_eFieldType, m_eFieldSubType, m_osGlob);
1658 poDomain->SetMergePolicy(m_eMergePolicy);
1659 poDomain->SetSplitPolicy(m_eSplitPolicy);
1660 return poDomain;
1661 }
1662
1667 const std::string &GetGlob() const
1668 {
1669 return m_osGlob;
1670 }
1671 };
1672
1673 /************************************************************************/
1674 /* OGRFeatureQuery */
1675 /************************************************************************/
1676
1678 class OGRLayer;
1679 class swq_expr_node;
1680 class swq_custom_func_registrar;
1681
1682 class CPL_DLL OGRFeatureQuery
1683 {
1684 private:
1685 OGRFeatureDefn *poTargetDefn;
1686 void *pSWQExpr;
1687
1688 char **FieldCollector(void *, char **);
1689
1690 static GIntBig *EvaluateAgainstIndices(const swq_expr_node *, OGRLayer *,
1691 GIntBig &nFIDCount);
1692
1693 static int CanUseIndex(const swq_expr_node *, OGRLayer *);
1694
1695 OGRErr Compile(OGRLayer *, OGRFeatureDefn *, const char *, int bCheck,
1696 swq_custom_func_registrar *poCustomFuncRegistrar);
1697
1698 CPL_DISALLOW_COPY_ASSIGN(OGRFeatureQuery)
1699
1700 public:
1701 OGRFeatureQuery();
1702 ~OGRFeatureQuery();
1703
1704 OGRErr Compile(OGRLayer *, const char *, int bCheck = TRUE,
1705 swq_custom_func_registrar *poCustomFuncRegistrar = nullptr);
1706 OGRErr Compile(OGRFeatureDefn *, const char *, int bCheck = TRUE,
1707 swq_custom_func_registrar *poCustomFuncRegistrar = nullptr);
1708 int Evaluate(OGRFeature *);
1709
1710 GIntBig *EvaluateAgainstIndices(OGRLayer *, OGRErr *);
1711
1712 int CanUseIndex(OGRLayer *);
1713
1714 char **GetUsedFields();
1715
1716 void *GetSWQExpr()
1717 {
1718 return pSWQExpr;
1719 }
1720 };
1722
1723 #endif /* ndef OGR_FEATURE_H_INCLUDED */
MAX
#define MAX(a, b)
Macro to compute the maximum of 2 values.
Definition: cpl_port.h:385
OGRNullMarker
#define OGRNullMarker
Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for a null field.
Definition: ogr_core.h:867
OGRFeature::GetFieldAsDoubleList
const double * GetFieldAsDoubleList(const char *pszFName, int *pnCount) const
Fetch field value as a list of doubles.
Definition: ogr_feature.h:1127
OGRFeature::FieldValue::GetString
const char * GetString() const
Return the string value.
Definition: ogr_feature.h:828
OGRFeatureDefn::FromHandle
static OGRFeatureDefn * FromHandle(OGRFeatureDefnH hFeatureDefn)
Convert a OGRFeatureDefnH to a OGRFeatureDefn*.
Definition: ogr_feature.h:663
OGRFeature::FieldValue::GetSubType
OGRFieldSubType GetSubType() const
Return field subtype.
Definition: ogr_feature.h:774
OGRFieldDomain::GetSplitPolicy
OGRFieldDomainSplitPolicy GetSplitPolicy() const
Get the split policy.
Definition: ogr_feature.h:1447
OGRFeatureDefn::GetFields
Fields GetFields()
Return an object that can be used to iterate over non-geometry fields.
Definition: ogr_feature.h:488
OGRFieldDomainMergePolicy
OGRFieldDomainMergePolicy
Merge policy for field domains.
Definition: ogr_core.h:1272
OGRFeatureDefn::IsStyleIgnored
virtual bool IsStyleIgnored() const
Determine whether the style can be omitted when fetching features.
Definition: ogr_feature.h:631
OFDSP_DEFAULT_VALUE
@ OFDSP_DEFAULT_VALUE
Default value.
Definition: ogr_core.h:1257
OGRFieldDomainType
OGRFieldDomainType
Type of field domain.
Definition: ogr_core.h:1237
GByte
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:196
OGRFieldDefnH
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_feature.h:62
OGRFeature::FieldNotFoundException
Exception raised by operator[](const char*) when a field is not found.
Definition: ogr_feature.h:949
OGRCodedFieldDomain::GetEnumeration
const OGRCodedValue * GetEnumeration() const
Get the enumeration as (code, value) pairs.
Definition: ogr_feature.h:1524
OGRFeature::SetField
void SetField(const char *pszFName, GIntBig nValue)
Set field to 64 bit integer value. OFTInteger, OFTInteger64 and OFTReal fields will be set directly....
Definition: ogr_feature.h:1176
OGRFeature::GetFieldAsStringList
char ** GetFieldAsStringList(const char *pszFName) const
Fetch field value as a list of strings.
Definition: ogr_feature.h:1131
OGRFieldDefn::GetDomainName
const std::string & GetDomainName() const
Return the name of the field domain for this field.
Definition: ogr_feature.h:227
OGRFeature::ConstFieldIterator
Field value iterator class.
Definition: ogr_feature.h:903
OGRFieldDefn::SetDomainName
void SetDomainName(const std::string &osDomainName)
Set the name of the field domain for this field.
Definition: ogr_feature.h:231
OGRFeature::GetStyleTable
virtual OGRStyleTable * GetStyleTable() const
Return style table.
Definition: ogr_feature.h:1249
OGRFieldDefn::SetJustify
void SetJustify(OGRJustification eJustifyIn)
Set the justification for this field.
Definition: ogr_feature.h:161
OGRFieldDefn::SetTZFlag
void SetTZFlag(int nTZFlag)
Set the time zone flag.
Definition: ogr_feature.h:188
begin
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:411
OGRFeature::FieldValue::GetType
OGRFieldType GetType() const
Return field type.
Definition: ogr_feature.h:769
OGRGeomFieldDefn::SetIgnored
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:325
OGRStyleTable
This class represents a style table.
Definition: ogr_featurestyle.h:84
OGRFieldDomain::SetMergePolicy
void SetMergePolicy(OGRFieldDomainMergePolicy policy)
Set the merge policy.
Definition: ogr_feature.h:1474
OGRFieldDefn::SetIgnored
void SetIgnored(int bIgnoreIn)
Set whether this field should be omitted when fetching features.
Definition: ogr_feature.h:204
OGRFeature::ToHandle
static OGRFeatureH ToHandle(OGRFeature *poFeature)
Convert a OGRFeature* to a OGRFeatureH.
Definition: ogr_feature.h:1273
OGRFeature::FieldValue::GetName
const char * GetName() const
Return field name.
Definition: ogr_feature.h:764
OGRFeatureDefn::GetGeomFieldIndex
virtual int GetGeomFieldIndex(const char *) const
Find geometry field by name.
Definition: ogrfeaturedefn.cpp:875
OGRFeature::GetFieldDefnRef
OGRFieldDefn * GetFieldDefnRef(int iField)
Fetch definition for this field.
Definition: ogr_feature.h:1013
OGRFieldDefn::GetWidth
int GetWidth() const
Get the formatting width for this field.
Definition: ogr_feature.h:166
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:166
OGRGeomFieldDefnH
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_feature.h:71
OGRStyleTableH
void * OGRStyleTableH
Opaque type for a style table (OGRStyleTable)
Definition: ogr_feature.h:68
OGRFieldDomain::FromHandle
static OGRFieldDomain * FromHandle(OGRFieldDomainH hFieldDomain)
Convert a OGRFieldDomainH to a OGRFieldDomain*.
Definition: ogr_feature.h:1438
OGRFeatureH
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_feature.h:66
OGRFieldDomain::SetSplitPolicy
void SetSplitPolicy(OGRFieldDomainSplitPolicy policy)
Set the split policy.
Definition: ogr_feature.h:1456
OGRFeature::SetField
void SetField(const char *pszFName, const OGRField *puValue)
Set field.
Definition: ogr_feature.h:1204
OGRRangeFieldDomain::GetMin
const OGRField & GetMin(bool &bIsInclusiveOut) const
Get the minimum value.
Definition: ogr_feature.h:1600
OGRFeature::GetFieldAsDouble
double GetFieldAsDouble(const char *pszFName) const
Fetch field value as a double.
Definition: ogr_feature.h:1105
OGRGeometry
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:334
OGRFieldDomain::GetDescription
const std::string & GetDescription() const
Get the description of the field domain.
Definition: ogr_feature.h:1399
OGRFieldDomain::Clone
virtual OGRFieldDomain * Clone() const =0
Clone.
OGRFeature::GetGeomFieldDefnRef
OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField)
Fetch definition for this geometry field.
Definition: ogr_feature.h:979
OGRLayer
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:73
OGRFeature::FieldValue::empty
bool empty() const
Return whether the field value is unset/empty.
Definition: ogr_feature.h:781
OFDMP_DEFAULT_VALUE
@ OFDMP_DEFAULT_VALUE
Default value.
Definition: ogr_core.h:1275
OGRGeomFieldDefn::ToHandle
static OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)
Convert a OGRGeomFieldDefn* to a OGRGeomFieldDefnH.
Definition: ogr_feature.h:344
OGRFieldDefn::GetPrecision
int GetPrecision() const
Get the formatting precision for this field. This should normally be zero for fields of types other t...
Definition: ogr_feature.h:175
ogr_geometry.h
OGRGeomFieldDefn::GetNameRef
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:307
OGRGeomFieldDefn::IsIgnored
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:321
OGRFeatureUniquePtr
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:1301
OGRRangeFieldDomain::GetMax
const OGRField & GetMax(bool &bIsInclusiveOut) const
Get the maximum value.
Definition: ogr_feature.h:1619
OGRFeatureH
void * OGRFeatureH
Opaque type for a feature (OGRFeature)
Definition: ogr_api.h:362
OGRFeature::GetGeomFieldIndex
int GetGeomFieldIndex(const char *pszName) const
Fetch the geometry field index given geometry field name.
Definition: ogr_feature.h:987
OGRFieldDefn::GetNameRef
const char * GetNameRef() const
Fetch name of this field.
Definition: ogr_feature.h:132
OGRBoolean
int OGRBoolean
Type for a OGR boolean.
Definition: ogr_core.h:395
OGRFeatureDefnH
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_api.h:360
OGRFieldDefn::SetPrecision
void SetPrecision(int nPrecisionIn)
Set the formatting precision for this field in characters.
Definition: ogr_feature.h:179
OGRFeatureDefn::GetFieldDefn
virtual OGRFieldDefn * GetFieldDefn(int i)
Fetch field definition.
Definition: ogrfeaturedefn.cpp:312
OGRFeature::FieldValue
Field value.
Definition: ogr_feature.h:706
OGRGeomFieldDefnH
struct OGRGeomFieldDefnHS * OGRGeomFieldDefnH
Opaque type for a geometry field definition (OGRGeomFieldDefn)
Definition: ogr_api.h:367
OGRFieldDefn::GetComment
const std::string & GetComment() const
Return the (optional) comment for this field.
Definition: ogr_feature.h:236
OGRFeature::begin
ConstFieldIterator begin() const
Return begin of field value iterator.
Definition: ogrfeature.cpp:7513
OGRFieldDefn::SetComment
void SetComment(const std::string &osComment)
Set the comment for this field.
Definition: ogr_feature.h:240
OGRFieldDomain::GetMergePolicy
OGRFieldDomainMergePolicy GetMergePolicy() const
Get the merge policy.
Definition: ogr_feature.h:1465
OGRFieldDefn::IsUnique
int IsUnique() const
Return whether this field has a unique constraint.
Definition: ogr_feature.h:218
OGRGlobFieldDomain
Definition of a field domain for field content validated by a glob.
Definition: ogr_feature.h:1630
OGRField
OGRFeature field attribute value union.
Definition: ogr_core.h:900
OGRFeature::GetDefnRef
OGRFeatureDefn * GetDefnRef()
Fetch feature definition.
Definition: ogr_feature.h:956
OGRFeatureDefn::GetGeomFieldDefn
virtual OGRGeomFieldDefn * GetGeomFieldDefn(int i)
Fetch geometry field definition.
Definition: ogrfeaturedefn.cpp:640
OGRFeature::SetField
void SetField(const char *pszFName, int nCount, const double *padfValues)
Definition: ogr_feature.h:1196
OGRCodedValue
Associates a code and a value.
Definition: ogr_core.h:1224
OGRFeature::GetFieldIndex
int GetFieldIndex(const char *pszName) const
Fetch the field index given field name.
Definition: ogr_feature.h:1017
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1178
OGRFeature::FieldValue::Unset
void Unset()
Unset the field.
Definition: ogr_feature.h:751
OGRFeatureDefn::GetFieldCount
virtual int GetFieldCount() const
Fetch number of fields on this feature.
Definition: ogrfeaturedefn.cpp:268
OGRFeature::SetField
void SetField(const char *pszFName, const char *pszValue)
Set field to string value.
Definition: ogr_feature.h:1184
OGRFieldDomain::GetName
const std::string & GetName() const
Get the name of the field domain.
Definition: ogr_feature.h:1389
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:1208
OGRFieldDefn::FromHandle
static OGRFieldDefn * FromHandle(OGRFieldDefnH hFieldDefn)
Convert a OGRFieldDefnH to a OGRFieldDefn*.
Definition: ogr_feature.h:258
OGRFieldDomainH
struct OGRFieldDomainHS * OGRFieldDomainH
Opaque type for a field domain definition (OGRFieldDomain)
Definition: ogr_api.h:370
OGRFieldDefn
Definition of an attribute of an OGRFeatureDefn.
Definition: ogr_feature.h:103
OGRGeomFieldDefn::IsNullable
int IsNullable() const
Return whether this geometry field can receive null values.
Definition: ogr_feature.h:330
ogr_featurestyle.h
OGRFieldDefn::SetUnique
void SetUnique(int bUniqueIn)
Set whether this field has a unique constraint.
Definition: ogr_feature.h:222
OGRFeature::SetField
void SetField(const char *pszFName, int nCount, const int *panValues)
Definition: ogr_feature.h:1188
OGRUnsetMarker
#define OGRUnsetMarker
Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for a unset field.
Definition: ogr_core.h:859
OGRRangeFieldDomain
Definition of a numeric field domain with a range of validity for values.
Definition: ogr_feature.h:1532
OGRJustification
OGRJustification
Display justification for field values.
Definition: ogr_core.h:836
OGRFeatureDefn::SetStyleIgnored
virtual void SetStyleIgnored(bool bIgnore)
Set whether the style can be omitted when fetching features.
Definition: ogr_feature.h:635
OGRFieldDefnH
void * OGRFieldDefnH
Opaque type for a field definition (OGRFieldDefn)
Definition: ogr_api.h:358
OGRFieldDomain::GetFieldType
OGRFieldType GetFieldType() const
Get the field type.
Definition: ogr_feature.h:1417
OGRGeomFieldDefn
Definition of a geometry field of an OGRFeatureDefn.
Definition: ogr_feature.h:286
OGRFeature::FieldValue::GetDouble
double GetDouble() const
Return the double value.
Definition: ogr_feature.h:819
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:1122
OGRFieldDomain
Definition of a field domain.
Definition: ogr_feature.h:1355
OGRFeature::FromHandle
static OGRFeature * FromHandle(OGRFeatureH hFeature)
Convert a OGRFeatureH to a OGRFeature*.
Definition: ogr_feature.h:1281
OGRFeatureDefn::Dereference
int Dereference()
Decrements the reference count by one.
Definition: ogr_feature.h:619
OGR_TZFLAG_UNKNOWN
#define OGR_TZFLAG_UNKNOWN
Time zone flag indicating unknown timezone.
Definition: ogr_core.h:873
end
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:419
OGRFieldDefn::GetType
OGRFieldType GetType() const
Fetch type of this field.
Definition: ogr_feature.h:143
OGRFieldDefn::GetTZFlag
int GetTZFlag() const
Get the time zone flag.
Definition: ogr_feature.h:184
OGRFeatureDefn::GetFieldIndex
virtual int GetFieldIndex(const char *) const
Find field by name.
Definition: ogrfeaturedefn.cpp:1177
OGRFieldDomain::GetFieldSubType
OGRFieldSubType GetFieldSubType() const
Get the field subtype.
Definition: ogr_feature.h:1426
OGRFieldDefn::GetAlternativeNameRef
const char * GetAlternativeNameRef() const
Fetch the alternative name (or "alias") for this field.
Definition: ogr_feature.h:138
OGRFieldDomainSplitPolicy
OGRFieldDomainSplitPolicy
Split policy for field domains.
Definition: ogr_core.h:1254
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:378
OGRFeatureDefn::GetGeomFields
GeomFields GetGeomFields()
Return an object that can be used to iterate over geometry fields.
Definition: ogr_feature.h:601
OGRFieldDomain::ToHandle
static OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)
Convert a OGRFieldDomain* to a OGRFieldDomainH.
Definition: ogr_feature.h:1432
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:226
OGRFeature::GetFieldDefnRef
const OGRFieldDefn * GetFieldDefnRef(int iField) const
Fetch definition for this field.
Definition: ogr_feature.h:1009
OGRFeature::FieldValue::GetInteger
int GetInteger() const
Return the integer value.
Definition: ogr_feature.h:801
OGRFeature::GetRawFieldRef
const OGRField * GetRawFieldRef(int i) const
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:1036
OGRwkbGeometryType
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:406
OGRFieldDefn::IsIgnored
int IsIgnored() const
Return whether this field should be omitted when fetching features.
Definition: ogr_feature.h:200
OGRFeature::SetField
void SetField(const char *pszFName, double dfValue)
Set field to double value.
Definition: ogr_feature.h:1180
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:976
OGRFeature::GetRawFieldRef
OGRField * GetRawFieldRef(int i)
Fetch a pointer to the internal field value given the index.
Definition: ogr_feature.h:1032
OGRFeatureDefn::Reference
int Reference()
Increments the reference count by one.
Definition: ogr_feature.h:615
OGRCodedFieldDomain
Definition of a coded / enumerated field domain.
Definition: ogr_feature.h:1486
OGRFeature
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:680
OGRFeature::end
ConstFieldIterator end() const
Return end of field value iterator.
Definition: ogrfeature.cpp:7518
OGRFeature::GetGeomFieldDefnRef
const OGRGeomFieldDefn * GetGeomFieldDefnRef(int iField) const
Fetch definition for this geometry field.
Definition: ogr_feature.h:983
OGRGeomFieldDefn::GetType
OGRwkbGeometryType GetType() const
Fetch geometry type of this field.
Definition: ogr_feature.h:312
OGRFeature::GetNativeMediaType
const char * GetNativeMediaType() const
Returns the native media type for the feature.
Definition: ogr_feature.h:1260
OGRFieldSubType
OGRFieldSubType
List of field subtypes.
Definition: ogr_core.h:811
OGRFieldDefn::SetNullable
void SetNullable(int bNullableIn)
Set whether this field can receive null values.
Definition: ogr_feature.h:213
OGRGeomFieldDefn::SetNullable
void SetNullable(int bNullableIn)
Set whether this geometry field can receive null values.
Definition: ogr_feature.h:334
OGRRangeFieldDomain::Clone
OGRRangeFieldDomain * Clone() const override
Clone.
Definition: ogr_feature.h:1577
OGRGeomFieldDefn::FromHandle
static OGRGeomFieldDefn * FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)
Convert a OGRGeomFieldDefnH to a OGRGeomFieldDefn*.
Definition: ogr_feature.h:352
OGRFeatureDefn::ToHandle
static OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)
Convert a OGRFeatureDefn* to a OGRFeatureDefnH.
Definition: ogr_feature.h:655
OGRFieldDefn::IsNullable
int IsNullable() const
Return whether this field can receive null values.
Definition: ogr_feature.h:209
OGRFieldType
OGRFieldType
List of feature field types.
Definition: ogr_core.h:783
OGRFeatureDefnH
void * OGRFeatureDefnH
Opaque type for a feature definition (OGRFeatureDefn)
Definition: ogr_feature.h:64
OGRFeatureDefn::GetGeomFieldCount
virtual int GetGeomFieldCount() const
Fetch number of geometry fields on this feature.
Definition: ogrfeaturedefn.cpp:591
OGRFeature::GetFieldAsInteger64
GIntBig GetFieldAsInteger64(const char *pszFName) const
Fetch field value as integer 64 bit.
Definition: ogr_feature.h:1101
OGRFeature::GetFieldAsString
const char * GetFieldAsString(const char *pszFName) const
Fetch field value as a string.
Definition: ogr_feature.h:1109
OGRFeature::FieldValue::GetInteger64
GIntBig GetInteger64() const
Return the 64-bit integer value.
Definition: ogr_feature.h:810
OGRFeature::SetField
void SetField(const char *pszFName, const char *const *papszValues)
Definition: ogr_feature.h:1200
OGRFieldDefn::SetWidth
void SetWidth(int nWidthIn)
Set the formatting width for this field in characters.
Definition: ogr_feature.h:170
OGRFeatureDefn
Definition of a feature class or feature layer.
Definition: ogr_feature.h:385
OGRGlobFieldDomain::GetGlob
const std::string & GetGlob() const
Get the glob expression.
Definition: ogr_feature.h:1667
OGRFeature::GetFieldAsInteger
int GetFieldAsInteger(const char *pszFName) const
Fetch field value as integer.
Definition: ogr_feature.h:1097
OGRFeatureDefn::GetReferenceCount
int GetReferenceCount() const
Fetch current reference count.
Definition: ogr_feature.h:623
OGRFieldDefn::GetSubType
OGRFieldSubType GetSubType() const
Fetch subtype of this field.
Definition: ogr_feature.h:150
OGRFeature::SetField
void SetField(const char *pszFName, int nValue)
Set field to integer value. OFTInteger, OFTInteger64 and OFTReal fields will be set directly....
Definition: ogr_feature.h:1172
OGRFeature::GetFieldAsIntegerList
const int * GetFieldAsIntegerList(const char *pszFName, int *pnCount) const
Fetch field value as a list of integers.
Definition: ogr_feature.h:1118
wkbUnknown
@ wkbUnknown
unknown type, non-standard
Definition: ogr_core.h:408
OGRFieldDomainH
struct OGRFieldDomainHS * OGRFieldDomainH
Opaque type for a field domain definition (OGRFieldDomain)
Definition: ogr_feature.h:74
OGRGlobFieldDomain::Clone
OGRGlobFieldDomain * Clone() const override
Clone.
Definition: ogr_feature.h:1654
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:1042
OGRFieldDefn::GetJustify
OGRJustification GetJustify() const
Get the justification for this field.
Definition: ogr_feature.h:157
OGRFeature::GetNativeData
const char * GetNativeData() const
Returns the native data for the feature.
Definition: ogr_feature.h:1256
OGRFeature::GetFieldAsISO8601DateTime
const char * GetFieldAsISO8601DateTime(const char *pszFName, CSLConstList papszOptions) const
Fetch OFTDateTime field value as a ISO8601 representation.
Definition: ogr_feature.h:1113
OGRFieldDomain::GetDomainType
OGRFieldDomainType GetDomainType() const
Get the type of the field domain.
Definition: ogr_feature.h:1408
OGRFeature::GetFID
GIntBig GetFID() const
Get feature identifier.
Definition: ogr_feature.h:1216
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:1192
OGRFieldDefn::ToHandle
static OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)
Convert a OGRFieldDefn* to a OGRFieldDefnH.
Definition: ogr_feature.h:250