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

#include <Utm.h>

Public Member Functions

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

Detailed Description

Definition at line 211 of file Utm.h.

Constructor & Destructor Documentation

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

Definition at line 224 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_.

227  : srid_(srid) {
228  double const eta = (x - E0) / k0_A;
229  small_eta_ = -1.0 / 12 <= eta && eta <= 1.0 / 12;
230  double const N0 = (32700 < srid_) * 10e6; // UTM False northing (m)
231  double const xi = (y - N0) / k0_A;
232 
233  double eta_sum = 0;
234  double xi_sum = 0;
235  if (small_eta_) {
236  for (unsigned j = N; j; --j) {
237  eta_sum += betas[j] * cos(2 * j * xi) * shared::fastSinh(2 * j * eta);
238  }
239  for (unsigned j = N; j; --j) {
240  xi_sum += betas[j] * sin(2 * j * xi) * shared::fastCosh(2 * j * eta);
241  }
242  } else {
243  for (unsigned j = N; j; --j) {
244  eta_sum += betas[j] * cos(2 * j * xi) * sinh(2 * j * eta);
245  }
246  for (unsigned j = N; j; --j) {
247  xi_sum += betas[j] * sin(2 * j * xi) * cosh(2 * j * eta);
248  }
249  }
250  eta_ = eta - eta_sum;
251  xi_ = xi - xi_sum;
252  }
double eta_
Definition: Utm.h:214
constexpr double E0
Definition: Utm.h:34
constexpr double k0_A
Definition: Utm.h:47
constexpr std::array< double, 9 > betas
Definition: Utm.h:72
double xi_
Definition: Utm.h:215
constexpr unsigned N
Definition: Utm.h:110
unsigned const srid_
Definition: Utm.h:213
bool small_eta_
Definition: Utm.h:216
DEVICE double fastCosh(double const x)
Definition: misc.h:230
DEVICE double fastSinh(double const x)
Definition: misc.h:248

+ Here is the call graph for this function:

Member Function Documentation

DEVICE ALWAYS_INLINE double TransformUTMTo4326::calculateX ( ) const
inline

Definition at line 255 of file Utm.h.

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

Referenced by conv_utm_4326(), and transform_utm_4326_x().

255  {
256  unsigned const zone = srid_ % 100u;
257  double const lambda0 = zone * 6.0 - 183;
258  double const sinh_eta = small_eta_ ? shared::fastSinh(eta_) : sinh(eta_);
259  return lambda0 + atan(sinh_eta / cos(xi_)) * math_consts::deg_div_rad;
260  }
double eta_
Definition: Utm.h:214
constexpr double deg_div_rad
Definition: math_consts.h:22
double xi_
Definition: Utm.h:215
unsigned const srid_
Definition: Utm.h:213
bool small_eta_
Definition: Utm.h:216
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 TransformUTMTo4326::calculateY ( ) const
inline

Definition at line 263 of file Utm.h.

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

Referenced by conv_utm_4326(), and transform_utm_4326_y().

263  {
264 #if 1
265  // https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system#Simplified_formulae
266  double const cosh_eta = small_eta_ ? shared::fastCosh(eta_) : cosh(eta_);
267  double const chi = asin(sin(xi_) / cosh_eta);
268  double sum = 0;
269  for (unsigned j = N; j; --j) {
270  sum += deltas[j] * sin(2 * j * chi);
271  }
272  return (chi + sum) * math_consts::deg_div_rad;
273 #else
274  // Heavier calculation from Transverse Mercator with an accuracy of a few nanometers
275  // by Karney 3 Feb 2011. This does not make use of the constexpr delta Fourier
276  // coefficients used by Kawase 2011 above which appears to be more accurate and
277  // probably faster.
278  double const e = std::sqrt(f * (2 - f));
279  double const taup =
280  std::sin(xi_) / std::sqrt(sq(std::sinh(eta_)) + sq(std::cos(xi_)));
281 
282  double tau[2]{taup, 0.0 / 0.0};
283  unsigned i = 0;
284  for (; tau[0] != tau[1]; ++i) {
285  double const tau_i = tau[i & 1];
286  double const sigma_i =
287  std::sinh(e * std::tanh(e * tau_i / std::sqrt(1 + sq(tau_i))));
288  double const taup_i =
289  tau_i * std::sqrt(1 + sq(sigma_i)) - sigma_i * std::sqrt(1 + sq(tau_i));
290  double const dtau_i = (taup - taup_i) * (1 + (1 - e * e) * sq(tau_i)) /
291  ((1 - e * e) * std::sqrt((1 + sq(taup_i)) * (1 + sq(tau_i))));
292  tau[~i & 1] = tau_i + dtau_i;
293  }
294  return std::atan(tau[0]) * deg_div_rad;
295 #endif
296  }
double eta_
Definition: Utm.h:214
constexpr std::array< double, 9 > deltas
Definition: Utm.h:98
constexpr double deg_div_rad
Definition: math_consts.h:22
constexpr double f
Definition: Utm.h:31
double xi_
Definition: Utm.h:215
constexpr unsigned N
Definition: Utm.h:110
bool small_eta_
Definition: Utm.h:216
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 TransformUTMTo4326::eta_
private

Definition at line 214 of file Utm.h.

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

bool TransformUTMTo4326::small_eta_
private

Definition at line 216 of file Utm.h.

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

unsigned const TransformUTMTo4326::srid_
private

Definition at line 213 of file Utm.h.

Referenced by calculateX(), and TransformUTMTo4326().

double TransformUTMTo4326::xi_
private

Definition at line 215 of file Utm.h.

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


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