]> granicus.if.org Git - postgis/commitdiff
Invalid geography polygons: BOOM! Could not generate outside point! (#1046)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 9 Feb 2012 00:37:43 +0000 (00:37 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 9 Feb 2012 00:37:43 +0000 (00:37 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9127 b70326c6-7e19-0410-871a-916f4a2858ee

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

index e0d27f34dc2b69f4e73754c99c15f47cb0ae8503..36df9e8249052814f061f08280f9142d3e5c76b3 100644 (file)
@@ -160,9 +160,9 @@ static void test_gserialized_get_gbox_geocentric(void)
                gbox_geocentric_slow = LW_FALSE;
                lwgeom_free(lwg);
 #if 0
-               printf("\nCALC: %s\n", gbox_to_string(gbox));
-               printf("GOOD: %s\n", gbox_to_string(gbox_slow));
-               printf("line %d: diff %.9g\n", i, fabs(gbox->xmin - gbox_slow->xmin)+fabs(gbox->ymin - gbox_slow->ymin)+fabs(gbox->zmin - gbox_slow->zmin));
+               printf("\nCALC: %s\n", gbox_to_string(&gbox));
+               printf("GOOD: %s\n", gbox_to_string(&gbox_slow));
+               printf("line %d: diff %.9g\n", i, fabs(gbox.xmin - gbox_slow.xmin)+fabs(gbox.ymin - gbox_slow.ymin)+fabs(gbox.zmin - gbox_slow.zmin));
                printf("------------\n");
 #endif
                CU_ASSERT_DOUBLE_EQUAL(gbox.xmin, gbox_slow.xmin, 0.000001);
index e78a3965e5a2305bb26930912045628fb59c3992..b7fbf980fc636e97112269f234d2430dacf3cb9b 100644 (file)
@@ -15,8 +15,8 @@ char gbox_data[][512] =
 {
        "LINESTRING(-0 40,0 -30)",
        "LINESTRING(-180 90,180 -80)",
-       "LINESTRING(-0 90,0 -90)",
-       "LINESTRING(0 90,80 -90)",
+       "LINESTRING(-0 90,0 -89)",
+       "LINESTRING(0 90,80 -89)",
        "LINESTRING(0 -5,0 -5)",
        "LINESTRING(180 -35,180 45)",
        "LINESTRING(158 -85,-57 86)",
@@ -27,7 +27,7 @@ char gbox_data[][512] =
        "LINESTRING(-3.083333333333333333333333333333333 9.83333333333333333333333333333333,15.5 -5.25)",
        "LINESTRING(86.85 9.85,105.5 -5.25)",
        "LINESTRING(-120.0 62.55,-120.0 62.55)",
-       "LINESTRING(-135.0 40.0,45.0 -40.0)",
+       "LINESTRING(-135.0 40.0,45.0 -39.0)",
        "LINESTRING(-120.0 62.55,60.0 73.25)",
        "LINESTRING(-120.0 -62.55,60.0 -73.25)",
        "LINESTRING(-120.0 20.0,-120.5 20.0)",
index 9a36d2fcc35341c4185b7458d33ad0dfd6e53de5..c38fbef8055221deb0e5435e7989a8157c1e7cb7 100644 (file)
@@ -958,7 +958,7 @@ int edge_calculate_gbox_slow(const GEOGRAPHIC_EDGE *e, GBOX *gbox)
                LWDEBUG(4, "edge is antipodal. setting to maximum size box, and returning");
                gbox->xmin = gbox->ymin = gbox->zmin = -1.0;
                gbox->xmax = gbox->ymax = gbox->zmax = 1.0;
-               return LW_SUCCESS;
+               return LW_SUCCESS; 
        }
 
        /* Walk along the chord between start and end incrementally,
@@ -1033,10 +1033,15 @@ int edge_calculate_gbox(const GEOGRAPHIC_EDGE *e, GBOX *gbox)
           set the box to contain the whole world and return */
        if ( FP_EQUALS(distance, M_PI) )
        {
-               LWDEBUG(4, "edge is antipodal. setting to maximum size box, and returning");
+               lwerror("Invalid geography. Antipodal edge (180 degrees long) detected: (%g %g,%g %g)",
+                       rad2deg(e->start.lon),rad2deg(e->start.lat),rad2deg(e->end.lon),rad2deg(e->end.lat) );
+               return LW_FAILURE;
+
+/*             LWDEBUG(4, "edge is antipodal. setting to maximum size box, and returning");
                gbox->xmin = gbox->ymin = gbox->zmin = -1.0;
                gbox->xmax = gbox->ymax = gbox->zmax = 1.0;
-               return LW_SUCCESS;
+               
+               return LW_SUCCESS; */
        }
 
        /* Calculate the difference in longitude between the two points. */