Get auth name and code.
272 {
273 const char *srs = NULL;
274
275 assert(authname != NULL);
276 assert(authcode != NULL);
277
278 *authname = NULL;
279 *authcode = NULL;
280
281 srs = GDALGetProjectionRef(hds);
282 if (srs != NULL && srs[0] != '\0') {
283 OGRSpatialReferenceH hSRS = OSRNewSpatialReference(NULL);
284
285 if (OSRSetFromUserInput(hSRS, srs) == OGRERR_NONE) {
286 const char* pszAuthorityName = OSRGetAuthorityName(hSRS, NULL);
287 const char* pszAuthorityCode = OSRGetAuthorityCode(hSRS, NULL);
288
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);
294
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);
301 }
302
303 strncpy(*authname, pszAuthorityName, authorityName_len);
304 strncpy(*authcode, pszAuthorityCode, authorityCode_len);
305 }
306 }
307
308 OSRDestroySpatialReference(hSRS);
309 }
310
312}
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)