[GRASS-dev] r.unpack: unhelpful error message when projection info does not match
Luca Delucchi
lucadeluge at gmail.com
Fri Feb 28 14:14:20 PST 2014
On 28 February 2014 15:38, Markus Neteler <neteler at osgeo.org> wrote:
>
> Ideas? thanks
>
I think the attached patch should fix the problem (I have no time to
test it), but I don't know if it broke something else.
I saw the function compare_key_value_text_files is used only in
r/v.unpack and temporal/stds_import.py, Soeren the attached patch
could create problem in this file?
> Markus
>
--
ciao
Luca
http://gis.cri.fmach.it/delucchi/
www.lucadelu.org
-------------- next part --------------
Index: lib/python/script/core.py
===================================================================
--- lib/python/script/core.py (revision 59147)
+++ lib/python/script/core.py (working copy)
@@ -901,7 +901,7 @@
@param precision precision with which the floating point values are compared
@param proj True if it has to check some information about projection system
@param units True if it has to check some information about units
-
+
@return True if full or almost identical, False if different
"""
dict_a = _text_to_key_value_dict(filename_a, sep, checkproj=proj,
@@ -909,34 +909,26 @@
dict_b = _text_to_key_value_dict(filename_b, sep, checkproj=proj,
checkunits=units)
- missing_keys = 0
+ if sorted(dict_a.keys()) != sorted(dict_b.keys()):
+ return False
# We compare matching keys
for key in dict_a.keys():
- if key in dict_b:
- # Floating point values must be handled separately
- if isinstance(dict_a[key], float) and isinstance(dict_b[key], float):
- if abs(dict_a[key] - dict_b[key]) > precision:
- return False
- elif isinstance(dict_a[key], float) or isinstance(dict_b[key], float):
- 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
+ # Floating point values must be handled separately
+ if isinstance(dict_a[key], float) and isinstance(dict_b[key], float):
+ if abs(dict_a[key] - dict_b[key]) > precision:
+ return False
+ elif isinstance(dict_a[key], float) or isinstance(dict_b[key], float):
+ 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:
- missing_keys += 1
- if missing_keys == len(dict_a):
- return False
- if missing_keys > 0:
- warning(_("Several keys (%(miss)i out of %(a)i) are missing "
- "in the target file") % {'miss': missing_keys,
- 'a': len(dict_a)})
+ if dict_a[key] != dict_b[key]:
+ return False
return True
def diff_files(filename_a, filename_b):
More information about the grass-dev
mailing list