| 27 | } // anonymous namespace |
| 28 | |
| 29 | static PJ_XYZ pj_hgridshift_forward_3d(PJ_LPZ lpz, PJ *P) { |
| 30 | auto Q = static_cast<hgridshiftData *>(P->opaque); |
| 31 | PJ_COORD point = {{0, 0, 0, 0}}; |
| 32 | point.lpz = lpz; |
| 33 | |
| 34 | if (Q->defer_grid_opening) { |
| 35 | Q->defer_grid_opening = false; |
| 36 | Q->grids = pj_hgrid_init(P, "grids"); |
| 37 | Q->error_code_in_defer_grid_opening = proj_errno(P); |
| 38 | } |
| 39 | if (Q->error_code_in_defer_grid_opening) { |
| 40 | proj_errno_set(P, Q->error_code_in_defer_grid_opening); |
| 41 | return proj_coord_error().xyz; |
| 42 | } |
| 43 | |
| 44 | if (!Q->grids.empty()) { |
| 45 | /* Only try the gridshift if at least one grid is loaded, |
| 46 | * otherwise just pass the coordinate through unchanged. */ |
| 47 | point.lp = pj_hgrid_apply(P->ctx, Q->grids, point.lp, PJ_FWD); |
| 48 | } |
| 49 | |
| 50 | return point.xyz; |
| 51 | } |
| 52 | |
| 53 | static PJ_LPZ pj_hgridshift_reverse_3d(PJ_XYZ xyz, PJ *P) { |
| 54 | auto Q = static_cast<hgridshiftData *>(P->opaque); |
no test coverage detected