]> granicus.if.org Git - postgis/commitdiff
#2638, geography ST_Intersects bugginess with Polygon/multilinestring M
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 6 Mar 2014 05:54:41 +0000 (05:54 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 6 Mar 2014 05:54:41 +0000 (05:54 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@12297 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/cu_geodetic.c
liblwgeom/g_box.c

index f9b41d54260537ee30e2bf5de2210fb753c3362f..ac54d38170170c5a47b93e6570b27e1fa1ca630c 100644 (file)
@@ -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)
index f89f35dd44236e2672ba6d50fa286174b6e0a1d6..dd4d21aa2979430903d132f0b3a4ffb6627766e8 100644 (file)
@@ -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;