[GRASS-SVN] r37726 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jun 3 22:23:42 EDT 2009


Author: hamish
Date: 2009-06-03 22:23:42 -0400 (Wed, 03 Jun 2009)
New Revision: 37726

Modified:
   grass/trunk/lib/gis/wind_format.c
Log:
if the programmer has lied to G_format_resolution() about the
projection type in order to get FP values for lat/lon coords,
"%.8f" is not enough to preserve fidelity once converted
back into D:M:S, which leads to rounding errors. (bug #335)
merge from devbr6


Modified: grass/trunk/lib/gis/wind_format.c
===================================================================
--- grass/trunk/lib/gis/wind_format.c	2009-06-04 02:21:43 UTC (rev 37725)
+++ grass/trunk/lib/gis/wind_format.c	2009-06-04 02:23:42 UTC (rev 37726)
@@ -85,6 +85,13 @@
 
 static void format_double(double value, char *buf)
 {
-    sprintf(buf, "%.8f", value);
+    /* if the programmer has lied to G_format_resolution() about the
+        projection type in order to get FP values for lat/lon coords,
+        "%.8f" is not enough to preserve fidelity once converted
+        back into D:M:S, which leads to rounding errors. */
+    if (G_projection() == PROJECTION_LL)
+	sprintf(buf, "%.15g", value);
+    else
+	sprintf(buf, "%.8f", value);
     G_trim_decimal(buf);
 }



More information about the grass-commit mailing list