Get auth name and code.
274 const char *srs = NULL;
276 assert(authname != NULL);
277 assert(authcode != NULL);
282 srs = GDALGetProjectionRef(hds);
283 if (srs != NULL && srs[0] !=
'\0') {
284 OGRSpatialReferenceH hSRS = OSRNewSpatialReference(NULL);
286 if (OSRSetFromUserInput(hSRS, srs) == OGRERR_NONE) {
287 const char* pszAuthorityName = OSRGetAuthorityName(hSRS, NULL);
288 const char* pszAuthorityCode = OSRGetAuthorityCode(hSRS, NULL);
290 if (pszAuthorityName != NULL && pszAuthorityCode != NULL) {
291 size_t authorityName_len = strlen(pszAuthorityName) +1;
292 size_t authorityCode_len = strlen(pszAuthorityCode) + 1;
293 *authname =
rtalloc(
sizeof(
char) * authorityName_len);
294 *authcode =
rtalloc(
sizeof(
char) * authorityCode_len);
296 if (*authname == NULL || *authcode == NULL) {
297 rterror(
"rt_util_gdal_sr_auth_info: Could not allocate memory for auth name and code");
298 if (*authname != NULL)
rtdealloc(*authname);
299 if (*authcode != NULL)
rtdealloc(*authcode);
300 OSRDestroySpatialReference(hSRS);
304 strncpy(*authname, pszAuthorityName, authorityName_len);
305 strncpy(*authcode, pszAuthorityCode, authorityCode_len);
309 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)