| 37 | #define OUTPUT_UNITS P->left |
| 38 | |
| 39 | static void inv_prepare(PJ *P, PJ_COORD &coo) { |
| 40 | if (coo.v[0] == HUGE_VAL || coo.v[1] == HUGE_VAL || coo.v[2] == HUGE_VAL) { |
| 41 | proj_errno_set(P, PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN); |
| 42 | coo = proj_coord_error(); |
| 43 | return; |
| 44 | } |
| 45 | |
| 46 | /* The helmert datum shift will choke unless it gets a sensible 4D |
| 47 | * coordinate |
| 48 | */ |
| 49 | if (HUGE_VAL == coo.v[2] && P->helmert) |
| 50 | coo.v[2] = 0.0; |
| 51 | if (HUGE_VAL == coo.v[3] && P->helmert) |
| 52 | coo.v[3] = 0.0; |
| 53 | |
| 54 | if (P->axisswap) |
| 55 | coo = proj_trans(P->axisswap, PJ_INV, coo); |
| 56 | |
| 57 | /* Handle remaining possible input types */ |
| 58 | switch (INPUT_UNITS) { |
| 59 | case PJ_IO_UNITS_WHATEVER: |
| 60 | break; |
| 61 | |
| 62 | case PJ_IO_UNITS_DEGREES: |
| 63 | break; |
| 64 | |
| 65 | /* de-scale and de-offset */ |
| 66 | case PJ_IO_UNITS_CARTESIAN: |
| 67 | coo.xyz.x *= P->to_meter; |
| 68 | coo.xyz.y *= P->to_meter; |
| 69 | coo.xyz.z *= P->to_meter; |
| 70 | if (P->is_geocent) { |
| 71 | coo = proj_trans(P->cart, PJ_INV, coo); |
| 72 | } |
| 73 | break; |
| 74 | |
| 75 | case PJ_IO_UNITS_PROJECTED: |
| 76 | case PJ_IO_UNITS_CLASSIC: |
| 77 | coo.xyz.x = P->to_meter * coo.xyz.x - P->x0; |
| 78 | coo.xyz.y = P->to_meter * coo.xyz.y - P->y0; |
| 79 | coo.xyz.z = P->vto_meter * coo.xyz.z - P->z0; |
| 80 | if (INPUT_UNITS == PJ_IO_UNITS_PROJECTED) |
| 81 | return; |
| 82 | |
| 83 | /* Classic proj.4 functions expect plane coordinates in units of the |
| 84 | * semimajor axis */ |
| 85 | /* Multiplying by ra, rather than dividing by a because the CalCOFI |
| 86 | * projection */ |
| 87 | /* stomps on a and hence (apparently) depends on this to roundtrip |
| 88 | * correctly |
| 89 | */ |
| 90 | /* (CalCOFI avoids further scaling by stomping - but a better solution |
| 91 | * is possible) */ |
| 92 | coo.xyz.x *= P->ra; |
| 93 | coo.xyz.y *= P->ra; |
| 94 | break; |
| 95 | |
| 96 | case PJ_IO_UNITS_RADIANS: |
no test coverage detected