USML
wposition.h
1 
5 #ifndef USML_TYPES_WPOSITION_H
6 #define USML_TYPES_WPOSITION_H
7 
8 #include <usml/ublas/ublas.h>
9 #include <usml/types/wvector.h>
10 
11 namespace usml {
12 namespace types {
15 
39 class USML_DECLSPEC wposition: public wvector
40 {
41 
42 public:
43 
54  wposition(unsigned rows = 1, unsigned cols = 1, double latitude = 0.0,
55  double longitude = 0.0, double altitude = 0.0);
56 
63  wposition(const wvector & other) :
64  wvector(other)
65  {
66  }
67 
78  template<class E1, class E2> inline wposition(
79  const vector_expression<E1>& latitude,
80  const vector_expression<E2>& longitude, double altitude = 0.0) :
81  wvector(latitude().size(), longitude().size())
82  {
83  for (int n = 0; n < latitude().size(); ++n) {
84  for (int m = 0; m < longitude().size(); ++m) {
85  this->latitude(n, m, latitude()(n));
86  this->longitude(n, m, longitude()(m));
87  this->altitude(n, m, altitude);
88  }
89  }
90  }
91 
92  //******************************
93  // Earth Radius static property
94 
100  static double earth_radius;
101 
124  static void compute_earth_radius(double latitude);
125 
126  // ******************************
127  // Altitude property (includes both matrix and indexed accessors)
128 
137  inline matrix<double> altitude() const
138  {
139  return rho() - earth_radius;
140  }
141 
149  template<class E> inline
150  void altitude(const matrix_expression<E>& altitude, bool no_alias = true)
151  {
152  rho(altitude + earth_radius, no_alias);
153  }
154 
163  inline double altitude(unsigned row, unsigned col) const
164  {
165  return rho(row, col) - earth_radius;
166  }
167 
176  inline void altitude(unsigned row, unsigned col, double altitude)
177  {
178  rho(row, col, altitude + earth_radius);
179  }
180 
181  //******************************
182  // Latitude property (includes both matrix and indexed accessors)
183 
192  inline matrix<double> latitude() const
193  {
194  return to_latitude(theta());
195  }
196 
204  template<class E> inline
205  void latitude(const matrix_expression<E>& latitude, bool no_alias = true)
206  {
207  theta(to_colatitude(latitude), no_alias);
208  }
209 
218  inline double latitude(unsigned row, unsigned col) const
219  {
220  return to_latitude(theta(row, col));
221  }
222 
231  inline void latitude(unsigned row, unsigned col, double latitude)
232  {
233  theta(row, col, to_colatitude(latitude));
234  }
235 
236  // ******************************
237  // Longitude property (includes both matrix and indexed accessors)
238 
247  inline matrix<double> longitude() const
248  {
249  return to_degrees(phi());
250  }
251 
259  template<class E> inline
260  void longitude(const matrix_expression<E>& longitude, bool no_alias = true)
261  {
262  phi(to_radians(longitude), no_alias);
263  }
264 
273  inline double longitude(unsigned row, unsigned col) const
274  {
275  return to_degrees(phi(row, col));
276  }
277 
286  inline void longitude(unsigned row, unsigned col, double longitude)
287  {
288  phi(row, col, to_radians(longitude));
289  }
290 
291 };
292 
294 } // end of ocean namespace
295 } // end of usml namespace
296 
297 #endif
wposition(const vector_expression< E1 > &latitude, const vector_expression< E2 > &longitude, double altitude=0.0)
Constructs a mesh of lat/long wpositions.
Definition: wposition.h:78
double latitude(unsigned row, unsigned col) const
Retrieves a single latitude component of geodetic earth coordinates.
Definition: wposition.h:218
static double earth_radius
Local radius of curvature in the area of operations.
Definition: wposition.h:100
math_traits< double >::value_type to_colatitude(math_traits< double >::const_reference t)
Definition: math_traits.h:761
matrix< double > longitude() const
Retrieves the longitude component of geodetic earth coordinates.
Definition: wposition.h:247
void latitude(const matrix_expression< E > &latitude, bool no_alias=true)
Defines the latitude component of geodetic earth coordinates.
Definition: wposition.h:205
World location in geodetic earth coordinates (latitude, longitude, and altitude). ...
Definition: wposition.h:39
math_traits< double >::value_type to_latitude(math_traits< double >::const_reference t)
Definition: math_traits.h:755
void longitude(const matrix_expression< E > &longitude, bool no_alias=true)
Defines the longitude component of geodetic earth coordinates.
Definition: wposition.h:260
void latitude(unsigned row, unsigned col, double latitude)
Defines a single latitude component of geodetic earth coordinates.
Definition: wposition.h:231
void altitude(unsigned row, unsigned col, double altitude)
Defines a single altitude above the mean sea level.
Definition: wposition.h:176
double altitude(unsigned row, unsigned col) const
Retrieves ia single altitude above the mean sea level.
Definition: wposition.h:163
wposition(const wvector &other)
Constructs a new wposition as a copy of an existing wposition.
Definition: wposition.h:63
void longitude(unsigned row, unsigned col, double longitude)
Defines a single longitude component of geodetic earth coordinates.
Definition: wposition.h:286
matrix< double > latitude() const
Retrieves the latitude component of geodetic earth coordinates.
Definition: wposition.h:192
void altitude(const matrix_expression< E > &altitude, bool no_alias=true)
Defines the altitude above the mean sea level.
Definition: wposition.h:150
math_traits< double >::value_type to_degrees(math_traits< double >::const_reference t)
Definition: math_traits.h:743
double longitude(unsigned row, unsigned col) const
Retrieves a single longitude component of geodetic earth coordinates.
Definition: wposition.h:273
matrix< double > altitude() const
Retrieves the altitude above the mean sea level.
Definition: wposition.h:137
World vector in spherical earth coordinates.
Definition: wvector.h:42
math_traits< double >::value_type to_radians(math_traits< double >::const_reference t)
Definition: math_traits.h:749