vcsl_spheroid.cxx
Go to the documentation of this file.
1 // This is core/vcsl/vcsl_spheroid.cxx
2 #include <cmath>
3 #include "vcsl_spheroid.h"
4 #ifdef _MSC_VER
5 # include <vcl_msvc_warnings.h>
6 #endif
7 #include <cassert>
8 
9 //---------------------------------------------------------------------------
10 // Set from a standard spheroid
11 //---------------------------------------------------------------------------
12 void vcsl_spheroid::set_from_std(const vcsl_std_spheroid new_std_spheroid)
13 {
14  switch (new_std_spheroid)
15  {
16  case airy_1830:
17  a_=6377563.396;
18  b_=6356256.910;
19  break;
22  a_=6378160;
23  b_=6356774.7192;
24  break;
25  case bessel_1841:
26  a_=6377397.155;
27  b_=6356078.9629;
28  break;
29  case clarke_1866:
30  a_=6378206.4;
31  b_=6356583.8;
32  break;
33  case clarke_1880:
34  a_=6378249.145;
35  b_=6356514.8696;
36  break;
37  case everest_1830:
38  a_=6377276.34518;
39  b_=6356075.41511;
40  break;
41  case grs_1980:
42  a_=6378137;
43  b_=6356752.3141;
44  break;
45  case international:
46  a_=6378388;
47  b_=6356911.9462;
48  break;
49  case modified_airy:
50  a_=6377340.189;
51  b_=6356034.446;
52  break;
53  case modified_everest:
54  a_=6377304.063;
55  b_=6356103.039;
56  break;
57  case wgs_1972:
58  a_=6378135;
59  b_=6356750.5;
60  break;
61  case wgs_1984:
62  a_=6378137;
63  b_=6356752.3142;
64  break;
65  default:
66  assert(!"impossible");
67  }
68 
69  f_=(a_-b_)/a_;
70  e_=std::sqrt(2*f_-f_*f_);
71 }
72 
73 //---------------------------------------------------------------------------
74 // Is `this' equal to `other' ?
75 //---------------------------------------------------------------------------
76 bool vcsl_spheroid::operator==(const vcsl_spheroid &other) const
77 {
78  if (this==&other)
79  return true;
80  else
81  return a_==other.a_ && b_==other.b_ && e_==other.e_ && f_==other.f_;
82 }
83 
84 //---------------------------------------------------------------------------
85 // Assignment
86 //---------------------------------------------------------------------------
88 {
89  if (this!=&other)
90  {
91  a_=other.a_;
92  b_=other.b_;
93  e_=other.e_;
94  f_=other.f_;
95  }
96  return *this;
97 }
bool operator==(const vcsl_spheroid &other) const
Is ‘this’ equal to ‘other’ ?.
vcsl_spheroid & operator=(const vcsl_spheroid &other)
double a_
Major axis of spheroid.
double e_
Eccentricity of spheroid.
double b_
Minor axis of spheroid.
void set_from_std(const vcsl_std_spheroid new_std_spheroid)
Set from a standard spheroid.
Reference sphere or ellipse for a geographic coordinate system.
double f_
Flattening of spheroid.
Reference sphere or ellipse for a geographic coordinate system.
Definition: vcsl_spheroid.h:26