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/TreeXML.h"
36#include <drain/util/EnumFlags.h>
37
38
39namespace drain
40{
41
42namespace image
43{
44
45struct 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
60class NodeGDAL: public GDAL, public drain::NodeXML<GDAL::tag_t> {
61public:
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;
96typedef drain::UnorderedMultiTree<image::NodeGDAL> TreeGDAL;
97
98} // image::
99
101
106inline
107std::ostream & operator<<(std::ostream & ostr, const image::TreeGDAL & tree){
108 return image::TreeGDAL::node_data_t::toStream(ostr, tree);
109}
110
111template <>
112const EnumDict<image::NodeGDAL::tag_t>::dict_t EnumDict<image::NodeGDAL::tag_t>::dict;
113
114DRAIN_TYPENAME(image::NodeGDAL);
115
116DRAIN_TYPENAME(image::NodeGDAL::tag_t);
117
118/*
119template <>
120inline
121const char* TypeName<image::NodeGDAL>::get(){
122 return "XML-GDAL";
123}
124
125template <>
126inline
127const char* TypeName<image::GDAL::tag_t>::get(){
128 return "XML-GDAL2";
129}
130*/
131
133template <>
134template <>
135inline
136image::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/*
143SUPRESSED. Semantics become unclear, esp. if calling: const version of x& = tree("name") which returns a tree.
144
145
147template <>
148template <>
149inline
150image::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:679
Definition TreeXML-GDAL.h:60
virtual void handleType(const tag_t &t) override final
Internal function called after setType()
Definition TreeXML-GDAL.cpp:111
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
DRAIN_TYPENAME(void)
Add a specialization for each type of those you want to support.
Definition TreeXML-GDAL.h:45