]> granicus.if.org Git - postgis/commitdiff
HAck fix for NaN areas.
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 13 Oct 2009 19:39:19 +0000 (19:39 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 13 Oct 2009 19:39:19 +0000 (19:39 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@4646 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwgeodetic.c

index 0cb1be26935947fa69d54dce94556068b3b7fde7..48071199e5030b4748463077bfb46379b7192991 100644 (file)
@@ -628,6 +628,13 @@ static double sphere_excess(GEOGRAPHIC_POINT a, GEOGRAPHIC_POINT b, GEOGRAPHIC_P
        double sign = signum(hcb-hca);
        double ss = (a_dist + b_dist + c_dist) / 2.0;
        double E = tan(ss/2.0)*tan((ss-a_dist)/2.0)*tan((ss-b_dist)/2.0)*tan((ss-c_dist)/2.0);
+       /* This is a worrying hack, the number had to be tuned a lot to find 
+          the dividing line between things so small they caused a NaN and 
+          things large enough to effect the final output areas. Probably we
+          will have platform difficulties with this.
+       */
+       if( fabs(E) < 1.0e-30 )
+               E = 0.0;
        return 4.0 * atan(sqrt(E)) * sign;
 }