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

Method StripVertical

ogr/ogrspatialreference.cpp:8949–8993  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8947 */
8948
8949OGRErr OGRSpatialReference::StripVertical()
8950
8951{
8952 TAKE_OPTIONAL_LOCK();
8953
8954 d->refreshProjObj();
8955 d->demoteFromBoundCRS();
8956 if (!d->m_pj_crs || d->m_pjType != PJ_TYPE_COMPOUND_CRS)
8957 {
8958 d->undoDemoteFromBoundCRS();
8959 return OGRERR_NONE;
8960 }
8961 auto horizCRS = proj_crs_get_sub_crs(d->getPROJContext(), d->m_pj_crs, 0);
8962 if (!horizCRS)
8963 {
8964 d->undoDemoteFromBoundCRS();
8965 return OGRERR_FAILURE;
8966 }
8967
8968 bool reuseExistingBoundCRS = false;
8969 if (d->m_pj_bound_crs_target)
8970 {
8971 auto type = proj_get_type(d->m_pj_bound_crs_target);
8972 reuseExistingBoundCRS = type == PJ_TYPE_GEOCENTRIC_CRS ||
8973 type == PJ_TYPE_GEOGRAPHIC_2D_CRS ||
8974 type == PJ_TYPE_GEOGRAPHIC_3D_CRS;
8975 }
8976
8977 if (reuseExistingBoundCRS)
8978 {
8979 auto newBoundCRS = proj_crs_create_bound_crs(
8980 d->getPROJContext(), horizCRS, d->m_pj_bound_crs_target,
8981 d->m_pj_bound_crs_co);
8982 proj_destroy(horizCRS);
8983 d->undoDemoteFromBoundCRS();
8984 d->setPjCRS(newBoundCRS);
8985 }
8986 else
8987 {
8988 d->undoDemoteFromBoundCRS();
8989 d->setPjCRS(horizCRS);
8990 }
8991
8992 return OGRERR_NONE;
8993}
8994
8995/************************************************************************/
8996/* OSRStripVertical() */

Callers 9

OSRStripVerticalFunction · 0.80
test_osr_strip_verticalFunction · 0.80
GDALRPCOpenDEMFunction · 0.80
bagdataset.cppFile · 0.80
GTIFSetFromOGISDefnExFunction · 0.80

Calls 5

refreshProjObjMethod · 0.80
demoteFromBoundCRSMethod · 0.80
getPROJContextMethod · 0.80
setPjCRSMethod · 0.80

Tested by 1

test_osr_strip_verticalFunction · 0.64