[postgis-tickets] r14485 - #3393, ST_Area NaN on some polygons

Daniel Baston dbaston at gmail.com
Mon Dec 14 04:52:58 PST 2015


Author: dbaston
Date: 2015-12-14 04:52:58 -0800 (Mon, 14 Dec 2015)
New Revision: 14485

Modified:
   trunk/liblwgeom/cunit/cu_geodetic.c
   trunk/liblwgeom/lwgeodetic.c
Log:
#3393, ST_Area NaN on some polygons

Modified: trunk/liblwgeom/cunit/cu_geodetic.c
===================================================================
--- trunk/liblwgeom/cunit/cu_geodetic.c	2015-12-14 10:11:21 UTC (rev 14484)
+++ trunk/liblwgeom/cunit/cu_geodetic.c	2015-12-14 12:52:58 UTC (rev 14485)
@@ -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: trunk/liblwgeom/lwgeodetic.c
===================================================================
--- trunk/liblwgeom/lwgeodetic.c	2015-12-14 10:11:21 UTC (rev 14484)
+++ trunk/liblwgeom/lwgeodetic.c	2015-12-14 12:52:58 UTC (rev 14485)
@@ -931,7 +931,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