PostGIS  2.2.7dev-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 270 of file rt_util.c.

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

Referenced by RASTER_addBandOutDB(), and rt_raster_from_gdal_dataset().

270  {
271  const char *srs = NULL;
272 
273  assert(authname != NULL);
274  assert(authcode != NULL);
275 
276  *authname = NULL;
277  *authcode = NULL;
278 
279  srs = GDALGetProjectionRef(hds);
280  if (srs != NULL && srs[0] != '\0') {
281  OGRSpatialReferenceH hSRS = OSRNewSpatialReference(NULL);
282 
283  if (OSRSetFromUserInput(hSRS, srs) == OGRERR_NONE) {
284  const char* pszAuthorityName = OSRGetAuthorityName(hSRS, NULL);
285  const char* pszAuthorityCode = OSRGetAuthorityCode(hSRS, NULL);
286 
287  if (pszAuthorityName != NULL && pszAuthorityCode != NULL) {
288  *authname = rtalloc(sizeof(char) * (strlen(pszAuthorityName) + 1));
289  *authcode = rtalloc(sizeof(char) * (strlen(pszAuthorityCode) + 1));
290 
291  if (*authname == NULL || *authcode == NULL) {
292  rterror("rt_util_gdal_sr_auth_info: Could not allocate memory for auth name and code");
293  if (*authname != NULL) rtdealloc(*authname);
294  if (*authcode != NULL) rtdealloc(*authcode);
295  OSRDestroySpatialReference(hSRS);
296  return ES_ERROR;
297  }
298 
299  strncpy(*authname, pszAuthorityName, strlen(pszAuthorityName) + 1);
300  strncpy(*authcode, pszAuthorityCode, strlen(pszAuthorityCode) + 1);
301  }
302  }
303 
304  OSRDestroySpatialReference(hSRS);
305  }
306 
307  return ES_NONE;
308 }
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
void rtdealloc(void *mem)
Definition: rt_context.c:186

Here is the call graph for this function:

Here is the caller graph for this function: