Browse Source

t.rast.to.rast3: Fixed ticket https://trac.osgeo.org/grass/ticket/2366 by applying the patch from Anna

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@61455 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 10 years ago
parent
commit
2b567bbb4e

+ 12 - 1
temporal/t.rast.to.rast3/t.rast.to.rast3.py

@@ -52,6 +52,12 @@ def main():
 
     maps = sp.get_registered_maps_as_objects_by_granularity()
     num_maps = len(maps)
+    # get datatype of the first map
+    if maps:
+        maps[0][0].select()
+        datatype = maps[0][0].metadata.get_datatype()
+    else:
+        datatype = None
 
     # Get the granularity and set bottom, top and top-bottom resolution
     granularity = sp.get_granularity()
@@ -112,7 +118,12 @@ def main():
 
     # Create a NULL map to fill the gaps
     null_map = "temporary_null_map_%i" % os.getpid()
-    grass.mapcalc("%s = null()" % (null_map))
+    if datatype == 'DCELL':
+        grass.mapcalc("%s = double(null())" % (null_map))
+    elif datatype == 'FCELL':
+        grass.mapcalc("%s = float(null())" % (null_map))
+    else:
+        grass.mapcalc("%s = null()" % (null_map))
 
     if maps:
         count = 0

+ 6 - 6
temporal/t.rast.to.rast3/test.t.rast.to.rast3.sh

@@ -5,12 +5,12 @@
 # The region setting should work for UTM and LL test locations
 g.region s=0 n=80 w=0 e=120 b=0 t=1 res=10 res3=10 -p3
 
-r.mapcalc --o expr="prec_1 = 100"
-r.mapcalc --o expr="prec_2 = 200"
-r.mapcalc --o expr="prec_3 = 300"
-r.mapcalc --o expr="prec_4 = 400"
-r.mapcalc --o expr="prec_5 = 500"
-r.mapcalc --o expr="prec_6 = 600"
+r.mapcalc --o expr="prec_1 = 100.0"
+r.mapcalc --o expr="prec_2 = 200.0"
+r.mapcalc --o expr="prec_3 = 300.0"
+r.mapcalc --o expr="prec_4 = 400.0"
+r.mapcalc --o expr="prec_5 = 500.0"
+r.mapcalc --o expr="prec_6 = 600.0"
 
 n1=`g.tempfile pid=1 -d`