OmniSciDB  cde582ebc3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Transform4326ToUTM Class Reference

#include <Utm.h>

Public Member Functions

DEVICE ALWAYS_INLINE Transform4326ToUTM (unsigned const srid, double const x, double const y)
 
DEVICE ALWAYS_INLINE double calculateX () const
 
DEVICE ALWAYS_INLINE double calculateY () const
 

Private Attributes

unsigned const srid_
 
double eta_
 
double xi_
 
bool small_dlambda_
 

Detailed Description

Definition at line 120 of file Utm.h.

Constructor & Destructor Documentation

DEVICE ALWAYS_INLINE Transform4326ToUTM::Transform4326ToUTM ( unsigned const  srid,
double const  x,
double const  y 
)
inline

Definition at line 134 of file Utm.h.

References eta_, shared::fastAtanh(), shared::fastCos(), shared::fastSin(), anonymous_namespace{Utm.h}::n, math_consts::rad_div_deg, small_dlambda_, srid_, and xi_.

137  : srid_(srid) {
138  unsigned const zone = srid_ % 100u;
139  double const x0 = zone * 6.0 - 183;
140  double const dlambda = (x - x0) * math_consts::rad_div_deg;
141  small_dlambda_ = -1.0 / 12 <= dlambda && dlambda <= 1.0 / 12;
142  double const phi = y * math_consts::rad_div_deg;
143  double const c = 2 * sqrt(n) / (1 + n); // Boost will have a constexpr sqrt
144 
145  // https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system#Simplified_formulae
146  double const t = sinh(atanh(sin(phi)) - c * atanh(c * sin(phi)));
147  if (small_dlambda_) {
148  eta_ = shared::fastAtanh(shared::fastSin(dlambda) / sqrt(1 + t * t));
149  xi_ = atan(t / shared::fastCos(dlambda));
150  } else {
151  eta_ = atanh(sin(dlambda) / sqrt(1 + t * t));
152  xi_ = atan(t / cos(dlambda));
153  }
154  /* Calculate scaling. May be used in the future.
155  double sigma_sum = 0;
156  for (unsigned j = N; j; --j) {
157  sigma_sum += 2 * j * alphas[j] * cos(2 * j * xi_) * cosh(2 * j * eta_);
158  }
159  sigma_ = 1 + sigma_sum;
160  for (unsigned j = N; j; --j) {
161  tau_ += 2 * j * alphas[j] * sin(2 * j * xi_) * sinh(2 * j * eta_);
162  }
163  k_ = k0_A *
164  sqrt((1 + sq(tan(phi) * (1 - n) / (1 + n))) * (sq(sigma_) + sq(tau_)) /
165  (sq(t) + sq(cos(dlambda)))) /
166  a;
167  */
168  }
DEVICE double fastSin(double const x)
Definition: misc.h:239
DEVICE double fastCos(double const x)
Definition: misc.h:221
constexpr double rad_div_deg
Definition: math_consts.h:21
unsigned const srid_
Definition: Utm.h:122
double xi_
Definition: Utm.h:124
DEVICE double fastAtanh(double const x)
Definition: misc.h:215
double eta_
Definition: Utm.h:123
constexpr double n
Definition: Utm.h:38
bool small_dlambda_
Definition: Utm.h:125

+ Here is the call graph for this function:

Member Function Documentation

DEVICE ALWAYS_INLINE double Transform4326ToUTM::calculateX ( ) const
inline

Definition at line 170 of file Utm.h.

References anonymous_namespace{Utm.h}::alphas, anonymous_namespace{Utm.h}::E0, eta_, shared::fastSinh(), anonymous_namespace{Utm.h}::k0_A, anonymous_namespace{Utm.h}::N, small_dlambda_, and xi_.

Referenced by conv_4326_utm(), and transform_4326_utm_x().

170  {
171  double sum = 0; // Sum in reverse to add smallest numbers first
172  if (small_dlambda_) {
173  for (unsigned j = N; j; --j) {
174  sum += alphas[j] * cos(2 * j * xi_) * shared::fastSinh(2 * j * eta_);
175  }
176  } else {
177  for (unsigned j = N; j; --j) {
178  sum += alphas[j] * cos(2 * j * xi_) * sinh(2 * j * eta_);
179  }
180  }
181  return E0 + k0_A * (eta_ + sum);
182  }
constexpr double E0
Definition: Utm.h:34
constexpr std::array< double, 9 > alphas
Definition: Utm.h:56
constexpr double k0_A
Definition: Utm.h:47
double xi_
Definition: Utm.h:124
double eta_
Definition: Utm.h:123
constexpr unsigned N
Definition: Utm.h:110
bool small_dlambda_
Definition: Utm.h:125
DEVICE double fastSinh(double const x)
Definition: misc.h:248

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE double Transform4326ToUTM::calculateY ( ) const
inline

Definition at line 195 of file Utm.h.

References anonymous_namespace{Utm.h}::alphas, eta_, shared::fastCosh(), anonymous_namespace{Utm.h}::k0_A, anonymous_namespace{Utm.h}::N, small_dlambda_, srid_, and xi_.

Referenced by conv_4326_utm(), and transform_4326_utm_y().

195  {
196  double const N0 = (32700 < srid_) * 10e6; // UTM False northing (m)
197  double sum = 0;
198  if (small_dlambda_) {
199  for (unsigned j = N; j; --j) {
200  sum += alphas[j] * sin(2 * j * xi_) * shared::fastCosh(2 * j * eta_);
201  }
202  } else {
203  for (unsigned j = N; j; --j) {
204  sum += alphas[j] * sin(2 * j * xi_) * cosh(2 * j * eta_);
205  }
206  }
207  return N0 + k0_A * (xi_ + sum);
208  }
constexpr std::array< double, 9 > alphas
Definition: Utm.h:56
constexpr double k0_A
Definition: Utm.h:47
unsigned const srid_
Definition: Utm.h:122
double xi_
Definition: Utm.h:124
double eta_
Definition: Utm.h:123
constexpr unsigned N
Definition: Utm.h:110
bool small_dlambda_
Definition: Utm.h:125
DEVICE double fastCosh(double const x)
Definition: misc.h:230

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

double Transform4326ToUTM::eta_
private

Definition at line 123 of file Utm.h.

Referenced by calculateX(), calculateY(), and Transform4326ToUTM().

bool Transform4326ToUTM::small_dlambda_
private

Definition at line 125 of file Utm.h.

Referenced by calculateX(), calculateY(), and Transform4326ToUTM().

unsigned const Transform4326ToUTM::srid_
private

Definition at line 122 of file Utm.h.

Referenced by calculateY(), and Transform4326ToUTM().

double Transform4326ToUTM::xi_
private

Definition at line 124 of file Utm.h.

Referenced by calculateX(), calculateY(), and Transform4326ToUTM().


The documentation for this class was generated from the following file: