142 {
145 GEOSGeometry *geom1 = NULL;
146 GEOSGeometry *geom2 = NULL;
147 int rtn = 0;
148 int flag = 0;
149
151
152 assert(NULL != rast1);
153 assert(NULL != rast2);
154 assert(NULL != testresult);
155
156 if (nband1 < 0 && nband2 < 0) {
157 nband1 = -1;
158 nband2 = -1;
159 }
160 else {
163 }
164
165
166 *testresult = 0;
167
168
170 rterror(
"rt_raster_geos_spatial_relationship: The two rasters provided have different SRIDs");
172 }
173
175
176
178 rterror(
"rt_raster_geos_spatial_relationship: Could not get surface of the specified band from the first raster");
180 }
182 rterror(
"rt_raster_geos_spatial_relationship: Could not get surface of the specified band from the second raster");
185 }
186
187
188 if (surface1 == NULL || surface2 == NULL) {
192 }
193
194
197 if (geom1 == NULL) {
198 rterror(
"rt_raster_geos_spatial_relationship: Could not convert surface of the specified band from the first raster to a GEOSGeometry");
201 }
202
205 if (geom2 == NULL) {
206 rterror(
"rt_raster_geos_spatial_relationship: Could not convert surface of the specified band from the second raster to a GEOSGeometry");
208 }
209
210 flag = 0;
211 switch (testtype) {
213 rtn = GEOSOverlaps(geom1, geom2);
214 break;
216 rtn = GEOSTouches(geom1, geom2);
217 break;
219 rtn = GEOSContains(geom1, geom2);
220 break;
222 rtn = GEOSRelatePattern(geom1, geom2, "T**FF*FF*");
223 break;
225 rtn = GEOSRelatePattern(geom1, geom2, "******FF*");
226 break;
228 rtn = GEOSRelatePattern(geom1, geom2, "**F**F***");
229 break;
230 default:
231 rterror(
"rt_raster_geos_spatial_relationship: Unknown or unsupported GEOS spatial relationship test");
232 flag = -1;
233 break;
234 }
235 GEOSGeom_destroy(geom1);
236 GEOSGeom_destroy(geom2);
237
238
239 if (rtn == 2) {
240 rterror(
"rt_raster_geos_spatial_relationship: Could not run the appropriate GEOS spatial relationship test");
242 }
243
244 else if (flag >= 0) {
245 if (rtn != 0)
246 *testresult = 1;
248 }
249
250 else
252
253 return flag;
254}
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
void lwgeom_geos_error(const char *fmt,...)
void lwmpoly_free(LWMPOLY *mpoly)
LWGEOM * lwmpoly_as_lwgeom(const LWMPOLY *obj)
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
#define RASTER_DEBUG(level, msg)
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
void void rtinfo(const char *fmt,...) __attribute__((format(printf
rt_errorstate rt_raster_surface(rt_raster raster, int nband, LWMPOLY **surface)
Get a raster as a surface (multipolygon).
uint16_t rt_raster_get_num_bands(rt_raster raster)