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
40// #include <drain/util/Proj6.h>
41// See also RadarProj4 @ Geometry?
42#include "Constants.h"
43
44
45namespace rack {
46
48extern //static
50
52extern //static
54
55/*
56class RadarProj : public drain::Proj4 {
57
58public:
59
60 inline
61 void setSiteLocationDeg(double lon, double lat){
62 std::stringstream s;
63 s << "+proj=aeqd" << " +lon_0=" << lon << " +lat_0=" << lat << " +ellps=WGS84 +type=crs";
64 setProjectionSrc(s.str());
65 }
66
68 void setSiteLocation(double lon, double lat){
69 setSiteLocationDeg(lon*drain::RAD2DEG, lat*drain::RAD2DEG);
70 }
71
72 inline
73 void setLatLonProjection(){
74 setProjectionDst("+proj=latlong +ellps=WGS84 +datum=WGS84 +no_defs");
75 }
76
78 void determineBoundingBoxM(double range, double & xLL, double & yLL, double & xUR, double & yUR) const;
79
81 inline
82 void determineBoundingBoxM(double range, drain::Rectangle<double> & bbox) const {
83 determineBoundingBoxM(range, bbox.lowerLeft.x, bbox.lowerLeft.y, bbox.upperRight.x, bbox.upperRight.y);
84 }
85
86
87
89 //void determineBoundingBoxD(double range, double & xLL, double & yLL, double & xUR, double & yUR) const;
90
91
93 inline
94 void XXdetermineBoundingBoxD(double range, drain::Rectangle<double> & bbox) const {
95 determineBoundingBoxD(range, bbox.lowerLeft.x, bbox.lowerLeft.y, bbox.upperRight.x, bbox.upperRight.y);
96 }
97
98
99};
100
101*/
102
104// DEPRECATED
130 public:
131
132
133 Coordinates();
134
135 virtual
136 ~Coordinates(){};
137
138 // coordinator();
139
141 void setOrigin(const double &theta,const double &phi);
142
145
146 // inline
147 void setOriginDeg(const double &lat,const double &lon);
148 // origin(lat*M_PI/180.0 , lon*M_PI/180.0);
149 // };
150 //const double &lat,const double &lon);
151
153 void setBinPosition(const double &alpha, const float &range);
154
155 // \param alpha is azimuth in radians, \param range in metres.
156 //void setBinPosition(double alpha, float range);
157
159 // void getBoundingBox(float range,double &latMin,double &lonMin,double &latMax,double &lonMax);
160
162 void info(std::ostream &ostr = std::cout);
163
164 // site positional
165 // double cos_theta;
166
168 // (Site normal unit vector not needed as such)
169 double p01, p02, p03;
170
172 double p1, p2, p3;
173
175 double e11, e12, e13;
176
178 double e21, e22, e23;
179
181 mutable double thetaBin;
182
184 mutable double phiBin;
185
187 inline
188 double binLatitudeDeg(){ return thetaBin/M_PI*180.0;};
189 //phi_bin/M_PI*180.0;};
190 //
191
193 inline
194 double binLongitudeDeg(){ return phiBin/M_PI*180.0;};
195 // theta_bin/M_PI*180.0;};;
196 //
197
198 //drain::Proj6 proj;
199
200 /*
201 inline
202 virtual std::string getProjectionString(){
203 std::stringstream sstr;
204 sstr << "+proj=longlat +R=" << EARTH_RADIUS << std::string(" +no_defs");
205 return sstr.str();
206 };
207 */
208 };
209
210} // ::rack
211
212#endif
213
214// Rack
Policies for coordinate underflows and overflows.
Definition CoordinatePolicy.h:100
Simple spherical coordinate computation. Does not handle projections, but earth coords.
Definition Coordinates.h:129
void info(std::ostream &ostr=std::cout)
Determines the bounding box (in degrees) of the circular radar measurement area.
Definition Coordinates.cpp:297
double e21
Elelements of the North pointing site unit vector [e21 e22 e23].
Definition Coordinates.h:178
void setBinPosition(const double &alpha, const float &range)
Definition Coordinates.cpp:209
double phiBin
Bin longitude in radians after calling bin_position().
Definition Coordinates.h:184
void setOrigin(const double &theta, const double &phi)
Radar site latitude and longitude in radians.
Definition Coordinates.cpp:167
double binLongitudeDeg()
Bin longitude in degrees after calling bin_position().
Definition Coordinates.h:194
double e11
Elelements of the East pointing site unit vector [e11 e12 e13].
Definition Coordinates.h:175
void setOriginDeg(const double &lat, const double &lon)
Set target projection. // void setProjection(const std::string &s);.
Definition Coordinates.cpp:201
double binLatitudeDeg()
Bin latitude in degrees after calling bin_position().
Definition Coordinates.h:188
double p01
Radar position vector (from Earth center to surface.
Definition Coordinates.h:169
double thetaBin
Bin latitude in radians after calling bin_position().
Definition Coordinates.h:181
double p1
Earth centered coordinates [p_1 p_2 p_3] of the current bin position.
Definition Coordinates.h:172
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:53
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:49