MCPcopy Create free account
hub / github.com/Kitware/VTK / PROJECTION

Function PROJECTION

ThirdParty/libproj/vtklibproj/src/projections/chamb.cpp:103–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101
102
103PJ *PROJECTION(chamb) {
104 int i, j;
105 char line[10];
106 struct pj_opaque *Q = static_cast<struct pj_opaque*>(calloc (1, sizeof (struct pj_opaque)));
107 if (nullptr==Q)
108 return pj_default_destructor (P, PROJ_ERR_OTHER /*ENOMEM*/);
109 P->opaque = Q;
110
111
112 for (i = 0; i < 3; ++i) { /* get control point locations */
113 (void)sprintf(line, "rlat_%d", i+1);
114 Q->c[i].phi = pj_param(P->ctx, P->params, line).f;
115 (void)sprintf(line, "rlon_%d", i+1);
116 Q->c[i].lam = pj_param(P->ctx, P->params, line).f;
117 Q->c[i].lam = adjlon(Q->c[i].lam - P->lam0);
118 Q->c[i].cosphi = cos(Q->c[i].phi);
119 Q->c[i].sinphi = sin(Q->c[i].phi);
120 }
121 for (i = 0; i < 3; ++i) { /* inter ctl pt. distances and azimuths */
122 j = i == 2 ? 0 : i + 1;
123 Q->c[i].v = vect(P->ctx,Q->c[j].phi - Q->c[i].phi, Q->c[i].cosphi, Q->c[i].sinphi,
124 Q->c[j].cosphi, Q->c[j].sinphi, Q->c[j].lam - Q->c[i].lam);
125 if (Q->c[i].v.r == 0.0)
126 {
127 proj_log_error(P, _("Invalid value for control points: they should be distinct"));
128 return pj_default_destructor(P, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE);
129 }
130 /* co-linearity problem ignored for now */
131 }
132 Q->beta_0 = lc(P->ctx,Q->c[0].v.r, Q->c[2].v.r, Q->c[1].v.r);
133 Q->beta_1 = lc(P->ctx,Q->c[0].v.r, Q->c[1].v.r, Q->c[2].v.r);
134 Q->beta_2 = M_PI - Q->beta_0;
135 Q->c[0].p.y = Q->c[2].v.r * sin(Q->beta_0);
136 Q->c[1].p.y = Q->c[0].p.y;
137 Q->p.y = 2. * Q->c[0].p.y;
138 Q->c[2].p.y = 0.;
139 Q->c[1].p.x = 0.5 * Q->c[0].v.r;
140 Q->c[0].p.x = -Q->c[1].p.x;
141 Q->c[2].p.x = Q->c[0].p.x + Q->c[2].v.r * cos(Q->beta_0);
142 Q->p.x = Q->c[2].p.x;
143
144 P->es = 0.;
145 P->fwd = chamb_s_forward;
146
147 return P;
148}

Callers

nothing calls this directly

Calls 9

pj_default_destructorFunction · 0.85
sprintfFunction · 0.85
pj_paramFunction · 0.85
adjlonFunction · 0.85
vectFunction · 0.85
proj_log_errorFunction · 0.85
lcFunction · 0.85
cosFunction · 0.50
sinFunction · 0.50

Tested by

no test coverage detected