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

Definition at line 14489 of file rt_pg.c.

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

14490 {
14491  const int set_count = 2;
14492  rt_pgraster *pgrast[2];
14493  int pgrastpos[2] = {-1, -1};
14494  rt_raster rast[2] = {NULL};
14495 
14496  uint32_t i;
14497  uint32_t j;
14498  uint32_t k;
14499  int rtn;
14500  int aligned = 0;
14501  char *reason = NULL;
14502  text *result = NULL;
14503 
14504  for (i = 0, j = 0; i < set_count; i++) {
14505  /* pgrast is null, return null */
14506  if (PG_ARGISNULL(j)) {
14507  for (k = 0; k < i; k++) {
14508  rt_raster_destroy(rast[k]);
14509  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
14510  }
14511  PG_RETURN_NULL();
14512  }
14513  pgrast[i] = (rt_pgraster *) PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(j), 0, sizeof(struct rt_raster_serialized_t));
14514  pgrastpos[i] = j;
14515  j++;
14516 
14517  /* raster */
14518  rast[i] = rt_raster_deserialize(pgrast[i], TRUE);
14519  if (!rast[i]) {
14520  for (k = 0; k <= i; k++) {
14521  if (k < i)
14522  rt_raster_destroy(rast[k]);
14523  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
14524  }
14525  elog(ERROR, "RASTER_notSameAlignmentReason: Could not deserialize the %s raster", i < 1 ? "first" : "second");
14526  PG_RETURN_NULL();
14527  }
14528  }
14529 
14531  rast[0],
14532  rast[1],
14533  &aligned,
14534  &reason
14535  );
14536  for (k = 0; k < set_count; k++) {
14537  rt_raster_destroy(rast[k]);
14538  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
14539  }
14540 
14541  if (rtn != ES_NONE) {
14542  elog(ERROR, "RASTER_notSameAlignmentReason: Could not test for alignment on the two rasters");
14543  PG_RETURN_NULL();
14544  }
14545 
14546  result = cstring2text(reason);
14547  PG_RETURN_TEXT_P(result);
14548 }
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_api.c:5387
tuple rast
Definition: rtpixdump.py:62
char ** result
Definition: liblwgeom.h:218
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: