blob: 6e883ab25e482dd0a8c2c1130670d231573ad623 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#define PJ_LIB__
#include <errno.h>
#include <math.h>
#include "proj.h"
#include "proj_internal.h"
namespace { // anonymous namespace
struct pj_opaque {
double phi1;
double fxa;
double fxb;
int mode;
};
} // anonymous namespace
PROJ_HEAD(rpoly, "Rectangular Polyconic")
"\n\tConic, Sph, no inv\n\tlat_ts=";
#define EPS 1e-9
static PJ_XY s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward */
PJ_XY xy = {0.0,0.0};
struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque);
double fa;
if (Q->mode)
fa = tan(lp.lam * Q->fxb) * Q->fxa;
else
fa = 0.5 * lp.lam;
if (fabs(lp.phi) < EPS) {
xy.x = fa + fa;
xy.y = - P->phi0;
} else {
xy.y = 1. / tan(lp.phi);
xy.x = sin(fa = 2. * atan(fa * sin(lp.phi))) * xy.y;
xy.y = lp.phi - P->phi0 + (1. - cos(fa)) * xy.y;
}
return xy;
}
PJ *PROJECTION(rpoly) {
struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque)));
if (nullptr==Q)
return pj_default_destructor(P, ENOMEM);
P->opaque = Q;
if ((Q->mode = (Q->phi1 = fabs(pj_param(P->ctx, P->params, "rlat_ts").f)) > EPS)) {
Q->fxb = 0.5 * sin(Q->phi1);
Q->fxa = 0.5 / Q->fxb;
}
P->es = 0.;
P->fwd = s_forward;
return P;
}
|