Loading...
Searching...
No Matches
AccumulatorGeo.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 ACCUMULATORGEO_H_
32#define ACCUMULATORGEO_H_
33
34#include "Accumulator.h"
35#include "GeoFrame.h"
36
37
38
39namespace drain
40{
41
42namespace image
43{
44
45
46
47class AccumulatorGeo : public Accumulator, public GeoFrame {
48
49public:
50
51 // Consider setFrameGeometry (protect this?)
52 virtual
53 inline
54 void setGeometry(unsigned int width, unsigned int height) {
55 GeoFrame::setGeometry(width, height);
56 // See allocate below, calling Accumulator::setGeometry(width, height);
57 }
58
59
61 virtual
62 inline
63 void allocate(){
64 //AccumulationArray::setGeometry(frameWidth,frameHeight);
65 if (!geometryIsSet()){
66 Logger mout(__FILE__, __FUNCTION__);
67 mout.warn("allocation requested for empty area" );
68 }
69 //AccumulationArray::setGeometry(frameWidth, frameHeight);
70 accArray.setGeometry(frameWidth, frameHeight);
71 };
72
73 inline
74 void reset(){
75 accArray.AccumulationArray::reset();
76 //AccumulationArray::reset();
77 GeoFrame::reset();
78 }
79
80 inline
81 void addUnprojected(double lon, double lat, double value, double weight){
82 int i,j;
83 size_t a;
84 deg2pix(lon,lat, i,j);
85 if ( (i>=0) && (i<static_cast<int>(accArray.getWidth())) && (j>=0) && (j< static_cast<int>(accArray.getHeight())) ){
86 a = accArray.data.address(i, j);
87 // std::cerr << "addUnprojected:" << i << ',' << j << '\t' << value << '/' << weight << '\n';
88 add(a, value, weight);
89 }
90 /*
91 else {
92 std::cerr << "addUnprojected: outside, " << lat << ',' << lon << '\t' << value << '/' << weight << '\n';
93 }
94 */
95 };
96
97 virtual
98 std::ostream & toStream(std::ostream & ostr) const;
99
100};
101
102inline
103std::ostream & operator<<(std::ostream &ostr, const AccumulatorGeo & accumulator){
104 return accumulator.AccumulatorGeo::toStream(ostr);
105}
106
107} // ::image
108} // ::drain
109
110#endif // AccumulatorGeo
111
112// Drain
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:312
Logger & warn(const TT &... args)
Possible error, but execution can continue.
Definition Log.h:430
ImageT< double > data
Accumulation array for actual data: , or generally .
Definition AccumulationArray.h:179
unsigned int getHeight() const
Returns the height of the accumulation array.
Definition AccumulationArray.h:162
virtual void setGeometry(size_t width, size_t height)
Changes the geometry of all the layers.
Definition AccumulationArray.cpp:47
unsigned int getWidth() const
Returns the width of the accumulation array.
Definition AccumulationArray.h:158
Definition AccumulatorGeo.h:47
virtual void allocate()
This should be called after setGeometry, unless the projection is used as a frame.
Definition AccumulatorGeo.h:63
Definition Accumulator.h:76
void add(const size_t i, double value, double weight)
Adds decoded data that applies natural scaling.
Definition Accumulator.h:147
AccumulationArray accArray
Todo: export.
Definition Accumulator.h:80
Array with georeferencing support.
Definition GeoFrame.h:58
bool geometryIsSet() const
Return true, if array area is greater than zero.
Definition GeoFrame.h:89
virtual void deg2pix(double lon, double lat, int &i, int &j) const
Projects geographic coordinates to image coordinates.
Definition GeoFrame.h:243
size_t address(size_t i) const
Computes the index location from image coordinates. Does not involve bit resolution.
Definition ImageFrame.h:148
Definition DataSelector.cpp:1277