Loading...
Searching...
No Matches
cartesian-bbox.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
32//#pragma once
33
34#ifndef RACK_CART_BBOX
35#define RACK_CART_BBOX
36
37
38
39// #include <drain/prog/CommandRegistry.h>
40// #include <drain/prog/CommandInstaller.h>
41#include "resources.h"
42
43
44
45namespace rack {
46
47
48
50
51public:
52
53 CartesianBBox() : drain::BasicCommand(__FUNCTION__, "Bounding box of the Cartesian product.") {
54 /*
55 RackResources & resources = getResources();
56 getParameters().link("llLon", resources.bbox.lowerLeft.x = 0.0, "deg");
57 getParameters().link("llLat", resources.bbox.lowerLeft.y = 0.0, "deg");
58 getParameters().link("urLon", resources.bbox.upperRight.x = 0.0, "deg");
59 getParameters().link("urLat", resources.bbox.upperRight.y = 0.0, "deg");
60 */
61 getParameters().link("llLon", bbox.lowerLeft.x = 0.0, "deg|m");
62 getParameters().link("llLat", bbox.lowerLeft.y = 0.0, "deg|m");
63 getParameters().link("urLon", bbox.upperRight.x = 0.0, "deg|m");
64 getParameters().link("urLat", bbox.upperRight.y = 0.0, "deg|m");
65 };
66
68 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
69 }
70
71 inline
72 void exec() const {
73 RackContext & ctx = getContext<RackContext>();
74 ctx.composite.setBoundingBox(bbox);
75 // std::cerr << __FILE__ << ' ' << bbox << std::endl;
76 // drain::Logger mout(ctx.log, __FILE__, __FUNCTION__);
77
78 }
79
80private:
81
83 // bool isMetric(double x, double limit){ -> GeoFrame
84
85};
86
87
89
90public:
91
92 CartesianBBoxReset() : drain::BasicCommand(__FUNCTION__, "Resets the bounding box (to be set again according to the next radar data).") {};
93
94 inline
95 void exec() const {
96 //RackResources & resources = getResources();
97 //resources.bbox.set(0,0,0,0);
98 //resources.composite.setBoundingBoxD(0,0,0,0);
99 RackContext & ctx = getContext<RackContext>();
100 ctx.composite.setBoundingBox(0,0,0,0);
101 };
102
103};
104//static RackLetAdapter<CartesianBBoxReset> cBBoxReset("cBBoxReset");
105
111class CartesianBBoxTest : public drain::BasicCommand { // public drain::SimpleCommand<int> { //
112
113public:
114
115 //mutable bool overlap;
116
117 /*
118 CartesianBBoxTest() : drain::SimpleCommand<int>(__FUNCTION__, "Tests whether the radar range is inside the composite.",
119 "mode", 0, "If no overlap, sets INPUT_ERROR flag, else resets. If also mode>1, exit with return value <mode>." ) {
120 };*/
121
122 CartesianBBoxTest() : drain::BasicCommand(__FUNCTION__, "Tests whether the radar range is inside the composite."){
123 getParameters().link("mode", mode);
124 }
126 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
127 }
128
129 /*
130 virtual
131 inline
132 void run(const std::string & params = ""){
133 SimpleCommand<int>::run(params);
134 value = static_cast<int>(overlap);
135 }
136 */
137 mutable
138 int mode;
139
140 void exec() const;
141
142};
143
144
146
147public:
148
150
151 CartesianBBoxTile() : drain::BasicCommand(__FUNCTION__, "Redefines bbox and compositing array size for several radars, applying original projection and resolution. See --cSize, --cBBox, --cProj.") {
152 getParameters().link("llLon", bbox.lowerLeft.x = 0.0, "deg");
153 getParameters().link("llLat", bbox.lowerLeft.y = 0.0, "deg");
154 getParameters().link("urLon", bbox.upperRight.x = 0.0, "deg");
155 getParameters().link("urLat", bbox.upperRight.y = 0.0, "deg");
156 }
157
159 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
160 }
161
162 void exec() const;
163
164};
165
166
167} // rack::
168
169
170
171#endif
172
173// Rack
Simple implementation of Command: adds name , description and parameters .
Definition Command.h:424
void copyStruct(const ReferenceMap &m, const T &src, T &dst, extLinkPolicy policy=RESERVE)
Experimental. Copies references and values of a structure to another.
Definition ReferenceMap.h:399
void setBoundingBox(double lonLL, double latLL, double lonUR, double latUR)
Sets bounding box in degrees OR in metres in the target coordinate system.
Definition GeoFrame.cpp:90
Definition cartesian-bbox.h:88
void exec() const
Run the command with current parameter values.
Definition cartesian-bbox.h:95
Definition cartesian-bbox.h:111
void exec() const
Run the command with current parameter values.
Definition cartesian-bbox.cpp:56
Definition cartesian-bbox.h:145
void exec() const
Run the command with current parameter values.
Definition cartesian-bbox.cpp:180
Definition cartesian-bbox.h:49
void exec() const
Run the command with current parameter values.
Definition cartesian-bbox.h:72
Resources provided separately for each thread.
Definition resources.h:67
Composite composite
TODO: inherit from ProductBase.
Definition resources.h:120
Definition DataSelector.cpp:44
Rectange defined through lower left and upper right coordinates.
Definition Rectangle.h:65