PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ RASTER_sameAlignment()

Datum RASTER_sameAlignment ( PG_FUNCTION_ARGS  )

Definition at line 1189 of file rtpg_spatial_relationship.c.

1190 {
1191  const uint32_t set_count = 2;
1192  rt_pgraster *pgrast[2];
1193  int pgrastpos[2] = {-1, -1};
1194  rt_raster rast[2] = {NULL};
1195 
1196  uint32_t i;
1197  uint32_t j;
1198  uint32_t k;
1199  int rtn;
1200  int aligned = 0;
1201  char *reason = NULL;
1202 
1203  for (i = 0, j = 0; i < set_count; i++) {
1204  /* pgrast is null, return null */
1205  if (PG_ARGISNULL(j)) {
1206  for (k = 0; k < i; k++) {
1207  rt_raster_destroy(rast[k]);
1208  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1209  }
1210  PG_RETURN_NULL();
1211  }
1212  pgrast[i] = (rt_pgraster *) PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(j), 0, sizeof(struct rt_raster_serialized_t));
1213  pgrastpos[i] = j;
1214  j++;
1215 
1216  /* raster */
1217  rast[i] = rt_raster_deserialize(pgrast[i], TRUE);
1218  if (!rast[i]) {
1219  for (k = 0; k <= i; k++) {
1220  if (k < i)
1221  rt_raster_destroy(rast[k]);
1222  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1223  }
1224  elog(ERROR, "RASTER_sameAlignment: Could not deserialize the %s raster", i < 1 ? "first" : "second");
1225  PG_RETURN_NULL();
1226  }
1227  }
1228 
1230  rast[0],
1231  rast[1],
1232  &aligned,
1233  &reason
1234  );
1235  for (k = 0; k < set_count; k++) {
1236  rt_raster_destroy(rast[k]);
1237  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1238  }
1239 
1240  if (rtn != ES_NONE) {
1241  elog(ERROR, "RASTER_sameAlignment: Could not test for alignment on the two rasters");
1242  PG_RETURN_NULL();
1243  }
1244 
1245  /* only output reason if not aligned */
1246  if (reason != NULL && !aligned)
1247  elog(NOTICE, "%s", reason);
1248 
1249  PG_RETURN_BOOL(aligned);
1250 }
#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: