Get auth name and code.
271 const char *srs = NULL;
273 assert(authname != NULL);
274 assert(authcode != NULL);
279 srs = GDALGetProjectionRef(hds);
280 if (srs != NULL && srs[0] !=
'\0') {
281 OGRSpatialReferenceH hSRS = OSRNewSpatialReference(NULL);
283 if (OSRSetFromUserInput(hSRS, srs) == OGRERR_NONE) {
284 const char* pszAuthorityName = OSRGetAuthorityName(hSRS, NULL);
285 const char* pszAuthorityCode = OSRGetAuthorityCode(hSRS, NULL);
287 if (pszAuthorityName != NULL && pszAuthorityCode != NULL) {
288 *authname =
rtalloc(
sizeof(
char) * (strlen(pszAuthorityName) + 1));
289 *authcode =
rtalloc(
sizeof(
char) * (strlen(pszAuthorityCode) + 1));
291 if (*authname == NULL || *authcode == NULL) {
292 rterror(
"rt_util_gdal_sr_auth_info: Could not allocate memory for auth name and code");
293 if (*authname != NULL)
rtdealloc(*authname);
294 if (*authcode != NULL)
rtdealloc(*authcode);
295 OSRDestroySpatialReference(hSRS);
299 strncpy(*authname, pszAuthorityName, strlen(pszAuthorityName) + 1);
300 strncpy(*authcode, pszAuthorityCode, strlen(pszAuthorityCode) + 1);
304 OSRDestroySpatialReference(hSRS);
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
void rtdealloc(void *mem)