PG_RETURN_POINTER(geom1);
}
+ /* WARNING: this is really a BOX2DF, use only xmin and ymin fields */
bbox2 = (GBOX *)PG_GETARG_POINTER(1);
- /* If bbox1 outside of bbox, return empty */
- if ( LW_FALSE == gbox_overlaps_2d(bbox1, bbox2) ) {
+ /* If bbox1 outside of bbox2, return empty */
+ if ( bbox1->xmin > bbox2->xmax || bbox1->xmax < bbox2->xmin ||
+ bbox1->ymin > bbox2->ymax || bbox1->ymax < bbox2->ymin )
+ {
lwresult = lwgeom_construct_empty(lwgeom1->type, lwgeom1->srid, 0, 0);
lwgeom_free(lwgeom1);
PG_FREE_IF_COPY(geom1, 0);
PG_RETURN_POINTER(result);
}
- /* if bbox1 is covered by bbox, return lwgeom1 */
+ /* if bbox1 is covered by bbox2, return lwgeom1 */
if ( bbox1->xmax <= bbox2->xmax && bbox1->xmin >= bbox2->xmin &&
bbox1->ymax <= bbox2->ymax && bbox1->ymin >= bbox2->ymin )
{
'SRID=3857;POLYGON((41 20,41 0,21 0,1 20,1 40,21 40,41 20))'
::geometry g;
SELECT ST_AsEWKT(ST_ClipByBox2d(g, ST_MakeEnvelope(-20,-20,-10,-10))) FROM t;
+-- See http://trac.osgeo.org/postgis/ticket/2954
+SELECT ST_AsEWKT(ST_ClipByBox2D('SRID=4326;POINT(0 0)','BOX3D(-1 -1,1 1)'::box3d::box2d));
POLYGON((2.5 2,5 4,5 5,5 4,7.5 2,2.5 2))
POLYGON((2 2,2 5,5 5,5 2,2 2))
SRID=3857;POLYGON EMPTY
+SRID=4326;POINT(0 0)