AccumulationConverter.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 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 
42 namespace drain {
43 
44 namespace image {
45 
47 
51 
52 public:
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  inline
95  double getNoDataMarker() const {
96  double value = 0.0;
97  double weight = 0.0;
98  encode(value, weight);
99  return value;
100  }
101 
102  virtual inline
103  double getNoReadingMarker() const {
104  return 0.0;
105  }
106 
107 
109  std::string type;
110 
111  virtual
112  std::ostream & toOstr(std::ostream & ostr) const {
113  //ostr << 5; ????
114  return ostr;
115  }
116 
117 
118 
119 
120 };
121 
122 
123 inline
124 std::ostream & operator<<(std::ostream & ostr, const AccumulationConverter & converter){
125  return converter.toOstr(ostr);
126 }
127 
128 } // image::
129 
130 
131 } // drain::
132 
133 #endif /*DataAccumulator_H_*/
134 
135 // Drain
Definition: DataSelector.cpp:1277
Converts raw data to values appropriate for accumulation.
Definition: AccumulationConverter.h:50
virtual bool decode(double &value, double &weight) const
Definition: AccumulationConverter.h:72
double getNoDataMarker() const
Returns the value when weight==0.0. Physically, this relates to results obtained under measurement ac...
Definition: AccumulationConverter.h:95
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:109
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 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