Loading...
Searching...
No Matches
RadarProj.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 RADAR_PROJ_
32#define RADAR_PROJ_ "RadarProj 2023 Markus Peura fmi.fi"
33
34#include <math.h>
35
36#include <iostream>
37#include <ostream>
38#include <sstream>
39
40#include <drain/util/Proj6.h>
41#include <drain/util/Rectangle.h>
42#include <drain/util/Units.h>
43
44#include "Constants.h"
45//#include "radar.h"
46
47// See also RadarProj4 @ Geometry?
48
49namespace rack {
50
54class RadarProj4 : public drain::Proj6 {
55
56public:
57
59 /*
60 * \param lon - longitude of the location, in degrees
61 * \param lat - longitude of the location, in degrees
62 */
63 RadarProj4(double lon=0.0, double lat=0.0){
64 setLocation(lon, lat);
65 }
66
68 /*
69 * \param lon - longitude of the location, in degrees
70 * \param lat - longitude of the location, in degrees
71 */
72 inline
73 void setLocation(double lon, double lat){
74 std::stringstream sstr;
75 sstr << "+proj=aeqd" << " +lon_0=" << lon << " +lat_0=" << lat << " +ellps=WGS84 +type=crs";
76 setProjectionSrc(sstr.str());
77 };
78
80 inline
81 void getBoundingBox(double range, double & lonLL, double & latLL, double & lonUR, double & latUR) const {
82 projectFwd(5.0/4.0*M_PI, ::sqrt(2.0)*range, lonLL, latLL);
83 projectFwd(1.0/4.0*M_PI, ::sqrt(2.0)*range, lonUR, latUR);
84 }
85
87 inline
88 void getBoundingBoxDeg(double range, double & lonLL, double & latLL, double & lonUR, double & latUR) const {
89 getBoundingBox(range, lonLL, latLL, lonUR, latUR);
90 lonLL *= drain::RAD2DEG;
91 latLL *= drain::RAD2DEG;
92 lonUR *= drain::RAD2DEG;
93 latUR *= drain::RAD2DEG;
94 }
95
96
97
98};
99
100class RadarProj : public drain::Proj6 {
101
102public:
103
105 /*
106 * \param lon - longitude of the location, in degrees
107 * \param lat - longitude of the location, in degrees
108 */
109 RadarProj(double lonDeg=0.0, double latDeg=0.0){
110 setSiteLocationDeg(lonDeg, latDeg);
111 }
112
114 /*
115 * \param lon - longitude of the location, in degrees
116 * \param lat - longitude of the location, in degrees
117 inline
118 void setLocation(double lon, double lat){
119 std::stringstream sstr;
120 sstr << "+proj=aeqd" << " +lon_0=" << lon << " +lat_0=" << lat << " +ellps=WGS84 +type=crs"; //
121 setProjectionSrc(sstr.str());
122 };
123 */
124
126 /*
127 * \param lon - longitude of the location, in degrees
128 * \param lat - longitude of the location, in degrees
129 */
130 inline
131 void setSiteLocationDeg(double lon, double lat){
132 std::stringstream s;
133 s << "+proj=aeqd" << " +lon_0=" << lon << " +lat_0=" << lat << " +ellps=WGS84 +type=crs"; // +type=crs
134 setProjectionSrc(s.str());
135 }
136
138 /*
139 * \param lon - longitude of the location in radians
140 * \param lat - longitude of the location in degrees
141 */
142 inline
143 void setSiteLocationRad(double lon, double lat){
144 setSiteLocationDeg(lon*drain::RAD2DEG, lat*drain::RAD2DEG);
145 }
146
148 inline
149 void getBoundingBox(double range, double & lonLL, double & latLL, double & lonUR, double & latUR) const {
150 projectFwd(5.0/4.0*M_PI, ::sqrt(2.0)*range, lonLL, latLL);
151 projectFwd(1.0/4.0*M_PI, ::sqrt(2.0)*range, lonUR, latUR);
152 }
153
155 inline
156 void getBoundingBoxDeg(double range, double & lonLL, double & latLL, double & lonUR, double & latUR) const {
157 getBoundingBox(range, lonLL, latLL, lonUR, latUR);
158 lonLL *= drain::RAD2DEG;
159 latLL *= drain::RAD2DEG;
160 lonUR *= drain::RAD2DEG;
161 latUR *= drain::RAD2DEG;
162 }
163
164
165 inline
166 void setLatLonProjection(){
167 setProjectionDst("+proj=latlong +ellps=WGS84 +datum=WGS84 +no_defs");
168 }
169
171 void determineBoundingBoxM(double range, double & xLL, double & yLL, double & xUR, double & yUR) const;
172
174 inline
175 void determineBoundingBoxM(double range, drain::Rectangle<double> & bbox) const {
176 determineBoundingBoxM(range, bbox.lowerLeft.x, bbox.lowerLeft.y, bbox.upperRight.x, bbox.upperRight.y);
177 }
178
180 //void determineBoundingBoxD(double range, double & xLL, double & yLL, double & xUR, double & yUR) const;
181
182
184 /*
185 inline
186 void determineBoundingBoxD(double range, drain::Rectangle<double> & bbox) const {
187 determineBoundingBoxD(range, bbox.lowerLeft.x, bbox.lowerLeft.y, bbox.upperRight.x, bbox.upperRight.y);
188 }
189 */
190
191
192};
193
194
196// DEPRECATED
222} // ::rack
223
224#endif
225
226// Rack
Definition Proj6.h:64
void setProjectionSrc(const T &...args)
Sets source projection.
Definition Proj6.h:98
void projectFwd(double &x, double &y) const
Forward projection (in-place)
Definition Proj6.h:186
void setProjectionDst(const T &...args)
Sets destination projection.
Definition Proj6.h:127
Definition RadarProj.h:54
void setLocation(double lon, double lat)
Sets location of the radar and the azimuthal equidistant (AEQD) projection accordingly.
Definition RadarProj.h:73
void getBoundingBoxDeg(double range, double &lonLL, double &latLL, double &lonUR, double &latUR) const
Bounding box in degrees.
Definition RadarProj.h:88
void getBoundingBox(double range, double &lonLL, double &latLL, double &lonUR, double &latUR) const
Bounding box in radians.
Definition RadarProj.h:81
RadarProj4(double lon=0.0, double lat=0.0)
Sets location of the radar and the azimuthal equidistant (AEQD) projection accordingly.
Definition RadarProj.h:63
Definition RadarProj.h:100
RadarProj(double lonDeg=0.0, double latDeg=0.0)
Sets location of the radar and the azimuthal equidistant (AEQD) projection accordingly.
Definition RadarProj.h:109
void getBoundingBoxDeg(double range, double &lonLL, double &latLL, double &lonUR, double &latUR) const
Bounding box in degrees.
Definition RadarProj.h:156
void determineBoundingBoxM(double range, drain::Rectangle< double > &bbox) const
Given radar's range, returns the metric bounding box using the current projection.
Definition RadarProj.h:175
void setSiteLocationDeg(double lon, double lat)
Sets location of the radar and the azimuthal equidistant (AEQD) projection accordingly.
Definition RadarProj.h:131
void setSiteLocationRad(double lon, double lat)
Sets location of the radar and the azimuthal equidistant (AEQD) projection accordingly.
Definition RadarProj.h:143
void determineBoundingBoxM(double range, double &xLL, double &yLL, double &xUR, double &yUR) const
Given radar's range, returns the metric bounding box using the current projection.
Definition RadarProj.cpp:41
void getBoundingBox(double range, double &lonLL, double &latLL, double &lonUR, double &latUR) const
Bounding box in radians.
Definition RadarProj.h:149
Definition DataSelector.cpp:44
Rectange defined through lower left and upper right coordinates.
Definition Rectangle.h:65