[GRASS-SVN] r51507 - grass/trunk/temporal/t.rast.import
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Apr 23 18:32:37 EDT 2012
Author: huhabla
Date: 2012-04-23 15:32:37 -0700 (Mon, 23 Apr 2012)
New Revision: 51507
Modified:
grass/trunk/temporal/t.rast.import/t.rast.import.py
grass/trunk/temporal/t.rast.import/test.t.rast.import.sh
Log:
Enable location creation without data import
Modified: grass/trunk/temporal/t.rast.import/t.rast.import.py
===================================================================
--- grass/trunk/temporal/t.rast.import/t.rast.import.py 2012-04-23 20:45:18 UTC (rev 51506)
+++ grass/trunk/temporal/t.rast.import/t.rast.import.py 2012-04-23 22:32:37 UTC (rev 51507)
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
############################################################################
#
-# MODULE: tr.import
+# MODULE: t.rast.import
# AUTHOR(S): Soeren Gebbert
#
# PURPOSE: Import a space time raster dataset
@@ -26,12 +26,9 @@
#%option G_OPT_STRDS_OUTPUT
#%end
-#%option
+#%option G_OPT_M_DIR
#% key: extrdir
-#% type: string
#% description: Path to the extraction directory
-#% required: yes
-#% multiple: no
#%end
#%option
@@ -73,7 +70,13 @@
#% description: override projection (use location's projection)
#%end
+#%flag
+#% key: c
+#% description: Create the location specified by the "location" parameter and exit. Do not import the space time raster datasets.
+#%end
+
+
import shutil
import os
import os.path
@@ -101,6 +104,7 @@
link = flags["l"]
exp = flags["e"]
overr = flags["o"]
+ create = flags["c"]
grass.set_raise_on_error(True)
@@ -139,8 +143,12 @@
grass.create_location(dbase=old_env["GISDBASE"],
location=location,
proj4=proj4_string)
- except:
- grass.fatal(_("Unable to create location %s") % location)
+ # Just create a new location and return
+ if create:
+ os.chdir(old_cwd)
+ return
+ except Exception as e:
+ grass.fatal(_("Unable to create location %s. Reason: %s") % (location, str(e)))
# Switch to the new created location
ret = grass.run_command("g.mapset", mapset="PERMANENT",
location=location,
Modified: grass/trunk/temporal/t.rast.import/test.t.rast.import.sh
===================================================================
--- grass/trunk/temporal/t.rast.import/test.t.rast.import.sh 2012-04-23 20:45:18 UTC (rev 51506)
+++ grass/trunk/temporal/t.rast.import/test.t.rast.import.sh 2012-04-23 22:32:37 UTC (rev 51507)
@@ -26,6 +26,8 @@
prec_6|2001-06-01|2001-07-01
EOF
+eval `g.gisenv`
+
t.create --o type=strds temporaltype=absolute output=precip_abs1 title="A test with input files" descr="A test with input files"
# The first @test
@@ -35,10 +37,15 @@
# Import the data into a new location
t.rast.import --o location=new_test_1 input=strds_export.tar.bz2 output=precip_abs1 extrdir=test\
title="A test" description="Description of a test"
+ls -la $GISDBASE/new_test_1/PERMANENT
t.rast.import --o location=new_test_2 input=strds_export.tar.bz2 output=precip_abs1 extrdir=test\
-l title="A test" description="Description of a test"
+ls -la $GISDBASE/new_test_2/PERMANENT
+t.rast.import --o location=new_test_3 input=strds_export.tar.bz2 output=precip_abs1 extrdir=test\
+ -c title="A test" description="Description of a test"
+ls -la $GISDBASE/new_test_3/PERMANENT
t.rast.import --o input=strds_export.tar.bz2 output=precip_abs1 extrdir=test\
-oe title="A test" description="Description of a test"
@@ -56,6 +63,6 @@
rm -rf test
rm strds_export.tar.bz2
# Remove the newly created locations
-eval `g.gisenv`
rm -rf $GISDBASE/new_test_1
rm -rf $GISDBASE/new_test_2
+rm -rf $GISDBASE/new_test_3
More information about the grass-commit
mailing list