TreeXML-GDAL.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 /*
27 Part of Rack development has been done in the BALTRAD projects part-financed
28 by the European Union (European Regional Development Fund and European
29 Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30 */
31 #ifndef DRAIN_FILE_GDAL_XML
32 #define DRAIN_FILE_GDAL_XML
33 
34 #include "drain/util/Flags.h"
35 #include "drain/util/TreeXML.h"
36 
37 
38 namespace drain
39 {
40 
41 namespace image
42 {
43 
44 struct GDAL {
45 
46  // Small
47  enum tag_t {
48  // Small indices reserved for basic XML
51  // GDAL
52  ROOT=10,
53  ITEM=11,
54  USER=12}; // , OFFSET, SCALE, UNITS}; // check CTEXT, maybe implement in XML
55 
56 };
57 
58 // https://www.awaresystems.be/imaging/tiff/ti fftags/gdal_metadata.html
59 class NodeGDAL: public GDAL, public drain::NodeXML<GDAL::tag_t> {
60 public:
61 
63  NodeGDAL(const tag_t & t = GDAL::ITEM);
64 
66  NodeGDAL(const NodeGDAL & node);
67 
68  // void setGDAL(const std::string & name, const drain::Variable & ctext, int sample, const std::string & role = "");
69  // void setGDAL(const drain::Variable & ctext, int sample=0, const std::string & role = "");
70  // void setGDAL(const std::string & name, const drain::Variable & ctext);
71 
72  template <class T>
73  inline
74  NodeGDAL & operator=(const T & x){
75  setText(x);
76  return *this;
77  }
78 
79  virtual
80  void setType(const tag_t & t);
81 
82 
83  // Multi-purpose key
84  std::string name;
85 
87  std::string sample; // string, to allow empty (unset) value
88 
90  std::string role;
91 
92 };
93 
94 //typedef NodeGDAL::xml_tree_t TreeGDAL;
95 typedef drain::UnorderedMultiTree<image::NodeGDAL> TreeGDAL;
96 
97 } // image::
98 
99 
101 
106 inline
107 std::ostream & operator<<(std::ostream & ostr, const image::TreeGDAL & tree){
108  return image::TreeGDAL::node_data_t::toStream(ostr, tree);
109 }
110 
111 
112 
113 DRAIN_TYPENAME(image::NodeGDAL);
114 
115 DRAIN_TYPENAME(image::NodeGDAL::tag_t);
116 
117 /*
118 template <>
119 inline
120 const char* TypeName<image::NodeGDAL>::get(){
121  return "XML-GDAL";
122 }
123 
124 template <>
125 inline
126 const char* TypeName<image::GDAL::tag_t>::get(){
127  return "XML-GDAL2";
128 }
129 */
130 
132 template <>
133 template <>
134 inline
135 image::TreeGDAL & image::TreeGDAL::operator()(const image::GDAL::tag_t & type){
136  this->data.setType(type);
137  return *this;
138 }
139 
140 /*
141 SUPRESSED. Semantics become unclear, esp. if calling: const version of x& = tree("name") which returns a tree.
142 
143 
145 template <>
146 template <>
147 inline
148 image::TreeGDAL & image::TreeGDAL::operator()(const std::string & name){
149  this->data.name = name;
150  return *this;
151 }
152 */
153 
154 
155 
156 
157 } // drain::
158 
159 
160 
161 #endif
162 
163 
Definition: TreeXML.h:135
NodeXML & setText(const S &value)
Assign the text content of this node. If the node type is undefined, set it to CTEXT.
Definition: TreeXML.h:521
Definition: TreeXML-GDAL.h:59
NodeGDAL(const tag_t &t=GDAL::ITEM)
Constructor.
Definition: TreeXML-GDAL.cpp:68
std::string sample
Standard GDAL attribute.
Definition: TreeXML-GDAL.h:87
std::string role
Standard GDAL attribute.
Definition: TreeXML-GDAL.h:90
Definition: DataSelector.cpp:1277
Definition: TreeXML-GDAL.h:44