Loading...
Searching...
No Matches
Coordinates.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__COORDINATES_
32#define RADAR__COORDINATES_ "radar__coordinates 0.2, May 16 2011 Markus.Peura@fmi.fi"
33
34#include <drain/image/CoordinatePolicy.h>
35#include <math.h>
36
37#include <iostream>
38#include <ostream>
39#include <sstream>
40
41// #include <drain/util/Proj6.h>
42// See also RadarProj4 @ Geometry?
43#include <drain/util/Rectangle.h>
44#include "Constants.h"
45
46
47namespace rack {
48
50extern //static
52
54extern //static
56
57/*
58class RadarProj : public drain::Proj4 {
59
60public:
61
62 inline
63 void setSiteLocationDeg(double lon, double lat){
64 std::stringstream s;
65 s << "+proj=aeqd" << " +lon_0=" << lon << " +lat_0=" << lat << " +ellps=WGS84 +type=crs";
66 setProjectionSrc(s.str());
67 }
68
70 void setSiteLocation(double lon, double lat){
71 setSiteLocationDeg(lon*drain::RAD2DEG, lat*drain::RAD2DEG);
72 }
73
74 inline
75 void setLatLonProjection(){
76 setProjectionDst("+proj=latlong +ellps=WGS84 +datum=WGS84 +no_defs");
77 }
78
80 void determineBoundingBoxM(double range, double & xLL, double & yLL, double & xUR, double & yUR) const;
81
83 inline
84 void determineBoundingBoxM(double range, drain::Rectangle<double> & bbox) const {
85 determineBoundingBoxM(range, bbox.lowerLeft.x, bbox.lowerLeft.y, bbox.upperRight.x, bbox.upperRight.y);
86 }
87
88
89
91 //void determineBoundingBoxD(double range, double & xLL, double & yLL, double & xUR, double & yUR) const;
92
93
95 inline
96 void XXdetermineBoundingBoxD(double range, drain::Rectangle<double> & bbox) const {
97 determineBoundingBoxD(range, bbox.lowerLeft.x, bbox.lowerLeft.y, bbox.upperRight.x, bbox.upperRight.y);
98 }
99
100
101};
102
103*/
104
106// DEPRECATED
132 public:
133
134
135 Coordinates();
136
137 virtual
138 ~Coordinates(){};
139
140 // coordinator();
141
143 void setOrigin(const double &theta,const double &phi);
144
147
148 // inline
149 void setOriginDeg(const double &lat,const double &lon);
150 // origin(lat*M_PI/180.0 , lon*M_PI/180.0);
151 // };
152 //const double &lat,const double &lon);
153
155 void setBinPosition(const double &alpha, const float &range);
156
157 // \param alpha is azimuth in radians, \param range in metres.
158 //void setBinPosition(double alpha, float range);
159
161 // void getBoundingBox(float range,double &latMin,double &lonMin,double &latMax,double &lonMax);
162
164 void info(std::ostream &ostr = std::cout);
165
166 // site positional
167 // double cos_theta;
168
170 // (Site normal unit vector not needed as such)
171 double p01, p02, p03;
172
174 double p1, p2, p3;
175
177 double e11, e12, e13;
178
180 double e21, e22, e23;
181
183 mutable double thetaBin;
184
186 mutable double phiBin;
187
189 inline
190 double binLatitudeDeg(){ return thetaBin/M_PI*180.0;};
191 //phi_bin/M_PI*180.0;};
192 //
193
195 inline
196 double binLongitudeDeg(){ return phiBin/M_PI*180.0;};
197 // theta_bin/M_PI*180.0;};;
198 //
199
200 //drain::Proj6 proj;
201
202 /*
203 inline
204 virtual std::string getProjectionString(){
205 std::stringstream sstr;
206 sstr << "+proj=longlat +R=" << EARTH_RADIUS << std::string(" +no_defs");
207 return sstr.str();
208 };
209 */
210 };
211
212} // ::rack
213
214#endif
215
216// Rack
Policies for coordinate underflows and overflows.
Definition CoordinatePolicy.h:106
Simple spherical coordinate computation. Does not handle projections, but earth coords.
Definition Coordinates.h:131
void info(std::ostream &ostr=std::cout)
Determines the bounding box (in degrees) of the circular radar measurement area.
Definition Coordinates.cpp:299
double e21
Elelements of the North pointing site unit vector [e21 e22 e23].
Definition Coordinates.h:180
void setBinPosition(const double &alpha, const float &range)
Definition Coordinates.cpp:211
double phiBin
Bin longitude in radians after calling bin_position().
Definition Coordinates.h:186
void setOrigin(const double &theta, const double &phi)
Radar site latitude and longitude in radians.
Definition Coordinates.cpp:169
double binLongitudeDeg()
Bin longitude in degrees after calling bin_position().
Definition Coordinates.h:196
double e11
Elelements of the East pointing site unit vector [e11 e12 e13].
Definition Coordinates.h:177
void setOriginDeg(const double &lat, const double &lon)
Set target projection. // void setProjection(const std::string &s);.
Definition Coordinates.cpp:203
double binLatitudeDeg()
Bin latitude in degrees after calling bin_position().
Definition Coordinates.h:190
double p01
Radar position vector (from Earth center to surface.
Definition Coordinates.h:171
double thetaBin
Bin latitude in radians after calling bin_position().
Definition Coordinates.h:183
double p1
Earth centered coordinates [p_1 p_2 p_3] of the current bin position.
Definition Coordinates.h:174
Definition DataSelector.cpp:44
const drain::image::CoordinatePolicy limitCoords(drain::image::EdgePolicy::LIMIT, drain::image::EdgePolicy::LIMIT, drain::image::EdgePolicy::LIMIT, drain::image::EdgePolicy::LIMIT)
Default coordinate policy; no wrapping or mirroring at edges.
Definition Coordinates.h:55
const drain::image::CoordinatePolicy polarLeftCoords(drain::image::EdgePolicy::POLAR, drain::image::EdgePolicy::WRAP, drain::image::EdgePolicy::LIMIT, drain::image::EdgePolicy::WRAP)
Standard (?) orientation of polar coords in radar data.
Definition Coordinates.h:51