[postgis-tickets] r14486 - #3393, ST_Area NaN on some polygons
Daniel Baston
dbaston at gmail.com
Mon Dec 14 04:58:27 PST 2015
Author: dbaston
Date: 2015-12-14 04:58:27 -0800 (Mon, 14 Dec 2015)
New Revision: 14486
Modified:
branches/2.2/liblwgeom/cunit/cu_geodetic.c
branches/2.2/liblwgeom/lwgeodetic.c
Log:
#3393, ST_Area NaN on some polygons
Modified: branches/2.2/liblwgeom/cunit/cu_geodetic.c
===================================================================
--- branches/2.2/liblwgeom/cunit/cu_geodetic.c 2015-12-14 12:52:58 UTC (rev 14485)
+++ branches/2.2/liblwgeom/cunit/cu_geodetic.c 2015-12-14 12:58:27 UTC (rev 14486)
@@ -1556,8 +1556,24 @@
area = lwgeom_area_sphere(lwg, &s);
CU_ASSERT_DOUBLE_EQUAL(area, 12360265021.3561, 1.0);
- lwgeom_free(lwg);
- return;
+ lwgeom_free(lwg);
+
+ /* Robustness tests, from ticket #3393 */
+ lwg = lwgeom_from_wkt("POLYGON((0 78.703946026663,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026663))", LW_PARSER_CHECK_NONE);
+ area = lwgeom_area_sphere(lwg, &s);
+ CU_ASSERT_DOUBLE_EQUAL(area, 127516467322130, 1.0);
+ lwgeom_free(lwg);
+
+ lwg = lwgeom_from_wkt("POLYGON((0 78.703946026662,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026662))", LW_PARSER_CHECK_NONE);
+ area = lwgeom_area_sphere(lwg, &s);
+ CU_ASSERT_DOUBLE_EQUAL(area, 127516467322130, 1.0);
+ lwgeom_free(lwg);
+
+ lwg = lwgeom_from_wkt("POLYGON((0 78.703946026664,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026664))", LW_PARSER_CHECK_NONE);
+ area = lwgeom_area_sphere(lwg, &s);
+ CU_ASSERT_DOUBLE_EQUAL(area, 127516467322130, 1.0);
+ lwgeom_free(lwg);
+ /* end #3393 */
}
/*
Modified: branches/2.2/liblwgeom/lwgeodetic.c
===================================================================
--- branches/2.2/liblwgeom/lwgeodetic.c 2015-12-14 12:52:58 UTC (rev 14485)
+++ branches/2.2/liblwgeom/lwgeodetic.c 2015-12-14 12:58:27 UTC (rev 14486)
@@ -916,7 +916,7 @@
*/
double sphere_distance_cartesian(const POINT3D *s, const POINT3D *e)
{
- return acos(dot_product(s, e));
+ return acos(FP_MIN(1.0, dot_product(s, e)));
}
/**
More information about the postgis-tickets
mailing list