Commit aace8c2f authored by Paul Ramsey's avatar Paul Ramsey
Browse files

Make PostGIS and GEOS consistent in handling clipping at the border of the...

Make PostGIS and GEOS consistent in handling clipping at the border of the rectangle (both now clip boundary vertices)
References #5962
parent fd9de191
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1546,8 +1546,9 @@ Datum ST_ClipByBox2d(PG_FUNCTION_ARGS)
	bbox2 = (GBOX *)PG_GETARG_POINTER(box2d_idx);
	bbox2->flags = 0;

	/* if bbox1 is covered by bbox2, return lwgeom1 */
	if (gbox_contains_2d(bbox2, &bbox1))
	/* If bbox1 is strictly contained by bbox2, return input geometry */
	if (bbox2->xmin < bbox1.xmin && bbox2->xmax > bbox1.xmax &&
	    bbox2->ymin < bbox1.ymin && bbox2->ymax > bbox1.ymax)
	{
		PG_RETURN_DATUM(PG_GETARG_DATUM(geom_idx));
	}
+10 −0
Original line number Diff line number Diff line
@@ -1613,3 +1613,13 @@ CREATE TABLE test5987 (geom geometry(Geometry,4326));
INSERT INTO test5987 VALUES('LINESTRING(20 20,20.1 20,20.2 19.9)'::geometry);
SELECT '#5987', ST_AsText(geom), ST_AsText(ST_GeometryN(geom, 1)) FROM test5987;
DROP TABLE IF EXISTS test5987;

-- -------------------------------------------------------------------------------------
-- #5962
SELECT '#5962',
    ST_AsText(ST_ClipByBox2D(
        ST_GeomFromText('MULTIPOINT((1 1),(3 4),(5 4))'),
        ST_MakeEnvelope(0, 0, 5, 5)), 2),
    ST_AsText(ST_ClipByBox2D(
        ST_GeomFromText('MULTIPOINT((1 1),(6 4),(5 4))'),
        ST_MakeEnvelope(0, 0, 5, 5 )), 2);
+1 −0
Original line number Diff line number Diff line
@@ -491,3 +491,4 @@ public|test5829|geom|2|4326|GEOMETRY
public|test5978|geometry|2|4326|POINT
public|test5978|shape|2|4326|POINT
#5987|LINESTRING(20 20,20.1 20,20.2 19.9)|LINESTRING(20 20,20.1 20,20.2 19.9)
#5962|MULTIPOINT((1 1),(3 4))|POINT(1 1)