From: Paul Ramsey Date: Thu, 9 Feb 2012 00:37:43 +0000 (+0000) Subject: Invalid geography polygons: BOOM! Could not generate outside point! (#1046) X-Git-Tag: 2.0.0alpha5~70 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2f360b6b986875498febdf10a2dc77ce77a91eb;p=postgis Invalid geography polygons: BOOM! Could not generate outside point! (#1046) git-svn-id: http://svn.osgeo.org/postgis/trunk@9127 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/cunit/cu_geodetic.c b/liblwgeom/cunit/cu_geodetic.c index e0d27f34d..36df9e824 100644 --- a/liblwgeom/cunit/cu_geodetic.c +++ b/liblwgeom/cunit/cu_geodetic.c @@ -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); diff --git a/liblwgeom/cunit/cu_geodetic_data.h b/liblwgeom/cunit/cu_geodetic_data.h index e78a3965e..b7fbf980f 100644 --- a/liblwgeom/cunit/cu_geodetic_data.h +++ b/liblwgeom/cunit/cu_geodetic_data.h @@ -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)", diff --git a/liblwgeom/lwgeodetic.c b/liblwgeom/lwgeodetic.c index 9a36d2fcc..c38fbef80 100644 --- a/liblwgeom/lwgeodetic.c +++ b/liblwgeom/lwgeodetic.c @@ -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. */