| 6148 | */ |
| 6149 | |
| 6150 | double OGRSpatialReference::GetProjParm(const char *pszName, |
| 6151 | double dfDefaultValue, |
| 6152 | OGRErr *pnErr) const |
| 6153 | |
| 6154 | { |
| 6155 | TAKE_OPTIONAL_LOCK(); |
| 6156 | |
| 6157 | d->refreshProjObj(); |
| 6158 | GetRoot(); // force update of d->m_bNodesWKT2 |
| 6159 | |
| 6160 | if (pnErr != nullptr) |
| 6161 | *pnErr = OGRERR_NONE; |
| 6162 | |
| 6163 | /* -------------------------------------------------------------------- */ |
| 6164 | /* Find the desired parameter. */ |
| 6165 | /* -------------------------------------------------------------------- */ |
| 6166 | const OGR_SRSNode *poPROJCS = |
| 6167 | GetAttrNode(d->m_bNodesWKT2 ? "CONVERSION" : "PROJCS"); |
| 6168 | if (poPROJCS == nullptr) |
| 6169 | { |
| 6170 | if (pnErr != nullptr) |
| 6171 | *pnErr = OGRERR_FAILURE; |
| 6172 | return dfDefaultValue; |
| 6173 | } |
| 6174 | |
| 6175 | const int iChild = FindProjParm(pszName, poPROJCS); |
| 6176 | if (iChild == -1) |
| 6177 | { |
| 6178 | if (IsProjected() && GetAxesCount() == 3) |
| 6179 | { |
| 6180 | OGRSpatialReference *poSRSTmp = Clone(); |
| 6181 | poSRSTmp->DemoteTo2D(nullptr); |
| 6182 | const double dfRet = |
| 6183 | poSRSTmp->GetProjParm(pszName, dfDefaultValue, pnErr); |
| 6184 | delete poSRSTmp; |
| 6185 | return dfRet; |
| 6186 | } |
| 6187 | |
| 6188 | if (pnErr != nullptr) |
| 6189 | *pnErr = OGRERR_FAILURE; |
| 6190 | return dfDefaultValue; |
| 6191 | } |
| 6192 | |
| 6193 | const OGR_SRSNode *poParameter = poPROJCS->GetChild(iChild); |
| 6194 | return CPLAtof(poParameter->GetChild(1)->GetValue()); |
| 6195 | } |
| 6196 | |
| 6197 | /************************************************************************/ |
| 6198 | /* OSRGetProjParm() */ |