Quellcode durchsuchen

Take special care of the "+towgs84" value list comparison

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54767 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert vor 12 Jahren
Ursprung
Commit
dc226e1675
1 geänderte Dateien mit 11 neuen und 2 gelöschten Zeilen
  1. 11 2
      lib/python/script/core.py

+ 11 - 2
lib/python/script/core.py

@@ -660,7 +660,7 @@ def _text_to_key_value_dict(filename, sep=":", val_sep=","):
 def compare_key_value_text_files(filename_a, filename_b, sep=":",
                                  val_sep=",", precision=0.000001):
     """
-        !Compare two key-value text files that may contain projection parameter
+        !Compare two key-value text files that contain projection parameter
 
         @param filename_a The name of the first key-value text file
         @param filenmae_b The name of the second key-value text file
@@ -685,6 +685,9 @@ def compare_key_value_text_files(filename_a, filename_b, sep=":",
     """
     dict_a = _text_to_key_value_dict(filename_a, sep)
     dict_b = _text_to_key_value_dict(filename_b, sep)
+    
+    print dict_a
+    print dict_b
 
     missing_keys = 0
 
@@ -696,7 +699,13 @@ def compare_key_value_text_files(filename_a, filename_b, sep=":",
                 if abs(dict_a[key] - dict_b[key]) > precision:
                     return False
             elif isinstance(dict_a[key], float) or isinstance(dict_b[key], float):
-                return False
+                warning(_("Mixing value types. Will try to compare after "
+                          "integer conversion"))
+                return int(dict_a[key]) ==  int(dict_b[key])
+            elif key == "+towgs84":
+                # We compare the sum of the entries
+                if abs(sum(dict_a[key]) - sum(dict_b[key])) > precision:
+                    return False
             else:
                 if dict_a[key] != dict_b[key]:
                     return False