Просмотр исходного кода

Fix raster_info to handle D:M:S output from r.info

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@37072 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 16 лет назад
Родитель
Сommit
1bc6bc5b43
1 измененных файлов с 7 добавлено и 2 удалено
  1. 7 2
      lib/python/grass.py

+ 7 - 2
lib/python/grass.py

@@ -589,15 +589,20 @@ def raster_history(map):
     
     warning("Unable to write history for <%s>. Raster map <%s> not found in current mapset." % (map, map))
     return False
-    
+
+def float_or_dms(s):
+    return sum(float(x) / 60 ** n for (n, x) in enumerate(s.split(':')))
+
 # run "r.info -rgstmpud ..." and parse output
 
 def raster_info(map):
     """Return information about a raster map (interface to `r.info')."""
     s = read_command('r.info', flags = 'rgstmpud', map = map)
     kv = parse_key_val(s)
-    for k in ['min', 'max', 'north', 'south', 'east', 'west', 'nsres', 'ewres']:
+    for k in ['min', 'max', 'north', 'south', 'east', 'west']:
 	kv[k] = float(kv[k])
+    for k in ['nsres', 'ewres']:
+	kv[k] = float_or_dms(kv[k])
     return kv
 
 # interface to r.mapcalc