MCPcopy Create free account
hub / github.com/OSGeo/PROJ / get_grid_values

Function get_grid_values

src/transformations/xyzgridshift.cpp:55–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53// ---------------------------------------------------------------------------
54
55static bool get_grid_values(PJ *P, xyzgridshiftData *Q, const PJ_LP &lp,
56 double &dx, double &dy, double &dz) {
57 if (Q->defer_grid_opening) {
58 Q->defer_grid_opening = false;
59 Q->grids = pj_generic_grid_init(P, "grids");
60 Q->error_code_in_defer_grid_opening = proj_errno(P);
61 }
62 if (Q->error_code_in_defer_grid_opening) {
63 proj_errno_set(P, Q->error_code_in_defer_grid_opening);
64 return false;
65 }
66
67 GenericShiftGridSet *gridset = nullptr;
68 auto grid = pj_find_generic_grid(Q->grids, lp, gridset);
69 if (!grid) {
70 return false;
71 }
72 if (grid->isNullGrid()) {
73 dx = 0;
74 dy = 0;
75 dz = 0;
76 return true;
77 }
78 const auto samplesPerPixel = grid->samplesPerPixel();
79 if (samplesPerPixel < 3) {
80 proj_log_error(P, "xyzgridshift: grid has not enough samples");
81 return false;
82 }
83 int sampleX = 0;
84 int sampleY = 1;
85 int sampleZ = 2;
86 for (int i = 0; i < samplesPerPixel; i++) {
87 const auto desc = grid->description(i);
88 if (desc == "x_translation") {
89 sampleX = i;
90 } else if (desc == "y_translation") {
91 sampleY = i;
92 } else if (desc == "z_translation") {
93 sampleZ = i;
94 }
95 }
96 const auto unit = grid->unit(sampleX);
97 if (!unit.empty() && unit != "metre") {
98 proj_log_error(P, "xyzgridshift: Only unit=metre currently handled");
99 return false;
100 }
101
102 bool must_retry = false;
103 if (!pj_bilinear_interpolation_three_samples(P->ctx, grid, lp, sampleX,
104 sampleY, sampleZ, dx, dy, dz,
105 must_retry)) {
106 if (must_retry)
107 return get_grid_values(P, Q, lp, dx, dy, dz);
108 return false;
109 }
110
111 dx *= Q->multiplier;
112 dy *= Q->multiplier;

Callers 2

iterative_adjustmentFunction · 0.85
direct_adjustmentFunction · 0.85

Calls 11

pj_generic_grid_initFunction · 0.85
proj_errnoFunction · 0.85
proj_errno_setFunction · 0.85
pj_find_generic_gridFunction · 0.85
proj_log_errorFunction · 0.85
isNullGridMethod · 0.45
samplesPerPixelMethod · 0.45
descriptionMethod · 0.45
unitMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected