Loading...
Searching...
No Matches
AccumulationConverter.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 AccumulationConverter_H_
32#define AccumulationConverter_H_
33
34
35//#include "drain/util/Rectangle.h"
36//#include "AccumulatorGeo.h"
37
38#include <string>
39
40// using namespace std;
41
42namespace drain {
43
44namespace image {
45
47
51
52public:
53
54 virtual
56
58
62 virtual inline
63 bool decode(double & value) const { return true; };
64
67
71 virtual inline
72 bool decode(double & value, double & weight) const { return true; };
73
75 virtual inline
76 void encode(double & value, double & weight) const {};
77
79 virtual inline
80 void encodeWeight(double & weight) const {};
81
83 virtual inline
84 void encodeCount(double & weight) const {};
85
86 virtual inline
87 void encodeStdDev(double & stdDev) const {};
88
90 virtual inline
91 void encodeDiff(double & diff) const {};
92
94 virtual // inline
95 double getNoDataMarker() const = 0; /* {
96 double value = 0.0;
97 double weight = 0.0;
98 encode(value, weight); // infinite loop, if encode uses marker?
99 return value;
100 }*/
101
105 virtual // inline
106 double getWeightNoDataMarker() const = 0; /* {
107 double value = 0.0;
108 double weight = 0.0;
109 encode(value, weight);
110 return weight;
111 }
112 */
113
115 virtual // inline
116 double getNoReadingMarker() const = 0; /* {
117 return 0.0;
118 }*/
119
120
122 std::string type;
123
124 virtual
125 std::ostream & toOstr(std::ostream & ostr) const {
126 //ostr << 5; ????
127 return ostr;
128 }
129
130
131
132
133};
134
135
136inline
137std::ostream & operator<<(std::ostream & ostr, const AccumulationConverter & converter){
138 return converter.toOstr(ostr);
139}
140
141} // image::
142
143
144} // drain::
145
146#endif /*DataAccumulator_H_*/
147
148// Drain
Definition DataSelector.cpp:1277
Converts raw data to values appropriate for accumulation.
Definition AccumulationConverter.h:50
virtual double getNoReadingMarker() const =0
Returns a marker value which indicates that although data has been measured, it is not within require...
virtual bool decode(double &value, double &weight) const
Definition AccumulationConverter.h:72
virtual void encode(double &value, double &weight) const
Converts natural-scale data to storage data, applying marker codes if needed.
Definition AccumulationConverter.h:76
std::string type
Default output storage data type.
Definition AccumulationConverter.h:122
virtual bool decode(double &value) const
Converts storage data to natural scale.
Definition AccumulationConverter.h:63
virtual void encodeWeight(double &weight) const
Converts natural-scale data to storage data, applying marker codes if needed.
Definition AccumulationConverter.h:80
virtual double getNoDataMarker() const =0
Returns the value when weight==0.0. Physically, this relates to results obtained under measurement ac...
virtual double getWeightNoDataMarker() const =0
virtual void encodeCount(double &weight) const
Converts natural-scale data to storage data, applying marker codes if needed.
Definition AccumulationConverter.h:84
virtual void encodeDiff(double &diff) const
When using unsigned types, encoding typically requires adding a positive bias and scaling the data.
Definition AccumulationConverter.h:91