| 11013 | */ |
| 11014 | |
| 11015 | const char *OGRSpatialReference::GetAxis(const char *pszTargetKey, int iAxis, |
| 11016 | OGRAxisOrientation *peOrientation, |
| 11017 | double *pdfConvUnit) const |
| 11018 | |
| 11019 | { |
| 11020 | TAKE_OPTIONAL_LOCK(); |
| 11021 | |
| 11022 | if (peOrientation != nullptr) |
| 11023 | *peOrientation = OAO_Other; |
| 11024 | if (pdfConvUnit != nullptr) |
| 11025 | *pdfConvUnit = 0; |
| 11026 | |
| 11027 | d->refreshProjObj(); |
| 11028 | if (d->m_pj_crs == nullptr) |
| 11029 | { |
| 11030 | return nullptr; |
| 11031 | } |
| 11032 | |
| 11033 | pszTargetKey = d->nullifyTargetKeyIfPossible(pszTargetKey); |
| 11034 | if (pszTargetKey == nullptr && iAxis <= 2) |
| 11035 | { |
| 11036 | auto ctxt = d->getPROJContext(); |
| 11037 | |
| 11038 | int iAxisModified = iAxis; |
| 11039 | |
| 11040 | d->demoteFromBoundCRS(); |
| 11041 | |
| 11042 | PJ *cs = nullptr; |
| 11043 | if (d->m_pjType == PJ_TYPE_COMPOUND_CRS) |
| 11044 | { |
| 11045 | auto horizCRS = proj_crs_get_sub_crs(ctxt, d->m_pj_crs, 0); |
| 11046 | if (horizCRS) |
| 11047 | { |
| 11048 | if (proj_get_type(horizCRS) == PJ_TYPE_BOUND_CRS) |
| 11049 | { |
| 11050 | auto baseCRS = proj_get_source_crs(ctxt, horizCRS); |
| 11051 | if (baseCRS) |
| 11052 | { |
| 11053 | proj_destroy(horizCRS); |
| 11054 | horizCRS = baseCRS; |
| 11055 | } |
| 11056 | } |
| 11057 | cs = proj_crs_get_coordinate_system(ctxt, horizCRS); |
| 11058 | proj_destroy(horizCRS); |
| 11059 | if (cs) |
| 11060 | { |
| 11061 | if (iAxisModified >= proj_cs_get_axis_count(ctxt, cs)) |
| 11062 | { |
| 11063 | iAxisModified -= proj_cs_get_axis_count(ctxt, cs); |
| 11064 | proj_destroy(cs); |
| 11065 | cs = nullptr; |
| 11066 | } |
| 11067 | } |
| 11068 | } |
| 11069 | |
| 11070 | if (cs == nullptr) |
| 11071 | { |
| 11072 | auto vertCRS = proj_crs_get_sub_crs(ctxt, d->m_pj_crs, 1); |
no test coverage detected