| 124 | } |
| 125 | |
| 126 | bool getZOffset(int ix, int iy, double &zOffset) const { |
| 127 | if (!checkedVertical) { |
| 128 | const auto samplesPerPixel = realGrid->samplesPerPixel(); |
| 129 | if (samplesPerPixel == 1) { |
| 130 | sampleZ = 0; |
| 131 | } else if (samplesPerPixel < 3) { |
| 132 | pj_log(ctx, PJ_LOG_ERROR, "grid %s has not enough samples", |
| 133 | realGrid->name().c_str()); |
| 134 | return false; |
| 135 | } |
| 136 | bool foundDesc = false; |
| 137 | bool foundDescZ = false; |
| 138 | for (int i = 0; i < samplesPerPixel; i++) { |
| 139 | const auto desc = realGrid->description(i); |
| 140 | if (desc == "vertical_offset") { |
| 141 | sampleZ = i; |
| 142 | foundDescZ = true; |
| 143 | } |
| 144 | if (!desc.empty()) { |
| 145 | foundDesc = true; |
| 146 | } |
| 147 | } |
| 148 | if (foundDesc && !foundDescZ) { |
| 149 | pj_log(ctx, PJ_LOG_ERROR, |
| 150 | "grid %s : Found band description, " |
| 151 | "but not the ones expected", |
| 152 | realGrid->name().c_str()); |
| 153 | return false; |
| 154 | } |
| 155 | const auto unit = realGrid->unit(sampleZ); |
| 156 | if (!unit.empty() && unit != STR_METRE) { |
| 157 | pj_log(ctx, PJ_LOG_ERROR, |
| 158 | "grid %s : Only unit=metre currently " |
| 159 | "handled for this mode", |
| 160 | realGrid->name().c_str()); |
| 161 | return false; |
| 162 | } |
| 163 | checkedVertical = true; |
| 164 | } |
| 165 | float zOffsetFloat = 0.0f; |
| 166 | const bool ret = realGrid->valueAt(ix, iy, sampleZ, zOffsetFloat); |
| 167 | zOffset = zOffsetFloat; |
| 168 | return ret; |
| 169 | } |
| 170 | |
| 171 | bool getEastingNorthingOffset(int ix, int iy, double &eastingOffset, |
| 172 | double &northingOffset) const { |
no test coverage detected