/src/PROJ/src/projections/eqc.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | |
2 | | |
3 | | #include <errno.h> |
4 | | #include <math.h> |
5 | | |
6 | | #include "proj.h" |
7 | | #include "proj_internal.h" |
8 | | |
9 | | namespace { // anonymous namespace |
10 | | struct pj_eqc_data { |
11 | | double rc; |
12 | | }; |
13 | | } // anonymous namespace |
14 | | |
15 | | PROJ_HEAD(eqc, "Equidistant Cylindrical (Plate Carree)") |
16 | | "\n\tCyl, Sph\n\tlat_ts=[, lat_0=0]"; |
17 | | |
18 | 18.6k | static PJ_XY eqc_s_forward(PJ_LP lp, PJ *P) { /* Spheroidal, forward */ |
19 | 18.6k | PJ_XY xy = {0.0, 0.0}; |
20 | 18.6k | struct pj_eqc_data *Q = static_cast<struct pj_eqc_data *>(P->opaque); |
21 | | |
22 | 18.6k | xy.x = Q->rc * lp.lam; |
23 | 18.6k | xy.y = lp.phi - P->phi0; |
24 | | |
25 | 18.6k | return xy; |
26 | 18.6k | } |
27 | | |
28 | 0 | static PJ_LP eqc_s_inverse(PJ_XY xy, PJ *P) { /* Spheroidal, inverse */ |
29 | 0 | PJ_LP lp = {0.0, 0.0}; |
30 | 0 | struct pj_eqc_data *Q = static_cast<struct pj_eqc_data *>(P->opaque); |
31 | |
|
32 | 0 | lp.lam = xy.x / Q->rc; |
33 | 0 | lp.phi = xy.y + P->phi0; |
34 | |
|
35 | 0 | return lp; |
36 | 0 | } |
37 | | |
38 | 196 | PJ *PJ_PROJECTION(eqc) { |
39 | 196 | struct pj_eqc_data *Q = static_cast<struct pj_eqc_data *>( |
40 | 196 | calloc(1, sizeof(struct pj_eqc_data))); |
41 | 196 | if (nullptr == Q) |
42 | 0 | return pj_default_destructor(P, PROJ_ERR_OTHER /*ENOMEM*/); |
43 | 196 | P->opaque = Q; |
44 | | |
45 | 196 | if ((Q->rc = cos(pj_param(P->ctx, P->params, "rlat_ts").f)) <= 0.) { |
46 | 1 | proj_log_error( |
47 | 1 | P, _("Invalid value for lat_ts: |lat_ts| should be <= 90°")); |
48 | 1 | return pj_default_destructor(P, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE); |
49 | 1 | } |
50 | 195 | P->inv = eqc_s_inverse; |
51 | 195 | P->fwd = eqc_s_forward; |
52 | 195 | P->es = 0.; |
53 | | |
54 | 195 | return P; |
55 | 196 | } |