浏览代码

wxGUI/g.gui.iclass: fix copy vector features from vector map (#1020)

Tomas Zigo 4 年之前
父节点
当前提交
e3d041f964
共有 2 个文件被更改,包括 20 次插入8 次删除
  1. 19 7
      gui/wxpython/iclass/digit.py
  2. 1 1
      gui/wxpython/iclass/frame.py

+ 19 - 7
gui/wxpython/iclass/digit.py

@@ -129,13 +129,15 @@ class IClassVDigit(IVDigit):
         for cat in cats:
             Vedit_delete_areas_cat(self.poMapInfo, 1, cat)
 
-    def CopyMap(self, name, tmp=False):
+    def CopyMap(self, name, tmp=False, update=False):
         """Make a copy of open vector map
 
         Note: Attributes are not copied
 
         :param name: name for a copy
         :param tmp: True for temporary map
+        :param bool update: True if copy target vector map (poMapInfoNew)
+        exist
 
         :return: number of copied features
         :return: -1 on error
@@ -147,13 +149,23 @@ class IClassVDigit(IVDigit):
         poMapInfoNew = pointer(Map_info())
 
         if not tmp:
-            open_fn = Vect_open_new
+            if update:
+                open_fn = Vect_open_update
+            else:
+                open_fn = Vect_open_new
         else:
-            open_fn = Vect_open_tmp_new
-
-        is3D = bool(Vect_is_3d(self.poMapInfo))
-        if open_fn(poMapInfoNew, name, is3D) == -1:
-            return -1
+            if update:
+                open_fn = Vect_open_tmp_update
+            else:
+                open_fn = Vect_open_tmp_new
+
+        if update:
+            if open_fn(poMapInfoNew, name, '') == -1:
+                return -1
+        else:
+            is3D = bool(Vect_is_3d(self.poMapInfo))
+            if open_fn(poMapInfoNew, name, is3D) == -1:
+                return -1
 
         verbose = G_verbose()
         G_set_verbose(-1)      # be silent

+ 1 - 1
gui/wxpython/iclass/frame.py

@@ -615,7 +615,7 @@ class IClassMapFrame(DoubleMapFrame):
         vname = self._getTempVectorName()
         # avoid deleting temporary map
         os.environ['GRASS_VECTOR_TEMPORARY'] = '1'
-        if digitClass.CopyMap(vname, tmp=True) == -1:
+        if digitClass.CopyMap(vname, tmp=True, update=True) == -1:
             GError(
                 parent=self,
                 message=_("Unable to copy vector features from <%s>") %