OTB  9.0.0
Orfeo Toolbox
otbVectorDataKeywordlist.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbVectorDataKeywordlist_h
22 #define otbVectorDataKeywordlist_h
23 
24 #include <iosfwd>
25 #include <vector>
26 #include <string>
27 
28 #include "itkLightObject.h"
29 #include "itkObjectFactory.h"
30 #if defined(__GNUC__) || defined(__clang__)
31 #pragma GCC diagnostic push
32 #pragma GCC diagnostic ignored "-Wshadow"
33 #include "ogr_feature.h"
34 #pragma GCC diagnostic pop
35 #else
36 #include "ogr_feature.h"
37 #endif
38 
39 namespace otb
40 {
55 #include "OTBVectorDataBaseExport.h"
56 
57 class OTBVectorDataBase_EXPORT VectorDataKeywordlist
58 {
59 public:
62 
63  typedef std::pair<OGRFieldDefn*, OGRField> FieldType;
64  typedef std::vector<FieldType> FieldListType;
65 
66  virtual const char* GetNameOfClass() const
67  {
68  return "VectorDataKeywordlist";
69  }
70 
71  void AddField(OGRFieldDefn* fieldDefn, OGRField* field);
72 
77  void AddField(const std::string& key, const std::string& value);
78 
84  std::string GetFieldAsString(const std::string& key) const;
85 
90  bool HasField(const std::string& key) const;
91 
96  void SetFieldAsString(const std::string& key, const std::string& value);
97 
103  double GetFieldAsDouble(const std::string& key) const;
104 
109  void SetFieldAsDouble(const std::string& key, double value);
110 
116  void SetFieldAsInt(const std::string& key, int value);
117 
123  int GetFieldAsInt(const std::string& key) const;
124 
129  FieldType GetNthField(unsigned int index) const;
130 
134  unsigned int GetNumberOfFields() const;
135 
139  std::vector<std::string> GetFieldList() const;
140 
144  void CopyFieldList(const Self& kwl);
145 
149  virtual void Print(std::ostream& os, itk::Indent indent = 0) const;
150 
153 
156 
158  VectorDataKeywordlist(const Self& other);
159 
161  void operator=(const Self&);
162 
163 protected:
164  virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
165 
166 private:
167  std::string PrintField(FieldType field) const;
168  FieldType CopyOgrField(FieldType field);
170 };
171 OTBVectorDataBase_EXPORT extern std::ostream& operator<<(std::ostream& os, const VectorDataKeywordlist& kwl);
172 }
173 
174 #endif
otb::VectorDataKeywordlist::m_FieldList
FieldListType m_FieldList
Definition: otbVectorDataKeywordlist.h:169
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::VectorDataKeywordlist::FieldListType
std::vector< FieldType > FieldListType
Definition: otbVectorDataKeywordlist.h:64
otb::VectorDataKeywordlist::FieldType
std::pair< OGRFieldDefn *, OGRField > FieldType
Definition: otbVectorDataKeywordlist.h:63
otb::operator<<
OTBCommon_EXPORT std::ostream & operator<<(std::ostream &os, const otb::StringToHTML &str)
otb::VectorDataKeywordlist
this class handle the metadata of vector data.
Definition: otbVectorDataKeywordlist.h:57
otb::VectorDataKeywordlist::GetNameOfClass
virtual const char * GetNameOfClass() const
Definition: otbVectorDataKeywordlist.h:66
otb::VectorDataKeywordlist::Self
VectorDataKeywordlist Self
Definition: otbVectorDataKeywordlist.h:61