From b4c3d8a1d41584bc57741ff8fb0824765c4283f3 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 12 May 2015 00:01:18 +0000 Subject: [PATCH] #3108, subdivide dropping some squares git-svn-id: http://svn.osgeo.org/postgis/trunk@13489 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/lwgeom.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/liblwgeom/lwgeom.c b/liblwgeom/lwgeom.c index 5a9032525..0c4b1c332 100644 --- a/liblwgeom/lwgeom.c +++ b/liblwgeom/lwgeom.c @@ -1937,10 +1937,15 @@ lwgeom_subdivide_recursive(const LWGEOM *geom, int maxvertices, LWCOLLECTION *co /* Is it because it's a rectangle totally *inside* a polygon? */ if ( geom->type == POLYGONTYPE ) { - POINT2D pt; - pt.x = clip->xmin; - pt.y = clip->ymin; - if ( lwpoly_contains_point((LWPOLY*)geom, &pt) ) + const LWPOLY *poly = (LWPOLY*)geom; + POINT2D pt_ll, pt_lr, pt_ur, pt_ul; + pt_ll.x = pt_ul.x = clip->xmin; + pt_lr.x = pt_ur.x = clip->xmax; + pt_ul.y = pt_ur.y = clip->ymax; + pt_ll.y = pt_lr.y = clip->ymin; + + if ( lwpoly_contains_point(poly, &pt_ll) || lwpoly_contains_point(poly, &pt_ul) || + lwpoly_contains_point(poly, &pt_lr) || lwpoly_contains_point(poly, &pt_ur) ) { /* TODO: Probably just making the clipping box into a polygon is a more */ /* efficient way to do this? */ -- 2.40.0