"Fossies" - the Fresh Open Source Software Archive

Member "proj-6.2.1/src/projections/eck3.cpp" (6 May 2019, 2768 Bytes) of package /linux/privat/proj-6.2.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "eck3.cpp" see the Fossies "Dox" file reference documentation.

    1 #define PJ_LIB__
    2 
    3 #include <errno.h>
    4 #include <math.h>
    5 
    6 #include "proj.h"
    7 #include "proj_internal.h"
    8 
    9 PROJ_HEAD(eck3, "Eckert III") "\n\tPCyl, Sph";
   10 PROJ_HEAD(putp1, "Putnins P1") "\n\tPCyl, Sph";
   11 PROJ_HEAD(wag6, "Wagner VI") "\n\tPCyl, Sph";
   12 PROJ_HEAD(kav7, "Kavraisky VII") "\n\tPCyl, Sph";
   13 
   14 namespace { // anonymous namespace
   15 struct pj_opaque {
   16     double C_x, C_y, A, B;
   17 };
   18 } // anonymous namespace
   19 
   20 
   21 static PJ_XY eck3_s_forward (PJ_LP lp, PJ *P) {           /* Spheroidal, forward */
   22     PJ_XY xy = {0.0,0.0};
   23     struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque);
   24 
   25     xy.y = Q->C_y * lp.phi;
   26     xy.x = Q->C_x * lp.lam * (Q->A + asqrt(1. - Q->B * lp.phi * lp.phi));
   27     return xy;
   28 }
   29 
   30 
   31 static PJ_LP eck3_s_inverse (PJ_XY xy, PJ *P) {           /* Spheroidal, inverse */
   32     PJ_LP lp = {0.0,0.0};
   33     struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque);
   34     double denominator;
   35 
   36     lp.phi = xy.y / Q->C_y;
   37     denominator = (Q->C_x * (Q->A + asqrt(1. - Q->B * lp.phi * lp.phi)));
   38     if ( denominator == 0.0)
   39         lp.lam = HUGE_VAL;
   40     else
   41         lp.lam = xy.x / denominator;
   42     return lp;
   43 }
   44 
   45 
   46 static PJ *setup(PJ *P) {
   47     P->es = 0.;
   48     P->inv = eck3_s_inverse;
   49     P->fwd = eck3_s_forward;
   50     return P;
   51 }
   52 
   53 
   54 PJ *PROJECTION(eck3) {
   55     struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque)));
   56     if (nullptr==Q)
   57         return pj_default_destructor (P, ENOMEM);
   58     P->opaque = Q;
   59 
   60     Q->C_x = 0.42223820031577120149;
   61     Q->C_y = 0.84447640063154240298;
   62     Q->A = 1.0;
   63     Q->B = 0.4052847345693510857755;
   64 
   65     return setup(P);
   66 }
   67 
   68 
   69 PJ *PROJECTION(kav7) {
   70     struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque)));
   71     if (nullptr==Q)
   72         return pj_default_destructor (P, ENOMEM);
   73     P->opaque = Q;
   74 
   75     /* Defined twice in original code - Using 0.866...,
   76      * but leaving the other one here as a safety measure.
   77      * Q->C_x = 0.2632401569273184856851; */
   78     Q->C_x = 0.8660254037844;
   79     Q->C_y = 1.;
   80     Q->A = 0.;
   81     Q->B = 0.30396355092701331433;
   82 
   83     return setup(P);
   84 }
   85 
   86 
   87 PJ *PROJECTION(wag6) {
   88     struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque)));
   89     if (nullptr==Q)
   90         return pj_default_destructor (P, ENOMEM);
   91     P->opaque = Q;
   92 
   93     Q->C_x = Q->C_y = 0.94745;
   94     Q->A = 0.0;
   95     Q->B = 0.30396355092701331433;
   96 
   97     return setup(P);
   98 }
   99 
  100 
  101 PJ *PROJECTION(putp1) {
  102     struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque)));
  103     if (nullptr==Q)
  104         return pj_default_destructor (P, ENOMEM);
  105     P->opaque = Q;
  106 
  107     Q->C_x = 1.89490;
  108     Q->C_y = 0.94745;
  109     Q->A = -0.5;
  110     Q->B = 0.30396355092701331433;
  111 
  112     return setup(P);
  113 }