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