瀏覽代碼

r.in.wms: fix 'region' option (patch by Stepan Turek)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54606 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 12 年之前
父節點
當前提交
7ef9a67c7d
共有 2 個文件被更改,包括 17 次插入12 次删除
  1. 15 5
      scripts/r.in.wms/r.in.wms.py
  2. 2 7
      scripts/r.in.wms/wms_base.py

+ 15 - 5
scripts/r.in.wms/r.in.wms.py

@@ -177,10 +177,15 @@ import grass.script as grass
 def GetRegionParams(opt_region):
 
     # set region 
-    if opt_region:                 
-        if not grass.find_file(name = opt_region, element = 'windows', mapset = '.' )['name']:
-            grass.fatal(_("Region <%s> not found") % opt_region)
-        
+    if opt_region:  
+        reg_spl = opt_region.strip().split('@', 1)
+        reg_mapset = '.'
+        if len(reg_spl) > 1:
+            reg_mapset = reg_spl[1]
+            
+        if not grass.find_file(name = reg_spl[0], element = 'windows', mapset = reg_mapset)['name']:
+             grass.fatal(_("Region <%s> not found") % opt_region)
+    
     if opt_region:
         s = grass.read_command('g.region',
                                 quiet = True,
@@ -209,8 +214,13 @@ def main():
     else:
         from wms_base import GRASSImporter
         options['region'] = GetRegionParams(options['region'])
-        importer = GRASSImporter(options['output'])
         fetched_map = wms.GetMap(options, flags)
+
+        grass.message(_("Importing raster map into GRASS..."))
+        if not fetched_map:
+            grass.warning(_("Nothing to import.\nNo data has been downloaded from wms server."))
+            return
+        importer = GRASSImporter(options['output'])
         importer.ImportMapIntoGRASS(fetched_map)
 
     return 0

+ 2 - 7
scripts/r.in.wms/wms_base.py

@@ -430,16 +430,10 @@ class GRASSImporter:
     def ImportMapIntoGRASS(self, raster): 
         """!Import raster into GRASS.
         """
-
-        grass.message(_("Importing raster map into GRASS..."))
-
-        if not raster:
-            grass.warning(_("Nothing to import.\nNo data has been downloaded from wms server."))
-            return
-
         # importing temp_map into GRASS
         if grass.run_command('r.in.gdal',
                              quiet = True,
+                             overwrite = True,
                              input = raster,
                              output = self.opt_output) != 0:
             grass.fatal(_('%s failed') % 'r.in.gdal')
@@ -480,6 +474,7 @@ class GRASSImporter:
         if grass.find_file(self.opt_output + '.red', element = 'cell', mapset = '.')['file']:
             if grass.run_command('r.composite',
                                  quiet = True,
+                                 overwrite = True,
                                  red = self.opt_output + '.red',
                                  green = self.opt_output +  '.green',
                                  blue = self.opt_output + '.blue',