瀏覽代碼

g.gui.vdigit: add new flag to create new vector map if doesn't exist

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57452 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 年之前
父節點
當前提交
e084f4f05b
共有 1 個文件被更改,包括 12 次插入2 次删除
  1. 12 2
      gui/wxpython/vdigit/g.gui.vdigit.py

+ 12 - 2
gui/wxpython/vdigit/g.gui.vdigit.py

@@ -26,8 +26,12 @@
 #% keywords: editing
 #% keywords: editing
 #% keywords: digitization
 #% keywords: digitization
 #%end
 #%end
+#%flag
+#% key: c
+#% description: Create new vector map if doesn't exist
+#%end
 #%option G_OPT_V_MAP
 #%option G_OPT_V_MAP
-#%label: Name of vector map to load
+#% label: Name of vector map to edit
 #%end
 #%end
 
 
 import os
 import os
@@ -92,6 +96,12 @@ if __name__ == "__main__":
     
     
     if not grass.find_file(name = options['map'], element = 'vector',
     if not grass.find_file(name = options['map'], element = 'vector',
                            mapset = grass.gisenv()['MAPSET'])['fullname']:
                            mapset = grass.gisenv()['MAPSET'])['fullname']:
-        grass.fatal(_("Vector map <%s> not found in current mapset") % options['map'])
+        if not flags['c']:
+            grass.fatal(_("Vector map <%s> not found in current mapset. "
+                          "New vector map can be created by providing '-c' flag.") % options['map'])
+        else:
+            grass.message(_("New vector map <%s> created") % options['map'])
+            if 0 != grass.run_command('v.edit', map = options['map'], tool = 'create'):
+                grass.fatal(_("Unable to create new vector map <%s>") % options['map'])
     
     
     GuiModuleMain(main)
     GuiModuleMain(main)