]> granicus.if.org Git - postgis/commitdiff
Whoops make sure the test macros match the library ones
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 24 Oct 2012 18:54:23 +0000 (18:54 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 24 Oct 2012 18:54:23 +0000 (18:54 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10545 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/cu_geodetic.c
liblwgeom/lwgeodetic.c
liblwgeom/lwgeodetic.h
liblwgeom/lwgeodetic_tree.c

index 23c7d86982434c427c6f4c27fa3357ec707d5706..1fe4d3239fe15dd96bba245ab91eb377f0f8b876 100644 (file)
@@ -518,7 +518,7 @@ static void test_edge_intersects(void)
        line2pts("LINESTRING(50 -10.999999999999998224, -10.0 50.0)", &A1, &A2);
        line2pts("LINESTRING(-10.0 50.0, -10.272779983831613393 -16.937003313332997578)", &B1, &B2);
        rv = edge_intersects(&A1, &A2, &B1, &B2);
-       CU_ASSERT(rv > 0);
+       CU_ASSERT(rv & PIR_INTERSECTS);
 
        /* Medford case, very short segment vs very long one */
        g.lat = 0.74123572595649878103;
@@ -550,7 +550,7 @@ static void test_edge_intersects(void)
        g.lon = 2.1065275171200439353;
        geog2cart(&g, &B2);
        rv = edge_intersects(&A1, &A2, &B1, &B2);
-       CU_ASSERT_EQUAL(rv, 1);
+       CU_ASSERT(rv == PIR_INTERSECTS);
 
        /* Again, this time with a less exact input edge. */
        line2pts("LINESTRING(-123.165031277506 42.4696787216231, -123.165031605021 42.4697127292275)", &A1, &A2);
@@ -561,45 +561,43 @@ static void test_edge_intersects(void)
        line2pts("LINESTRING(-1.0 0.0, 1.0 0.0)", &A1, &A2);
        line2pts("LINESTRING(0.0 -1.0, 0.0 1.0)", &B1, &B2);
        rv = edge_intersects(&A1, &A2, &B1, &B2);
-       CU_ASSERT_EQUAL(rv, PIR_INTERSECTS);
+       CU_ASSERT(rv == PIR_INTERSECTS);
 
        /*  No intersection at (0 0) */
        line2pts("LINESTRING(-1.0 0.0, 1.0 0.0)", &A1, &A2);
        line2pts("LINESTRING(0.0 -1.0, 0.0 -2.0)", &B1, &B2);
        rv = edge_intersects(&A1, &A2, &B1, &B2);
-       CU_ASSERT_EQUAL(rv, 0);
+       CU_ASSERT(rv == 0);
 
        /*  End touches middle of segment at (0 0) */
        line2pts("LINESTRING(-1.0 0.0, 1.0 0.0)", &A1, &A2);
        line2pts("LINESTRING(0.0 -1.0, 0.0 0.0)", &B1, &B2);
        rv = edge_intersects(&A1, &A2, &B1, &B2);
-       printf("\nEnd touches middle of segment: %d\n", rv);
-       CU_ASSERT_EQUAL(rv, PIR_INTERSECTS|PIR_B_TOUCH_RIGHT);
+       CU_ASSERT(rv == (PIR_INTERSECTS|PIR_B_TOUCH_RIGHT) );
 
        /*  End touches end of segment at (0 0) */
        line2pts("LINESTRING(0.0 0.0, 1.0 0.0)", &A1, &A2);
        line2pts("LINESTRING(0.0 -1.0, 0.0 0.0)", &B1, &B2);
        rv = edge_intersects(&A1, &A2, &B1, &B2);
-       printf("End touches end of segment: %d\n", rv);
-       CU_ASSERT_EQUAL(rv, PIR_INTERSECTS|PIR_B_TOUCH_RIGHT|PIR_A_TOUCH_RIGHT);
+       CU_ASSERT(rv == (PIR_INTERSECTS|PIR_B_TOUCH_RIGHT|PIR_A_TOUCH_RIGHT) );
 
        /* Intersection at (180 0) */
        line2pts("LINESTRING(-179.0 -1.0, 179.0 1.0)", &A1, &A2);
        line2pts("LINESTRING(-179.0 1.0, 179.0 -1.0)", &B1, &B2);
        rv = edge_intersects(&A1, &A2, &B1, &B2);
-       CU_ASSERT_EQUAL(rv, PIR_INTERSECTS);
+       CU_ASSERT(rv == PIR_INTERSECTS);
 
        /* Intersection at (180 0) */
        line2pts("LINESTRING(-170.0 0.0, 170.0 0.0)", &A1, &A2);
        line2pts("LINESTRING(180.0 -10.0, 180.0 10.0)", &B1, &B2);
        rv = edge_intersects(&A1, &A2, &B1, &B2);
-       CU_ASSERT_EQUAL(rv, PIR_INTERSECTS);
+       CU_ASSERT(rv == PIR_INTERSECTS);
 
        /* Intersection at north pole */
        line2pts("LINESTRING(-180.0 80.0, 0.0 80.0)", &A1, &A2);
        line2pts("LINESTRING(90.0 80.0, -90.0 80.0)", &B1, &B2);
        rv = edge_intersects(&A1, &A2, &B1, &B2);
-       CU_ASSERT_EQUAL(rv, PIR_INTERSECTS);
+       CU_ASSERT(rv == PIR_INTERSECTS);
 
        /* Equal edges return true */
        line2pts("LINESTRING(45.0 10.0, 50.0 20.0)", &A1, &A2);
@@ -611,21 +609,19 @@ static void test_edge_intersects(void)
        line2pts("LINESTRING(40.0 0.0, 70.0 0.0)", &A1, &A2);
        line2pts("LINESTRING(60.0 0.0, 50.0 0.0)", &B1, &B2);
        rv = edge_intersects(&A1, &A2, &B1, &B2);
-       CU_ASSERT_EQUAL(rv, PIR_INTERSECTS|PIR_COLINEAR);
+       CU_ASSERT(rv == (PIR_INTERSECTS|PIR_COLINEAR) );
 
        /* End touches arc at north pole */
        line2pts("LINESTRING(-180.0 80.0, 0.0 80.0)", &A1, &A2);
        line2pts("LINESTRING(90.0 80.0, -90.0 90.0)", &B1, &B2);
        rv = edge_intersects(&A1, &A2, &B1, &B2);
-       printf("End touches arc at north pole: %d\n", rv);
-       CU_ASSERT_EQUAL(rv, PIR_INTERSECTS|PIR_B_TOUCH_LEFT);
+       CU_ASSERT(rv == (PIR_INTERSECTS|PIR_B_TOUCH_LEFT) );
        
        /* End touches end at north pole */
        line2pts("LINESTRING(-180.0 80.0, 0.0 90.0)", &A1, &A2);
        line2pts("LINESTRING(90.0 80.0, -90.0 90.0)", &B1, &B2);
        rv = edge_intersects(&A1, &A2, &B1, &B2);
-       printf("End touches end at north pole: %d\n", rv);
-       CU_ASSERT_EQUAL(rv, PIR_INTERSECTS|PIR_B_TOUCH_LEFT|PIR_A_TOUCH_RIGHT);
+       CU_ASSERT(rv == (PIR_INTERSECTS|PIR_B_TOUCH_LEFT|PIR_A_TOUCH_RIGHT) );
 }
 
 
index 9e5c23891201e2f459c63aad714e1c3797da8596..b6480086cb0af2d5dc18b1daed39938c9b74ad3f 100644 (file)
@@ -3236,24 +3236,24 @@ edge_intersects(const POINT3D *A1, const POINT3D *A2, const POINT3D *B1, const P
        if ( a1_side == 0 )
        {
                /* Touches at A1, A2 is on what side? */
-               rv |= (a2_side < 0 ? PIR_A_TOUCH_LEFT : PIR_A_TOUCH_RIGHT);
+               rv |= (a2_side < 0 ? PIR_A_TOUCH_RIGHT : PIR_A_TOUCH_LEFT);
        }
        else if ( a2_side == 0 )
        {
                /* Touches at A2, A1 is on what side? */
-               rv |= (a1_side < 0 ? PIR_A_TOUCH_LEFT : PIR_A_TOUCH_RIGHT);
+               rv |= (a1_side < 0 ? PIR_A_TOUCH_RIGHT : PIR_A_TOUCH_LEFT);
        }
 
        /* B touches A */
        if ( b1_side == 0 )
        {
                /* Touches at B1, B2 is on what side? */
-               rv |= (b2_side < 0 ? PIR_B_TOUCH_LEFT : PIR_B_TOUCH_RIGHT);
+               rv |= (b2_side < 0 ? PIR_B_TOUCH_RIGHT : PIR_B_TOUCH_LEFT);
        }
        else if ( b2_side == 0 )
        {
                /* Touches at B2, B1 is on what side? */
-               rv |= (b1_side < 0 ? PIR_B_TOUCH_LEFT : PIR_B_TOUCH_RIGHT);
+               rv |= (b1_side < 0 ? PIR_B_TOUCH_RIGHT : PIR_B_TOUCH_LEFT);
        }
        
        return rv;
@@ -3322,14 +3322,14 @@ int ptarray_contains_point_sphere(const POINTARRAY *pa, const POINT2D *pt_outsid
                {
                        /* If the stabline is touching the edge, that implies the test point */
                        /* is on the edge, so we're done, the point is in (on) the ring. */
-                       if ( (inter & PIR_A_TOUCH_LEFT) || (inter & PIR_A_TOUCH_RIGHT) )
+                       if ( (inter & PIR_A_TOUCH_RIGHT) || (inter & PIR_A_TOUCH_LEFT) )
                        {
                                return LW_TRUE;
                        }
                        
                        /* It's a touching interaction, disregard all the left-side ones. */
                        /* It's a co-linear intersection, ignore those. */
-                       if ( inter & PIR_B_TOUCH_LEFT || inter & PIR_COLINEAR )
+                       if ( inter & PIR_B_TOUCH_RIGHT || inter & PIR_COLINEAR )
                        {
                                /* Do nothing, to avoid double counts. */
                                LWDEBUGF(4,"    edge (%d) crossed, disregarding to avoid double count", i, count);
index 0816df712538edcdded8502a1113b6f25bda8a73..b01ccb91077220b71699a8d3019ba172459ef5a6 100644 (file)
@@ -72,10 +72,10 @@ typedef struct
 #define PIR_NO_INTERACT    0x00
 #define PIR_INTERSECTS     0x01
 #define PIR_COLINEAR       0x02
-#define PIR_A_TOUCH_LEFT   0x04
-#define PIR_A_TOUCH_RIGHT  0x08
-#define PIR_B_TOUCH_LEFT   0x10
-#define PIR_B_TOUCH_RIGHT  0x20
+#define PIR_A_TOUCH_RIGHT   0x04
+#define PIR_A_TOUCH_LEFT  0x08
+#define PIR_B_TOUCH_RIGHT   0x10
+#define PIR_B_TOUCH_LEFT  0x20
 
 
 /*
index ea57fcfed876410609e95e878c01403af3077ec1..f06812650e7778e22edc40d7d11742aeb618c9a9 100644 (file)
@@ -439,7 +439,7 @@ int circ_tree_contains_point(const CIRC_NODE* node, const POINT2D* pt, const POI
                                /* To avoid double counting crossings-at-a-vertex, */
                                /* always ignore crossings at "lower" ends of edges*/
 
-                               if ( inter & PIR_B_TOUCH_LEFT || inter & PIR_COLINEAR )
+                               if ( inter & PIR_B_TOUCH_RIGHT || inter & PIR_COLINEAR )
                                {
                                        LWDEBUG(3,"  rejecting stab line grazing by left-side edge");
                                        return 0;
@@ -580,15 +580,21 @@ circ_tree_distance_tree_internal(const CIRC_NODE* n1, const CIRC_NODE* n2, doubl
                        else
                        {
                                GEOGRAPHIC_EDGE e1, e2;
-                               GEOGRAPHIC_POINT g1;
+                               GEOGRAPHIC_POINT g;
+                               POINT3D A1, A2, B1, B2;
                                geographic_point_init(n1->p1->x, n1->p1->y, &(e1.start));
                                geographic_point_init(n1->p2->x, n1->p2->y, &(e1.end));
                                geographic_point_init(n2->p1->x, n2->p1->y, &(e2.start));
                                geographic_point_init(n2->p2->x, n2->p2->y, &(e2.end));
-                               if ( edge_intersection(&e1, &e2, &g1) )
+                               geog2cart(&(e1.start), &A1);
+                               geog2cart(&(e1.end), &A2);
+                               geog2cart(&(e2.start), &B1);
+                               geog2cart(&(e2.end), &B2);
+                               if ( edge_intersects(&A1, &A2, &B1, &B2) )
                                {
                                        d = 0.0;
-                                       close1 = close2 = g1;
+                                       edge_intersection(&e1, &e2, &g);
+                                       close1 = close2 = g;
                                }
                                else
                                {