CU_ASSERT_STRING_EQUAL(wkt, tmp)
lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
+ /* Disjoint polygon */
+ wkt = "POLYGON((311017 4773762,311016 4773749,311006 4773744,310990 4773748,310980 4773758,310985 4773771,311003 4773776,311017 4773762))";
+ in = lwgeom_from_wkt(wkt, LW_PARSER_CHECK_NONE);
+ out = lwgeom_clip_by_rect(in, -80, -80, 80, 80);
+ //tmp = lwgeom_to_ewkt(out); printf("%s\n", tmp); lwfree(tmp);
+ CU_ASSERT(lwgeom_is_empty(out));
+ lwgeom_free(out); lwgeom_free(in);
+
#endif /* POSTGIS_GEOS_VERSION >= 35 */
}
if ( LW_FALSE == gbox_overlaps_2d(bbox1, bbox2) ) {
lwresult = lwgeom_construct_empty(lwgeom1->type, lwgeom1->srid, 0, 0);
lwgeom_free(lwgeom1);
- PG_FREE_IF_COPY(geom1, 1);
+ PG_FREE_IF_COPY(geom1, 0);
result = geometry_serialize(lwresult) ;
lwgeom_free(lwresult) ;
PG_RETURN_POINTER(result);
SELECT ST_AsText(ST_ClipByBox2d(
'0103000000010000000400000000000000000000000000000000000000000000000000244000000000000000000000000000002440000000000000244000000000000000000000000000002440'
, ST_MakeEnvelope(2,2,5,5)));
-
+-- Geometry disjoint from box, from a table
+-- See http://trac.osgeo.org/postgis/ticket/2950
+CREATE TEMPORARY TABLE t AS SELECT
+'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;
POLYGON((2 2,8 2,2 8,8 8,2 2))
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