OTB  6.7.0
Orfeo Toolbox
otbVectorDataKeywordlist.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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  {return "VectorDataKeywordlist"; }
68 
69  void AddField(OGRFieldDefn* fieldDefn, OGRField* field);
70 
75  void AddField(const std::string& key, const std::string& value);
76 
82  std::string GetFieldAsString(const std::string& key) const;
83 
88  bool HasField(const std::string& key) const;
89 
94  void SetFieldAsString(const std::string& key, const std::string& value);
95 
101  double GetFieldAsDouble(const std::string& key) const;
102 
107  void SetFieldAsDouble(const std::string& key, double value);
108 
114  void SetFieldAsInt(const std::string& key, int value);
115 
121  int GetFieldAsInt(const std::string& key) const;
122 
127  FieldType GetNthField(unsigned int index) const;
128 
132  unsigned int GetNumberOfFields() const;
133 
137  std::vector<std::string> GetFieldList() const;
138 
142  void CopyFieldList(const Self& kwl);
143 
147  virtual void Print(std::ostream& os, itk::Indent indent = 0) const;
148 
151 
154 
156  VectorDataKeywordlist(const Self& other);
157 
159  void operator =(const Self&);
160 
161 protected:
162 
163  virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
164 
165 private:
166 
167  std::string PrintField(FieldType field) const;
168  FieldType CopyOgrField(FieldType field);
170 
171 };
172 OTBVectorDataBase_EXPORT
173 extern std::ostream & operator <<(std::ostream& os, const VectorDataKeywordlist& kwl);
174 
175 }
176 
177 #endif
OTBCommon_EXPORT std::ostream & operator<<(std::ostream &os, const otb::StringToHTML &str)
std::pair< OGRFieldDefn *, OGRField > FieldType
std::vector< FieldType > FieldListType
this class handle the metadata of vector data.
virtual const char * GetNameOfClass() const