Get auth name and code.
277 const char *srs = NULL;
279 assert(authname != NULL);
280 assert(authcode != NULL);
285 srs = GDALGetProjectionRef(hds);
286 if (srs != NULL && srs[0] !=
'\0') {
287 OGRSpatialReferenceH hSRS = OSRNewSpatialReference(NULL);
289 if (OSRSetFromUserInput(hSRS, srs) == OGRERR_NONE) {
290 const char* pszAuthorityName = OSRGetAuthorityName(hSRS, NULL);
291 const char* pszAuthorityCode = OSRGetAuthorityCode(hSRS, NULL);
293 if (pszAuthorityName != NULL && pszAuthorityCode != NULL) {
294 size_t authorityName_len = strlen(pszAuthorityName) +1;
295 size_t authorityCode_len = strlen(pszAuthorityCode) + 1;
296 *authname =
rtalloc(
sizeof(
char) * authorityName_len);
297 *authcode =
rtalloc(
sizeof(
char) * authorityCode_len);
299 if (*authname == NULL || *authcode == NULL) {
300 rterror(
"rt_util_gdal_sr_auth_info: Could not allocate memory for auth name and code");
301 if (*authname != NULL)
rtdealloc(*authname);
302 if (*authcode != NULL)
rtdealloc(*authcode);
303 OSRDestroySpatialReference(hSRS);
307 strncpy(*authname, pszAuthorityName, authorityName_len);
308 strncpy(*authcode, pszAuthorityCode, authorityCode_len);
312 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)