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