MCPcopy Create free account
hub / github.com/OSGeo/gdal / GetProjParm

Method GetProjParm

ogr/ogrspatialreference.cpp:6150–6195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6148 */
6149
6150double 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() */

Callers 15

OSRGetProjParmFunction · 0.80
ICreateLayerMethod · 0.80
test_netcdf_6Function · 0.80
test_netcdf_7Function · 0.80
test_netcdf_8Function · 0.80
test_tiff_write_104Function · 0.80
test_osr_esri_4Function · 0.80

Calls 7

CloneFunction · 0.85
CPLAtofFunction · 0.85
refreshProjObjMethod · 0.80
DemoteTo2DMethod · 0.80
GetRootFunction · 0.50
GetChildMethod · 0.45
GetValueMethod · 0.45

Tested by 15

test_netcdf_6Function · 0.64
test_netcdf_7Function · 0.64
test_netcdf_8Function · 0.64
test_tiff_write_104Function · 0.64
test_osr_esri_4Function · 0.64
test_osr_esri_5Function · 0.64
test_osr_esri_12Function · 0.64
test_osr_esri_13Function · 0.64
test_osr_esri_24Function · 0.64