PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ RASTER_notSameAlignmentReason()

Datum RASTER_notSameAlignmentReason ( PG_FUNCTION_ARGS  )

Definition at line 1256 of file rtpg_spatial_relationship.c.

1257 {
1258  const uint32_t set_count = 2;
1259  rt_pgraster *pgrast[2];
1260  int pgrastpos[2] = {-1, -1};
1261  rt_raster rast[2] = {NULL};
1262 
1263  uint32_t i;
1264  uint32_t j;
1265  uint32_t k;
1266  int rtn;
1267  int aligned = 0;
1268  char *reason = NULL;
1269  text *result = NULL;
1270 
1271  for (i = 0, j = 0; i < set_count; i++) {
1272  /* pgrast is null, return null */
1273  if (PG_ARGISNULL(j)) {
1274  for (k = 0; k < i; k++) {
1275  rt_raster_destroy(rast[k]);
1276  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1277  }
1278  PG_RETURN_NULL();
1279  }
1280  pgrast[i] = (rt_pgraster *) PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(j), 0, sizeof(struct rt_raster_serialized_t));
1281  pgrastpos[i] = j;
1282  j++;
1283 
1284  /* raster */
1285  rast[i] = rt_raster_deserialize(pgrast[i], TRUE);
1286  if (!rast[i]) {
1287  for (k = 0; k <= i; k++) {
1288  if (k < i)
1289  rt_raster_destroy(rast[k]);
1290  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1291  }
1292  elog(ERROR, "RASTER_notSameAlignmentReason: Could not deserialize the %s raster", i < 1 ? "first" : "second");
1293  PG_RETURN_NULL();
1294  }
1295  }
1296 
1298  rast[0],
1299  rast[1],
1300  &aligned,
1301  &reason
1302  );
1303  for (k = 0; k < set_count; k++) {
1304  rt_raster_destroy(rast[k]);
1305  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1306  }
1307 
1308  if (rtn != ES_NONE) {
1309  elog(ERROR, "RASTER_notSameAlignmentReason: Could not test for alignment on the two rasters");
1310  PG_RETURN_NULL();
1311  }
1312 
1313  result = cstring_to_text(reason);
1314  PG_RETURN_TEXT_P(result);
1315 }
#define TRUE
Definition: dbfopen.c:169
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
@ ES_NONE
Definition: librtcore.h:180
rt_errorstate rt_raster_same_alignment(rt_raster rast1, rt_raster rast2, int *aligned, char **reason)
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_serialize.c:725
Struct definitions.
Definition: librtcore.h:2250
unsigned int uint32_t
Definition: uthash.h:78

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

Here is the call graph for this function: