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 #include <drain/util/EnumFlags.h>
37 
38 
39 namespace drain
40 {
41 
42 namespace image
43 {
44 
45 struct GDAL {
46 
47  // Small
48  enum tag_t {
49  // Small indices reserved for basic XML
52  // GDAL
53  ROOT=10,
54  ITEM=11,
55  USER=12}; // , OFFSET, SCALE, UNITS}; // check CTEXT, maybe implement in XML
56 
57 };
58 
59 // https://www.awaresystems.be/imaging/tiff/ti fftags/gdal_metadata.html
60 class NodeGDAL: public GDAL, public drain::NodeXML<GDAL::tag_t> {
61 public:
62 
64  NodeGDAL(const tag_t & t = GDAL::ITEM);
65 
67  NodeGDAL(const NodeGDAL & node);
68 
69  // void setGDAL(const std::string & name, const drain::Variable & ctext, int sample, const std::string & role = "");
70  // void setGDAL(const drain::Variable & ctext, int sample=0, const std::string & role = "");
71  // void setGDAL(const std::string & name, const drain::Variable & ctext);
72 
73  template <class T>
74  inline
75  NodeGDAL & operator=(const T & x){
76  setText(x);
77  return *this;
78  }
79 
80  virtual
81  void handleType(const tag_t & t) override final;
82 
83 
84  // Multi-purpose key
85  std::string name;
86 
88  std::string sample; // string, to allow empty (unset) value
89 
91  std::string role;
92 
93 };
94 
95 //typedef NodeGDAL::xml_tree_t TreeGDAL;
96 typedef drain::UnorderedMultiTree<image::NodeGDAL> TreeGDAL;
97 
98 } // image::
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 template <>
112 const EnumDict<image::NodeGDAL::tag_t>::dict_t EnumDict<image::NodeGDAL::tag_t>::dict;
113 
114 DRAIN_TYPENAME(image::NodeGDAL);
115 
116 DRAIN_TYPENAME(image::NodeGDAL::tag_t);
117 
118 /*
119 template <>
120 inline
121 const char* TypeName<image::NodeGDAL>::get(){
122  return "XML-GDAL";
123 }
124 
125 template <>
126 inline
127 const char* TypeName<image::GDAL::tag_t>::get(){
128  return "XML-GDAL2";
129 }
130 */
131 
133 template <>
134 template <>
135 inline
136 image::TreeGDAL & image::TreeGDAL::operator()(const image::GDAL::tag_t & type){
137  return XML::xmlSetType(*this, type);
138  // this->data.setType(type);
139  // return *this;
140 }
141 
142 /*
143 SUPRESSED. Semantics become unclear, esp. if calling: const version of x& = tree("name") which returns a tree.
144 
145 
147 template <>
148 template <>
149 inline
150 image::TreeGDAL & image::TreeGDAL::operator()(const std::string & name){
151  this->data.name = name;
152  return *this;
153 }
154 */
155 
156 
157 
158 
159 } // drain::
160 
161 
162 
163 #endif
164 
165 
Definition: TreeXML.h:341
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:619
static TX & xmlSetType(TX &tree, const typename TX::node_data_t::xml_tag_t &type)
Definition: XML.h:559
Definition: TreeXML-GDAL.h:60
virtual void handleType(const tag_t &t) override final
Internal function called after setType()
Definition: TreeXML-GDAL.cpp:111
NodeGDAL(const tag_t &t=GDAL::ITEM)
Constructor.
Definition: TreeXML-GDAL.cpp:95
std::string sample
Standard GDAL attribute.
Definition: TreeXML-GDAL.h:88
std::string role
Standard GDAL attribute.
Definition: TreeXML-GDAL.h:91
Definition: DataSelector.cpp:1277
Definition: TreeXML-GDAL.h:45