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

Function OSRGetCRSInfoListFromDatabase

ogr/ogrspatialreference.cpp:12944–13021  ·  view source on GitHub ↗

\brief Enumerate CRS objects from the database. * * The returned object is an array of OSRCRSInfo* pointers, whose last * entry is NULL. This array should be freed with OSRDestroyCRSInfoList() * * @param pszAuthName Authority name, used to restrict the search. * Or NULL for all authorities. * @param params Additional criteria. Must be set to NULL for now. * @param pnOutResultCount Output p

Source from the content-addressed store, hash-verified

12942 * @since GDAL 3.0
12943 */
12944OSRCRSInfo **
12945OSRGetCRSInfoListFromDatabase(const char *pszAuthName,
12946 CPL_UNUSED const OSRCRSListParameters *params,
12947 int *pnOutResultCount)
12948{
12949 int nResultCount = 0;
12950 auto projList = proj_get_crs_info_list_from_database(
12951 OSRGetProjTLSContext(), pszAuthName, nullptr, &nResultCount);
12952 if (pnOutResultCount)
12953 *pnOutResultCount = nResultCount;
12954 if (!projList)
12955 {
12956 return nullptr;
12957 }
12958 auto res = new OSRCRSInfo *[nResultCount + 1];
12959 for (int i = 0; i < nResultCount; i++)
12960 {
12961 res[i] = new OSRCRSInfo;
12962 res[i]->pszAuthName = projList[i]->auth_name
12963 ? CPLStrdup(projList[i]->auth_name)
12964 : nullptr;
12965 res[i]->pszCode =
12966 projList[i]->code ? CPLStrdup(projList[i]->code) : nullptr;
12967 res[i]->pszName =
12968 projList[i]->name ? CPLStrdup(projList[i]->name) : nullptr;
12969 res[i]->eType = OSR_CRS_TYPE_OTHER;
12970 switch (projList[i]->type)
12971 {
12972 case PJ_TYPE_GEOGRAPHIC_2D_CRS:
12973 res[i]->eType = OSR_CRS_TYPE_GEOGRAPHIC_2D;
12974 break;
12975 case PJ_TYPE_GEOGRAPHIC_3D_CRS:
12976 res[i]->eType = OSR_CRS_TYPE_GEOGRAPHIC_3D;
12977 break;
12978 case PJ_TYPE_GEOCENTRIC_CRS:
12979 res[i]->eType = OSR_CRS_TYPE_GEOCENTRIC;
12980 break;
12981 case PJ_TYPE_PROJECTED_CRS:
12982 res[i]->eType = OSR_CRS_TYPE_PROJECTED;
12983 break;
12984 case PJ_TYPE_VERTICAL_CRS:
12985 res[i]->eType = OSR_CRS_TYPE_VERTICAL;
12986 break;
12987 case PJ_TYPE_COMPOUND_CRS:
12988 res[i]->eType = OSR_CRS_TYPE_COMPOUND;
12989 break;
12990 default:
12991 break;
12992 }
12993 res[i]->bDeprecated = projList[i]->deprecated;
12994 res[i]->bBboxValid = projList[i]->bbox_valid;
12995 res[i]->dfWestLongitudeDeg = projList[i]->west_lon_degree;
12996 res[i]->dfSouthLatitudeDeg = projList[i]->south_lat_degree;
12997 res[i]->dfEastLongitudeDeg = projList[i]->east_lon_degree;
12998 res[i]->dfNorthLatitudeDeg = projList[i]->north_lat_degree;
12999 res[i]->pszAreaName = projList[i]->area_name
13000 ? CPLStrdup(projList[i]->area_name)
13001 : nullptr;

Callers 1

gdalalgorithm.cppFile · 0.85

Calls 3

OSRGetProjTLSContextFunction · 0.85
CPLStrdupFunction · 0.85
EQUALFunction · 0.50

Tested by

no test coverage detected