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

Method CopyGeogCSFrom

ogr/ogrspatialreference.cpp:3817–3900  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3815 */
3816
3817OGRErr OGRSpatialReference::CopyGeogCSFrom(const OGRSpatialReference *poSrcSRS)
3818
3819{
3820 TAKE_OPTIONAL_LOCK();
3821
3822 d->bNormInfoSet = FALSE;
3823 d->m_osAngularUnits.clear();
3824 d->m_dfAngularUnitToRadian = 0.0;
3825 d->m_osPrimeMeridianName.clear();
3826 d->dfFromGreenwich = 0.0;
3827
3828 d->refreshProjObj();
3829 poSrcSRS->d->refreshProjObj();
3830 if (!poSrcSRS->d->m_pj_crs)
3831 {
3832 return OGRERR_FAILURE;
3833 }
3834 auto geodCRS =
3835 proj_crs_get_geodetic_crs(d->getPROJContext(), poSrcSRS->d->m_pj_crs);
3836 if (!geodCRS)
3837 {
3838 return OGRERR_FAILURE;
3839 }
3840
3841 /* -------------------------------------------------------------------- */
3842 /* Handle geocentric coordinate systems specially. We just */
3843 /* want to copy the DATUM. */
3844 /* -------------------------------------------------------------------- */
3845 if (d->m_pjType == PJ_TYPE_GEOCENTRIC_CRS)
3846 {
3847 auto datum = proj_crs_get_datum(d->getPROJContext(), geodCRS);
3848#if PROJ_VERSION_MAJOR > 7 || \
3849 (PROJ_VERSION_MAJOR == 7 && PROJ_VERSION_MINOR >= 2)
3850 if (datum == nullptr)
3851 {
3852 datum = proj_crs_get_datum_ensemble(d->getPROJContext(), geodCRS);
3853 }
3854#endif
3855 if (datum == nullptr)
3856 {
3857 proj_destroy(geodCRS);
3858 return OGRERR_FAILURE;
3859 }
3860
3861 const char *pszUnitName = nullptr;
3862 double unitConvFactor = GetLinearUnits(&pszUnitName);
3863
3864 auto pj_crs = proj_create_geocentric_crs_from_datum(
3865 d->getPROJContext(), proj_get_name(d->m_pj_crs), datum, pszUnitName,
3866 unitConvFactor);
3867 proj_destroy(datum);
3868
3869 d->setPjCRS(pj_crs);
3870 }
3871
3872 else if (d->m_pjType == PJ_TYPE_PROJECTED_CRS)
3873 {
3874 auto pj_crs = proj_crs_alter_geodetic_crs(d->getPROJContext(),

Callers 15

OSRCopyGeogCSFromFunction · 0.80
GetEPSGGeogCSMethod · 0.80
GetGeodesicInputsFunction · 0.80
FetchSRSIdMethod · 0.80
gdalalgorithm.cppFile · 0.80
gt_wkt_srs.cppFile · 0.80
ScanForGCPsMethod · 0.80
ReadProjectionMethod · 0.80

Calls 5

GetLinearUnitsFunction · 0.85
refreshProjObjMethod · 0.80
getPROJContextMethod · 0.80
setPjCRSMethod · 0.80
clearMethod · 0.45