PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ RASTER_sameAlignment()

Datum RASTER_sameAlignment ( PG_FUNCTION_ARGS  )

Definition at line 1188 of file rtpg_spatial_relationship.c.

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

Referenced by RASTER_dfullywithin().

1189 {
1190  const int set_count = 2;
1191  rt_pgraster *pgrast[2];
1192  int pgrastpos[2] = {-1, -1};
1193  rt_raster rast[2] = {NULL};
1194 
1195  uint32_t i;
1196  uint32_t j;
1197  uint32_t k;
1198  int rtn;
1199  int aligned = 0;
1200  char *reason = NULL;
1201 
1202  for (i = 0, j = 0; i < set_count; i++) {
1203  /* pgrast is null, return null */
1204  if (PG_ARGISNULL(j)) {
1205  for (k = 0; k < i; k++) {
1206  rt_raster_destroy(rast[k]);
1207  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1208  }
1209  PG_RETURN_NULL();
1210  }
1211  pgrast[i] = (rt_pgraster *) PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(j), 0, sizeof(struct rt_raster_serialized_t));
1212  pgrastpos[i] = j;
1213  j++;
1214 
1215  /* raster */
1216  rast[i] = rt_raster_deserialize(pgrast[i], TRUE);
1217  if (!rast[i]) {
1218  for (k = 0; k <= i; k++) {
1219  if (k < i)
1220  rt_raster_destroy(rast[k]);
1221  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1222  }
1223  elog(ERROR, "RASTER_sameAlignment: Could not deserialize the %s raster", i < 1 ? "first" : "second");
1224  PG_RETURN_NULL();
1225  }
1226  }
1227 
1229  rast[0],
1230  rast[1],
1231  &aligned,
1232  &reason
1233  );
1234  for (k = 0; k < set_count; k++) {
1235  rt_raster_destroy(rast[k]);
1236  PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
1237  }
1238 
1239  if (rtn != ES_NONE) {
1240  elog(ERROR, "RASTER_sameAlignment: Could not test for alignment on the two rasters");
1241  PG_RETURN_NULL();
1242  }
1243 
1244  /* only output reason if not aligned */
1245  if (reason != NULL && !aligned)
1246  elog(NOTICE, "%s", reason);
1247 
1248  PG_RETURN_BOOL(aligned);
1249 }
rt_errorstate rt_raster_same_alignment(rt_raster rast1, rt_raster rast2, int *aligned, char **reason)
unsigned int uint32_t
Definition: uthash.h:78
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
Struct definitions.
Definition: librtcore.h:2201
#define TRUE
Definition: dbfopen.c:169
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_serialize.c:717
Here is the call graph for this function:
Here is the caller graph for this function: