composite.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 
32 #pragma once
33 
34 // SINCE 2017/06/30,
35 /* cCreate = cAdd + cExtract dw
36  * cAdd adds current h5 (polar or cartesian).
37  */
38 
39 #ifndef RACK_COMPOSITING
40 #define RACK_COMPOSITING
41 
42 
43 //#include "data/Quantity.h"
44 #include "data/ODIM.h"
45 
46 //#include <drain/prog/Command.h>
47 #include <drain/prog/CommandInstaller.h>
48 
49 
50 #include "resources.h"
51 
52 
53 
54 namespace rack {
55 
56 // Combines program resources and compositing functions.
57 
59 
60 
61 protected:
62 
63  inline
64  Compositor(const std::string & name, const std::string & description) : drain::BasicCommand(name, description), weight(1.0) {
65  }
66 
67  inline
68  Compositor(const Compositor & cmd) : drain::BasicCommand(cmd), weight(cmd.weight) {
69  }
70 
71 
72 protected:
73 
74  static
75  void prepareBBox(const Composite & composite, const drain::BBox & cropGeo, drain::Rectangle<int> & cropImage);
76 
77  double applyTimeDecay(Composite & composite,double w, const ODIM & odim) const;
78 
79  // Filter is applied by getH5(), so OR function of: RackContext::CARTESIAN, RackContext::POLAR, RackContext::LATEST
80 
81  void add(Composite & composite, drain::Flags::ivalue_t inputFilter, bool updateSelector = true) const;
82  //void add(drain::Flags::value_t inputFilter, bool updateSelector = true) const;
83 
84  void addPolar(Composite & composite, const Hi5Tree & src) const;
85  void addCartesian(Composite & composite, const Hi5Tree & src) const;
86  //void extract(Composite & composite, const std::string & channels, const drain::Rectangle<double> & bbox = {0,0,0,0}) const;
87  void extract(Composite & composite, const std::string & channels, const std::string & crop = "") const;
88 
89  double weight;
90 
91  // Composite & getCompositeOLD() const;
92 
93 };
94 
95 
96 
97 }
98 
99 
100 
101 #endif
102 
103 // Rack
Container for geographical extent spanned by lowerLeft(x,y) and upperRight(x,y). Assumes longitude=x ...
Definition: BoundingBox.h:46
Simple implementation of Command: adds name , description and parameters .
Definition: Command.h:417
Cartesian composite (mosaic) of data from several radars.
Definition: Composite.h:105
Definition: composite.h:58
void addPolar(Composite &composite, const Hi5Tree &src) const
Definition: composite.cpp:227
void add(Composite &composite, drain::Flags::ivalue_t inputFilter, bool updateSelector=true) const
Definition: composite.cpp:112
void extract(Composite &composite, const std::string &channels, const std::string &crop="") const
Definition: composite.cpp:667
void addCartesian(Composite &composite, const Hi5Tree &src) const
Definition: composite.cpp:475
ODIM metadata (quantity, gain, offset, undetect, nodata, date, time)
Definition: ODIM.h:79
Definition: DataSelector.cpp:44
Rectange defined through lower left and upper right coordinates.
Definition: Rectangle.h:65