PostGIS  2.1.10dev-r@@SVN_REVISION@@
rt_errorstate rt_util_gdal_sr_auth_info ( GDALDatasetH  hds,
char **  authname,
char **  authcode 
)

Get auth name and code.

Parameters
authnameauthority organization of code. calling function is expected to free the memory allocated for value
authcodecode assigned by authority organization. calling function is expected to free the memory allocated for value
Returns
ES_NONE on success, ES_ERROR on error

Definition at line 381 of file rt_api.c.

References ES_ERROR, ES_NONE, rtalloc(), rtdealloc(), and rterror().

Referenced by RASTER_addBandOutDB(), and rt_raster_from_gdal_dataset().

381  {
382  const char *srs = NULL;
383 
384  assert(authname != NULL);
385  assert(authcode != NULL);
386 
387  *authname = NULL;
388  *authcode = NULL;
389 
390  srs = GDALGetProjectionRef(hds);
391  if (srs != NULL && srs[0] != '\0') {
392  OGRSpatialReferenceH hSRS = OSRNewSpatialReference(NULL);
393 
394  if (OSRSetFromUserInput(hSRS, srs) == OGRERR_NONE) {
395  const char* pszAuthorityName = OSRGetAuthorityName(hSRS, NULL);
396  const char* pszAuthorityCode = OSRGetAuthorityCode(hSRS, NULL);
397 
398  if (pszAuthorityName != NULL && pszAuthorityCode != NULL) {
399  *authname = rtalloc(sizeof(char) * (strlen(pszAuthorityName) + 1));
400  *authcode = rtalloc(sizeof(char) * (strlen(pszAuthorityCode) + 1));
401 
402  if (*authname == NULL || *authcode == NULL) {
403  rterror("rt_util_gdal_sr_auth_info: Could not allocate memory for auth name and code");
404  if (*authname != NULL) rtdealloc(*authname);
405  if (*authcode != NULL) rtdealloc(*authcode);
406  OSRDestroySpatialReference(hSRS);
407  return ES_ERROR;
408  }
409 
410  strncpy(*authname, pszAuthorityName, strlen(pszAuthorityName) + 1);
411  strncpy(*authcode, pszAuthorityCode, strlen(pszAuthorityCode) + 1);
412  }
413  }
414 
415  OSRDestroySpatialReference(hSRS);
416  }
417 
418  return ES_NONE;
419 }
void rtdealloc(void *mem)
Definition: rt_api.c:882
void * rtalloc(size_t size)
Raster core memory management functions.
Definition: rt_api.c:867
void rterror(const char *fmt,...)
Raster core error and info handlers.
Definition: rt_api.c:895

Here is the call graph for this function:

Here is the caller graph for this function: