Skip to content

Commit

Permalink
wxGUI/g.gui.iclass: fix copy vector features from vector map (#1020)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmszi authored and neteler committed Oct 22, 2020
1 parent 41f914a commit e3d041f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
26 changes: 19 additions & 7 deletions gui/wxpython/iclass/digit.py
Expand Up @@ -129,13 +129,15 @@ def DeleteAreasByCat(self, cats):
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
Expand All @@ -147,13 +149,23 @@ def CopyMap(self, name, tmp=False):
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
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/iclass/frame.py
Expand Up @@ -615,7 +615,7 @@ def ImportAreas(self, vector):
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>") %
Expand Down

0 comments on commit e3d041f

Please sign in to comment.