浏览代码

Enable location creation without data import

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@51507 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 13 年之前
父节点
当前提交
09b67f4079
共有 2 个文件被更改,包括 23 次插入8 次删除
  1. 15 7
      temporal/t.rast.import/t.rast.import.py
  2. 8 1
      temporal/t.rast.import/test.t.rast.import.sh

+ 15 - 7
temporal/t.rast.import/t.rast.import.py

@@ -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,6 +70,12 @@
 #% 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
@@ -101,6 +104,7 @@ def main():
     link = flags["l"]
     exp = flags["e"]
     overr = flags["o"]
+    create = flags["c"]
 
     grass.set_raise_on_error(True)
     
@@ -139,8 +143,12 @@ def main():
 	    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, 

+ 8 - 1
temporal/t.rast.import/test.t.rast.import.sh

@@ -26,6 +26,8 @@ prec_5|2001-05-01|2001-06-01
 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 @@ t.rast.export input=precip_abs1 output=strds_export.tar.bz2 compression=bzip2 wo
 # 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 @@ g.remove rast=prec_1,prec_2,prec_3,prec_4,prec_5,prec_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