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

#include <Utm.h>

Public Member Functions

ALWAYS_INLINE TransformUTMTo4326 (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_eta_
 

Detailed Description

Definition at line 206 of file Utm.h.

Constructor & Destructor Documentation

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

Definition at line 219 of file Utm.h.

References anonymous_namespace{Utm.h}::betas, anonymous_namespace{Utm.h}::E0, eta_, shared::fastCosh(), shared::fastSinh(), anonymous_namespace{Utm.h}::k0_A, anonymous_namespace{Utm.h}::N, small_eta_, srid_, and xi_.

220  : srid_(srid) {
221  double const eta = (x - E0) / k0_A;
222  small_eta_ = -1.0 / 12 <= eta && eta <= 1.0 / 12;
223  double const N0 = (32700 < srid_) * 10e6; // UTM False northing (m)
224  double const xi = (y - N0) / k0_A;
225 
226  double eta_sum = 0;
227  double xi_sum = 0;
228  if (small_eta_) {
229  for (unsigned j = N; j; --j) {
230  eta_sum += betas[j] * cos(2 * j * xi) * shared::fastSinh(2 * j * eta);
231  }
232  for (unsigned j = N; j; --j) {
233  xi_sum += betas[j] * sin(2 * j * xi) * shared::fastCosh(2 * j * eta);
234  }
235  } else {
236  for (unsigned j = N; j; --j) {
237  eta_sum += betas[j] * cos(2 * j * xi) * sinh(2 * j * eta);
238  }
239  for (unsigned j = N; j; --j) {
240  xi_sum += betas[j] * sin(2 * j * xi) * cosh(2 * j * eta);
241  }
242  }
243  eta_ = eta - eta_sum;
244  xi_ = xi - xi_sum;
245  }
double eta_
Definition: Utm.h:209
double fastCosh(double const x)
Definition: misc.h:222
constexpr double E0
Definition: Utm.h:35
constexpr double k0_A
Definition: Utm.h:48
constexpr std::array< double, 9 > betas
Definition: Utm.h:73
double xi_
Definition: Utm.h:210
constexpr unsigned N
Definition: Utm.h:111
unsigned const srid_
Definition: Utm.h:208
double fastSinh(double const x)
Definition: misc.h:240
bool small_eta_
Definition: Utm.h:211

+ Here is the call graph for this function:

Member Function Documentation

ALWAYS_INLINE double TransformUTMTo4326::calculateX ( ) const
inline

Definition at line 248 of file Utm.h.

References math_consts::deg_div_rad, eta_, shared::fastSinh(), small_eta_, srid_, and xi_.

Referenced by transform_utm_4326_x().

248  {
249  unsigned const zone = srid_ % 100u;
250  double const lambda0 = zone * 6.0 - 183;
251  double const sinh_eta = small_eta_ ? shared::fastSinh(eta_) : sinh(eta_);
252  return lambda0 + atan(sinh_eta / cos(xi_)) * math_consts::deg_div_rad;
253  }
double eta_
Definition: Utm.h:209
constexpr double deg_div_rad
Definition: math_consts.h:21
double xi_
Definition: Utm.h:210
unsigned const srid_
Definition: Utm.h:208
double fastSinh(double const x)
Definition: misc.h:240
bool small_eta_
Definition: Utm.h:211

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ALWAYS_INLINE double TransformUTMTo4326::calculateY ( ) const
inline

Definition at line 256 of file Utm.h.

References math_consts::deg_div_rad, anonymous_namespace{Utm.h}::deltas, eta_, f, shared::fastCosh(), i, anonymous_namespace{Utm.h}::N, small_eta_, and xi_.

Referenced by transform_utm_4326_y().

256  {
257 #if 1
258  // https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system#Simplified_formulae
259  double const cosh_eta = small_eta_ ? shared::fastCosh(eta_) : cosh(eta_);
260  double const chi = asin(sin(xi_) / cosh_eta);
261  double sum = 0;
262  for (unsigned j = N; j; --j) {
263  sum += deltas[j] * sin(2 * j * chi);
264  }
265  return (chi + sum) * math_consts::deg_div_rad;
266 #else
267  // Heavier calculation from Transverse Mercator with an accuracy of a few nanometers
268  // by Karney 3 Feb 2011. This does not make use of the constexpr delta Fourier
269  // coefficients used by Kawase 2011 above which appears to be more accurate.
270  double const e = std::sqrt(f * (2 - f));
271  double const taup =
272  std::sin(xi_) / std::sqrt(sq(std::sinh(eta_)) + sq(std::cos(xi_)));
273 
274  double tau[2]{taup, 0.0 / 0.0};
275  unsigned i = 0;
276  for (; tau[0] != tau[1]; ++i) {
277  double const tau_i = tau[i & 1];
278  double const sigma_i =
279  std::sinh(e * std::tanh(e * tau_i / std::sqrt(1 + sq(tau_i))));
280  double const taup_i =
281  tau_i * std::sqrt(1 + sq(sigma_i)) - sigma_i * std::sqrt(1 + sq(tau_i));
282  double const dtau_i = (taup - taup_i) * (1 + (1 - e * e) * sq(tau_i)) /
283  ((1 - e * e) * std::sqrt((1 + sq(taup_i)) * (1 + sq(tau_i))));
284  tau[~i & 1] = tau_i + dtau_i;
285  }
286  return std::atan(tau[0]) * deg_div_rad;
287 #endif
288  }
double eta_
Definition: Utm.h:209
double fastCosh(double const x)
Definition: misc.h:222
constexpr std::array< double, 9 > deltas
Definition: Utm.h:99
constexpr double deg_div_rad
Definition: math_consts.h:21
double xi_
Definition: Utm.h:210
constexpr unsigned N
Definition: Utm.h:111
char * f
bool small_eta_
Definition: Utm.h:211

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

double TransformUTMTo4326::eta_
private

Definition at line 209 of file Utm.h.

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

bool TransformUTMTo4326::small_eta_
private

Definition at line 211 of file Utm.h.

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

unsigned const TransformUTMTo4326::srid_
private

Definition at line 208 of file Utm.h.

Referenced by calculateX(), and TransformUTMTo4326().

double TransformUTMTo4326::xi_
private

Definition at line 210 of file Utm.h.

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


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