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

#include <Utm.h>

Public Member Functions

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

Private Attributes

unsigned const srid_
 
double eta_
 
double xi_
 
bool small_dlambda_
 

Detailed Description

Definition at line 117 of file Utm.h.

Constructor & Destructor Documentation

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

Definition at line 131 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_, t, and xi_.

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

+ Here is the call graph for this function:

Member Function Documentation

ALWAYS_INLINE double Transform4326ToUTM::calculateX ( ) const
inline

Definition at line 165 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 transform_4326_utm_x().

165  {
166  double sum = 0; // Sum in reverse to add smallest numbers first
167  if (small_dlambda_) {
168  for (unsigned j = N; j; --j) {
169  sum += alphas[j] * cos(2 * j * xi_) * shared::fastSinh(2 * j * eta_);
170  }
171  } else {
172  for (unsigned j = N; j; --j) {
173  sum += alphas[j] * cos(2 * j * xi_) * sinh(2 * j * eta_);
174  }
175  }
176  return E0 + k0_A * (eta_ + sum);
177  }
constexpr double E0
Definition: Utm.h:35
constexpr std::array< double, 9 > alphas
Definition: Utm.h:57
constexpr double k0_A
Definition: Utm.h:48
double xi_
Definition: Utm.h:121
double eta_
Definition: Utm.h:120
constexpr unsigned N
Definition: Utm.h:111
double fastSinh(double const x)
Definition: misc.h:240
bool small_dlambda_
Definition: Utm.h:122

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ALWAYS_INLINE double Transform4326ToUTM::calculateY ( ) const
inline

Definition at line 190 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 transform_4326_utm_y().

190  {
191  double const N0 = (32700 < srid_) * 10e6; // UTM False northing (m)
192  double sum = 0;
193  if (small_dlambda_) {
194  for (unsigned j = N; j; --j) {
195  sum += alphas[j] * sin(2 * j * xi_) * shared::fastCosh(2 * j * eta_);
196  }
197  } else {
198  for (unsigned j = N; j; --j) {
199  sum += alphas[j] * sin(2 * j * xi_) * cosh(2 * j * eta_);
200  }
201  }
202  return N0 + k0_A * (xi_ + sum);
203  }
double fastCosh(double const x)
Definition: misc.h:222
constexpr std::array< double, 9 > alphas
Definition: Utm.h:57
constexpr double k0_A
Definition: Utm.h:48
unsigned const srid_
Definition: Utm.h:119
double xi_
Definition: Utm.h:121
double eta_
Definition: Utm.h:120
constexpr unsigned N
Definition: Utm.h:111
bool small_dlambda_
Definition: Utm.h:122

+ 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 120 of file Utm.h.

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

bool Transform4326ToUTM::small_dlambda_
private

Definition at line 122 of file Utm.h.

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

unsigned const Transform4326ToUTM::srid_
private

Definition at line 119 of file Utm.h.

Referenced by calculateY(), and Transform4326ToUTM().

double Transform4326ToUTM::xi_
private

Definition at line 121 of file Utm.h.

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


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