long long msudf_crosses(UDF_INIT *initid,UDF_ARGS *args,char *is_null, char *error) { GEOSGeom geom1,geom2; long long result; DEBUG("msudf_crosses"); geom1 = msudf_getGeometry((unsigned char *)args->args[0],args->lengths[0]); if (geom1 == NULL) { strcpy(error,"Invalid geometry."); *is_null = 1; return 0; } geom2 = msudf_getGeometry((unsigned char *)args->args[1],args->lengths[1]); if (geom2 == NULL) { strcpy(error,"Invalid geometry."); *is_null = 1; return 0; } result = GEOSCrosses(geom1,geom2); if (geom1 != NULL) GEOSGeom_destroy(geom1); if (geom2 != NULL) GEOSGeom_destroy(geom2); if (result >1) { *is_null = 1; return 0; } else { return result; } }
/* ** Does shape1 cross shape2, returns MS_TRUE/MS_FALSE or -1 for an error. */ int msGEOSCrosses(shapeObj *shape1, shapeObj *shape2) { #ifdef USE_GEOS GEOSGeom g1, g2; int result; if(!shape1 || !shape2) return -1; if(!shape1->geometry) /* if no geometry for shape1 then build one */ shape1->geometry = (GEOSGeom) msGEOSShape2Geometry(shape1); g1 = shape1->geometry; if(!g1) return -1; if(!shape2->geometry) /* if no geometry for shape2 then build one */ shape2->geometry = (GEOSGeom) msGEOSShape2Geometry(shape2); g2 = shape2->geometry; if(!g2) return -1; result = GEOSCrosses(g1, g2); return ((result==2) ? -1 : result); #else msSetError(MS_GEOSERR, "GEOS support is not available.", "msGEOSCrosses()"); return -1; #endif }