Get auth name and code.
380 {
381 const char *srs = NULL;
382
383 assert(authname != NULL);
384 assert(authcode != NULL);
385
386 *authname = NULL;
387 *authcode = NULL;
388
389 srs = GDALGetProjectionRef(hds);
390 if (srs != NULL && srs[0] != '\0') {
391 OGRSpatialReferenceH hSRS = OSRNewSpatialReference(NULL);
392
393 if (OSRSetFromUserInput(hSRS, srs) == OGRERR_NONE) {
394 const char* pszAuthorityName = OSRGetAuthorityName(hSRS, NULL);
395 const char* pszAuthorityCode = OSRGetAuthorityCode(hSRS, NULL);
396
397 if (pszAuthorityName != NULL && pszAuthorityCode != NULL) {
398 size_t authorityName_len = strlen(pszAuthorityName) +1;
399 size_t authorityCode_len = strlen(pszAuthorityCode) + 1;
400 *authname =
rtalloc(
sizeof(
char) * authorityName_len);
401 *authcode =
rtalloc(
sizeof(
char) * authorityCode_len);
402
403 if (*authname == NULL || *authcode == NULL) {
404 rterror(
"rt_util_gdal_sr_auth_info: Could not allocate memory for auth name and code");
405 if (*authname != NULL)
rtdealloc(*authname);
406 if (*authcode != NULL)
rtdealloc(*authcode);
407 OSRDestroySpatialReference(hSRS);
409 }
410
411 strncpy(*authname, pszAuthorityName, authorityName_len);
412 strncpy(*authcode, pszAuthorityCode, authorityCode_len);
413 }
414 }
415
416 OSRDestroySpatialReference(hSRS);
417 }
418
420}
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
void rtdealloc(void *mem)