| 96 | |
| 97 | |
| 98 | static PJ_COORD inv_finalize (PJ *P, PJ_COORD coo) { |
| 99 | if (coo.xyz.x == HUGE_VAL) { |
| 100 | proj_errno_set (P, PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN); |
| 101 | return proj_coord_error (); |
| 102 | } |
| 103 | |
| 104 | if (OUTPUT_UNITS==PJ_IO_UNITS_RADIANS) { |
| 105 | |
| 106 | /* Distance from central meridian, taking system zero meridian into account */ |
| 107 | coo.lp.lam = coo.lp.lam + P->from_greenwich + P->lam0; |
| 108 | |
| 109 | /* adjust longitude to central meridian */ |
| 110 | if (0==P->over) |
| 111 | coo.lpz.lam = adjlon(coo.lpz.lam); |
| 112 | |
| 113 | if (P->vgridshift) |
| 114 | coo = proj_trans (P->vgridshift, PJ_INV, coo); /* Go geometric from orthometric */ |
| 115 | if (coo.lp.lam==HUGE_VAL) |
| 116 | return coo; |
| 117 | if (P->hgridshift) |
| 118 | coo = proj_trans (P->hgridshift, PJ_FWD, coo); |
| 119 | else if (P->helmert || (P->cart_wgs84 != nullptr && P->cart != nullptr)) { |
| 120 | coo = proj_trans (P->cart, PJ_FWD, coo); /* Go cartesian in local frame */ |
| 121 | if( P->helmert ) |
| 122 | coo = proj_trans (P->helmert, PJ_FWD, coo); /* Step into WGS84 */ |
| 123 | coo = proj_trans (P->cart_wgs84, PJ_INV, coo); /* Go back to angular using WGS84 ellps */ |
| 124 | } |
| 125 | if (coo.lp.lam==HUGE_VAL) |
| 126 | return coo; |
| 127 | |
| 128 | /* If input latitude was geocentrical, convert back to geocentrical */ |
| 129 | if (P->geoc) |
| 130 | coo = pj_geocentric_latitude (P, PJ_FWD, coo); |
| 131 | } |
| 132 | |
| 133 | return coo; |
| 134 | } |
| 135 | |
| 136 | |
| 137 | static PJ_COORD error_or_coord(PJ *P, PJ_COORD coord, int last_errno) { |
no test coverage detected