Loading...
Searching...
No Matches
TreeXML-GDAL.h
1/*
2
3MIT License
4
5Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood 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/EnumFlags.h>
36#include "drain/util/TreeXML.h"
37#include "drain/util/UtilsXML.h"
38
39
40namespace drain
41{
42
43namespace image
44{
45
46struct GDAL {
47
48 // Small
49 enum tag_t {
50 // Small indices reserved for basic XML
53 // GDAL
54 ROOT=10,
55 ITEM=11,
56 USER=12}; // , OFFSET, SCALE, UNITS}; // check CTEXT, maybe implement in XML
57
58};
59
60// https://www.awaresystems.be/imaging/tiff/ti fftags/gdal_metadata.html
61class NodeGDAL: public GDAL, public drain::NodeXML<GDAL::tag_t> {
62public:
63
65 NodeGDAL(const tag_t & t = GDAL::ITEM);
66
68 NodeGDAL(const NodeGDAL & node);
69
70 // void setGDAL(const std::string & name, const drain::Variable & ctext, int sample, const std::string & role = "");
71 // void setGDAL(const drain::Variable & ctext, int sample=0, const std::string & role = "");
72 // void setGDAL(const std::string & name, const drain::Variable & ctext);
73
74 template <class T>
75 inline
76 NodeGDAL & operator=(const T & x){
77 setText(x);
78 return *this;
79 }
80
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
92protected:
93
94 virtual
95 void handleType() override final;
96
97 /*
98 virtual
99 void handleType(const tag_t & t) override final;
100 */
101};
102
103//typedef NodeGDAL::xml_tree_t TreeGDAL;
104typedef drain::UnorderedMultiTree<image::NodeGDAL> TreeGDAL;
105
106} // image::
107
109
114inline
115std::ostream & operator<<(std::ostream & ostr, const image::TreeGDAL & tree){
116 return image::TreeGDAL::node_data_t::toStream(ostr, tree);
117}
118
119template <>
120const EnumDict<image::NodeGDAL::tag_t>::dict_t EnumDict<image::NodeGDAL::tag_t>::dict;
121
122DRAIN_TYPENAME(image::NodeGDAL);
123
124DRAIN_TYPENAME(image::NodeGDAL::tag_t);
125
126/*
127template <>
128inline
129const char* TypeName<image::NodeGDAL>::get(){
130 return "XML-GDAL";
131}
132
133template <>
134inline
135const char* TypeName<image::GDAL::tag_t>::get(){
136 return "XML-GDAL2";
137}
138*/
139
141template <>
142template <>
143inline
144image::TreeGDAL & image::TreeGDAL::operator()(const image::GDAL::tag_t & type){
145 return UtilsXML::setType(*this, type);
146 // this->data.setType(type);
147 // return *this;
148}
149
150/*
151SUPRESSED. Semantics become unclear, esp. if calling: const version of x& = tree("name") which returns a tree.
152
153
155template <>
156template <>
157inline
158image::TreeGDAL & image::TreeGDAL::operator()(const std::string & name){
159 this->data.name = name;
160 return *this;
161}
162*/
163
164
165
166
167} // drain::
168
169
170
171#endif
172
173
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 & setType(TX &tree, const typename TX::node_data_t::xml_tag_t &type)
Definition UtilsXML.h:238
Definition TreeXML-GDAL.h:61
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
DRAIN_TYPENAME(void)
Add a specialization for each type of those you want to support.
Definition TreeXML-GDAL.h:46