[GRASS-SVN] r54606 - grass/trunk/scripts/r.in.wms
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jan 12 08:13:46 PST 2013
Author: martinl
Date: 2013-01-12 08:13:46 -0800 (Sat, 12 Jan 2013)
New Revision: 54606
Modified:
grass/trunk/scripts/r.in.wms/r.in.wms.py
grass/trunk/scripts/r.in.wms/wms_base.py
Log:
r.in.wms: fix 'region' option (patch by Stepan Turek)
Modified: grass/trunk/scripts/r.in.wms/r.in.wms.py
===================================================================
--- grass/trunk/scripts/r.in.wms/r.in.wms.py 2013-01-12 11:38:56 UTC (rev 54605)
+++ grass/trunk/scripts/r.in.wms/r.in.wms.py 2013-01-12 16:13:46 UTC (rev 54606)
@@ -177,10 +177,15 @@
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 @@
else:
from wms_base import GRASSImporter
options['region'] = GetRegionParams(options['region'])
+ 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'])
- fetched_map = wms.GetMap(options, flags)
importer.ImportMapIntoGRASS(fetched_map)
return 0
Modified: grass/trunk/scripts/r.in.wms/wms_base.py
===================================================================
--- grass/trunk/scripts/r.in.wms/wms_base.py 2013-01-12 11:38:56 UTC (rev 54605)
+++ grass/trunk/scripts/r.in.wms/wms_base.py 2013-01-12 16:13:46 UTC (rev 54606)
@@ -430,16 +430,10 @@
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 @@
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',
More information about the grass-commit
mailing list