| 125 | // --------------------------------------------------------------------------- |
| 126 | |
| 127 | bool gridshiftData::checkGridTypes(PJ *P, bool &isProjectedCoord) { |
| 128 | std::string offsetX, offsetY; |
| 129 | int gridCount = 0; |
| 130 | isProjectedCoord = false; |
| 131 | for (const auto &gridset : m_grids) { |
| 132 | for (const auto &grid : gridset->grids()) { |
| 133 | ++gridCount; |
| 134 | const auto &type = grid->metadataItem("TYPE"); |
| 135 | if (type == "HORIZONTAL_OFFSET") { |
| 136 | m_bHasHorizontalOffset = true; |
| 137 | if (offsetX.empty()) { |
| 138 | offsetX = grid->metadataItem("constant_offset", 0); |
| 139 | } |
| 140 | if (offsetY.empty()) { |
| 141 | offsetY = grid->metadataItem("constant_offset", 1); |
| 142 | } |
| 143 | } else if (type == "GEOGRAPHIC_3D_OFFSET") |
| 144 | m_bHasGeographic3DOffset = true; |
| 145 | else if (type == "ELLIPSOIDAL_HEIGHT_OFFSET") |
| 146 | m_bHasEllipsoidalHeightOffset = true; |
| 147 | else if (type == "VERTICAL_OFFSET_VERTICAL_TO_VERTICAL") |
| 148 | m_bHasVerticalToVertical = true; |
| 149 | else if (type == "VERTICAL_OFFSET_GEOGRAPHIC_TO_VERTICAL") |
| 150 | m_bHasGeographicToVertical = true; |
| 151 | else if (type.empty()) { |
| 152 | proj_log_error(P, _("Missing TYPE metadata item in grid(s).")); |
| 153 | return false; |
| 154 | } else { |
| 155 | proj_log_error( |
| 156 | P, _("Unhandled value for TYPE metadata item in grid(s).")); |
| 157 | return false; |
| 158 | } |
| 159 | |
| 160 | isProjectedCoord = !grid->extentAndRes().isGeographic; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | if (!offsetX.empty() || !offsetY.empty()) { |
| 165 | if (gridCount > 1) { |
| 166 | // Makes life easier... |
| 167 | proj_log_error(P, _("Shift offset found in one grid. Only one grid " |
| 168 | "with shift offset is supported at a time.")); |
| 169 | return false; |
| 170 | } |
| 171 | try { |
| 172 | m_offsetX = NS_PROJ::internal::c_locale_stod(offsetX); |
| 173 | } catch (const std::exception &) { |
| 174 | proj_log_error(P, _("Invalid offset value")); |
| 175 | return false; |
| 176 | } |
| 177 | try { |
| 178 | m_offsetY = NS_PROJ::internal::c_locale_stod(offsetY); |
| 179 | } catch (const std::exception &) { |
| 180 | proj_log_error(P, _("Invalid offset value")); |
| 181 | return false; |
| 182 | } |
| 183 | } |
| 184 |
no test coverage detected