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

Function HFAPCSStructToOSR

frmts/hfa/hfaopen.cpp:4066–4787  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4064/************************************************************************/
4065
4066std::unique_ptr<OGRSpatialReference>
4067HFAPCSStructToOSR(const Eprj_Datum *psDatum, const Eprj_ProParameters *psPro,
4068 const Eprj_MapInfo *psMapInfo, HFAEntry *poMapInformation)
4069
4070{
4071 // General case for Erdas style projections.
4072
4073 // We make a particular effort to adapt the mapinfo->proname as
4074 // the PROJCS[] name per #2422.
4075 auto poSRS = std::make_unique<OGRSpatialReference>();
4076 poSRS->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
4077
4078 if (psPro == nullptr && psMapInfo != nullptr)
4079 {
4080 poSRS->SetLocalCS(psMapInfo->proName);
4081 }
4082 else if (psPro == nullptr)
4083 {
4084 return nullptr;
4085 }
4086 else if (psPro->proType == EPRJ_EXTERNAL)
4087 {
4088 if (EQUALN(psPro->proExeName, EPRJ_EXTERNAL_NZMG, 4))
4089 {
4090 // Handle New Zealand Map Grid (NZMG) external projection. See:
4091 // http://www.linz.govt.nz/
4092 //
4093 // Is there a better way that doesn't require hardcoding
4094 // of these numbers?
4095 poSRS->SetNZMG(-41.0, 173.0, 2510000, 6023150);
4096 }
4097 else
4098 {
4099 poSRS->SetLocalCS(psPro->proName);
4100 }
4101 }
4102 else if (psPro->proNumber != EPRJ_LATLONG && psMapInfo != nullptr)
4103 {
4104 poSRS->SetProjCS(psMapInfo->proName);
4105 }
4106 else if (psPro->proNumber != EPRJ_LATLONG)
4107 {
4108 poSRS->SetProjCS(psPro->proName);
4109 }
4110
4111 // Handle units. It is important to deal with this first so
4112 // that the projection Set methods will automatically do
4113 // translation of linear values (like false easting) to PROJCS
4114 // units from meters. Erdas linear projection values are
4115 // always in meters.
4116 if (poSRS->IsProjected() || poSRS->IsLocal())
4117 {
4118 const char *pszUnits = nullptr;
4119
4120 if (psMapInfo)
4121 pszUnits = psMapInfo->units;
4122 else if (poMapInformation != nullptr)
4123 pszUnits = poMapInformation->GetStringField("units.string");

Callers 2

ReadProjectionMethod · 0.85
HFAReadCameraModelFunction · 0.85

Calls 15

HFAGetUnitMapFunction · 0.85
CPLAtofFunction · 0.85
HFAGetDatumMapFunction · 0.85
OSRCalcInvFlatteningFunction · 0.85
fabsFunction · 0.85
OSRGetProjTLSContextFunction · 0.85
CPLTestBoolFunction · 0.85
CPLDebugFunction · 0.85
SetLocalCSMethod · 0.80
SetNZMGMethod · 0.80
SetProjCSMethod · 0.80

Tested by

no test coverage detected