PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum RASTER_sameAlignment ( PG_FUNCTION_ARGS  )

Definition at line 14422 of file rt_pg.c.

References ES_NONE, rtpixdump::rast, rt_raster_deserialize(), rt_raster_destroy(), rt_raster_same_alignment(), and TRUE.

14423 {
14424  const int set_count = 2;
14425  rt_pgraster *pgrast[2];
14426  int pgrastpos[2] = {-1, -1};
14427  rt_raster rast[2] = {NULL};
14428 
14429  uint32_t i;
14430  uint32_t j;
14431  uint32_t k;
14432  int rtn;
14433  int aligned = 0;
14434  char *reason = NULL;
14435 
14436  for (i = 0, j = 0; i < set_count; i++) {
14437  /* pgrast is null, return null */
14438  if (PG_ARGISNULL(j)) {
14439  for (k = 0; k < i; k++) {
14440  rt_raster_destroy(rast[k]);
14441  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
14442  }
14443  PG_RETURN_NULL();
14444  }
14445  pgrast[i] = (rt_pgraster *) PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(j), 0, sizeof(struct rt_raster_serialized_t));
14446  pgrastpos[i] = j;
14447  j++;
14448 
14449  /* raster */
14450  rast[i] = rt_raster_deserialize(pgrast[i], TRUE);
14451  if (!rast[i]) {
14452  for (k = 0; k <= i; k++) {
14453  if (k < i)
14454  rt_raster_destroy(rast[k]);
14455  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
14456  }
14457  elog(ERROR, "RASTER_sameAlignment: Could not deserialize the %s raster", i < 1 ? "first" : "second");
14458  PG_RETURN_NULL();
14459  }
14460  }
14461 
14463  rast[0],
14464  rast[1],
14465  &aligned,
14466  &reason
14467  );
14468  for (k = 0; k < set_count; k++) {
14469  rt_raster_destroy(rast[k]);
14470  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
14471  }
14472 
14473  if (rtn != ES_NONE) {
14474  elog(ERROR, "RASTER_sameAlignment: Could not test for alignment on the two rasters");
14475  PG_RETURN_NULL();
14476  }
14477 
14478  /* only output reason if not aligned */
14479  if (reason != NULL && !aligned)
14480  elog(NOTICE, "%s", reason);
14481 
14482  PG_RETURN_BOOL(aligned);
14483 }
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_api.c:5387
tuple rast
Definition: rtpixdump.py:62
Struct definitions.
Definition: rt_api.h:2175
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_api.c:8350
rt_errorstate rt_raster_same_alignment(rt_raster rast1, rt_raster rast2, int *aligned, char **reason)
Definition: rt_api.c:12774
#define TRUE
Definition: dbfopen.c:170

Here is the call graph for this function: