Kaynağa Gözat

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 https://trac.osgeo.org/grass/ticket/335)
merge from devbr6


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@37726 15284696-431f-4ddb-bdfa-cd5b030d7da7

Hamish Bowman 16 yıl önce
ebeveyn
işleme
0e24a5a664
1 değiştirilmiş dosya ile 8 ekleme ve 1 silme
  1. 8 1
      lib/gis/wind_format.c

+ 8 - 1
lib/gis/wind_format.c

@@ -85,6 +85,13 @@ void G_format_resolution(double res, char *buf, int projection)
 
 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);
 }