static OGRSpatialReference* BuildSRS(const char* pszWKT) { OGRSpatialReference* poSRS = new OGRSpatialReference(pszWKT); if (poSRS->morphFromESRI() != OGRERR_NONE) { delete poSRS; return nullptr; } else { if (poSRS->AutoIdentifyEPSG() != OGRERR_NONE) { int nEntries = 0; int* panConfidence = nullptr; OGRSpatialReferenceH* pahSRS = poSRS->FindMatches(nullptr, &nEntries, &panConfidence); if (nEntries == 1 && panConfidence[0] == 100) { poSRS->Release(); poSRS = reinterpret_cast<OGRSpatialReference*>(pahSRS[0]); CPLFree(pahSRS); } else { OSRFreeSRSArray(pahSRS); } CPLFree(panConfidence); } return poSRS; } }