From: Paul Ramsey Date: Thu, 6 Mar 2014 05:54:41 +0000 (+0000) Subject: #2638, geography ST_Intersects bugginess with Polygon/multilinestring M X-Git-Tag: 2.2.0rc1~1208 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=79e019ea313e5a5ed69221e61d670a5707579ba8;p=postgis #2638, geography ST_Intersects bugginess with Polygon/multilinestring M git-svn-id: http://svn.osgeo.org/postgis/trunk@12297 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/cunit/cu_geodetic.c b/liblwgeom/cunit/cu_geodetic.c index f9b41d542..ac54d3817 100644 --- a/liblwgeom/cunit/cu_geodetic.c +++ b/liblwgeom/cunit/cu_geodetic.c @@ -1220,6 +1220,21 @@ static void test_lwgeom_distance_sphere(void) lwgeom_free(lwg1); lwgeom_free(lwg2); + /* Ticket #2638, no "M" */ + lwg1 = lwgeom_from_wkt("LINESTRING (-41.0821 50.3036,50 -41)", LW_PARSER_CHECK_NONE); + lwg2 = lwgeom_from_wkt("POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5))", LW_PARSER_CHECK_NONE); + d = lwgeom_distance_spheroid(lwg1, lwg2, &s, 0.0); + CU_ASSERT_DOUBLE_EQUAL(d, 0.0, 0.00001); + lwgeom_free(lwg1); + lwgeom_free(lwg2); + + /* Ticket #2638, with "M" */ + lwg1 = lwgeom_from_wkt("LINESTRING M (-41.0821 50.3036 1,50 -41 1)", LW_PARSER_CHECK_NONE); + lwg2 = lwgeom_from_wkt("POLYGON M ((0 0 2,10 0 1,10 10 -2,0 10 -5,0 0 -5),(5 5 6,7 5 6,7 7 6,5 7 10,5 5 -2))", LW_PARSER_CHECK_NONE); + d = lwgeom_distance_spheroid(lwg1, lwg2, &s, 0.0); + CU_ASSERT_DOUBLE_EQUAL(d, 0.0, 0.00001); + lwgeom_free(lwg1); + lwgeom_free(lwg2); } static void test_spheroid_distance(void) diff --git a/liblwgeom/g_box.c b/liblwgeom/g_box.c index f89f35dd4..dd4d21aa2 100644 --- a/liblwgeom/g_box.c +++ b/liblwgeom/g_box.c @@ -246,10 +246,19 @@ int gbox_overlaps(const GBOX *g1, const GBOX *g2) if ( g1->xmax < g2->xmin || g1->ymax < g2->ymin || g1->xmin > g2->xmax || g1->ymin > g2->ymax ) return LW_FALSE; + + /* Deal with the geodetic case special: we only compare the geodetic boxes (x/y/z) */ + /* Never the M dimension */ + if ( FLAGS_GET_GEODETIC(g1->flags) && FLAGS_GET_GEODETIC(g2->flags) ) + { + if ( g1->zmax < g2->zmin || g1->zmin > g2->zmax ) + return LW_FALSE; + else + return LW_TRUE; + } /* If both geodetic or both have Z, check Z */ - if ( (FLAGS_GET_Z(g1->flags) && FLAGS_GET_Z(g2->flags)) || - (FLAGS_GET_GEODETIC(g1->flags) && FLAGS_GET_GEODETIC(g2->flags)) ) + if ( FLAGS_GET_Z(g1->flags) && FLAGS_GET_Z(g2->flags) ) { if ( g1->zmax < g2->zmin || g1->zmin > g2->zmax ) return LW_FALSE;