PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ RASTER_sameAlignment()

Datum RASTER_sameAlignment ( PG_FUNCTION_ARGS  )

Definition at line 1193 of file rtpg_spatial_relationship.c.

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

References ES_NONE, rt_raster_deserialize(), rt_raster_destroy(), rt_raster_same_alignment(), and TRUE.

Here is the call graph for this function: