[GRASS-SVN] r30228 - in grass/trunk/gui/wxpython: gui_modules vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Feb 18 07:04:58 EST 2008
Author: martinl
Date: 2008-02-18 07:04:57 -0500 (Mon, 18 Feb 2008)
New Revision: 30228
Modified:
grass/trunk/gui/wxpython/gui_modules/digit.py
grass/trunk/gui/wxpython/vdigit/cats.cpp
Log:
wxGUI/vdigit: Copy objects from background vector map enabled also for vdigit component (already functional in vedit)
Modified: grass/trunk/gui/wxpython/gui_modules/digit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/digit.py 2008-02-18 10:12:35 UTC (rev 30227)
+++ grass/trunk/gui/wxpython/gui_modules/digit.py 2008-02-18 12:04:57 UTC (rev 30228)
@@ -232,6 +232,39 @@
return type
+ def SelectLinesFromBackgroundMap(self, pos1, pos2):
+ """Select features from background map
+
+ @param pos1,pos2 bounding box defifinition
+ """
+
+ if self.settings['backgroundMap'] == '':
+ Debug.msg(4, "VEdit.SelectLinesFromBackgroundMap(): []")
+ return []
+
+ x1, y1 = pos1
+ x2, y2 = pos2
+
+ vEditCmd = gcmd.Command(['v.edit',
+ '--q',
+ 'map=%s' % self.settings['backgroundMap'],
+ 'tool=select',
+ 'bbox=%f,%f,%f,%f' % (pos1[0], pos1[1], pos2[0], pos2[1])])
+ #'polygon=%f,%f,%f,%f,%f,%f,%f,%f,%f,%f' % \
+ # (x1, y1, x2, y1, x2, y2, x1, y2, x1, y1)])
+
+ try:
+ output = vEditCmd.ReadStdOutput()[0] # first line
+ ids = output.split(',')
+ ids = map(int, ids) # str -> int
+ except:
+ return []
+
+ Debug.msg(4, "VEdit.SelectLinesFromBackgroundMap(): %s" % \
+ ",".join(["%d" % v for v in ids]))
+
+ return ids
+
class VEdit(AbstractDigit):
"""
Prototype of digitization class based on v.edit command
@@ -688,39 +721,6 @@
return True
- def SelectLinesFromBackgroundMap(self, pos1, pos2):
- """Select features from background map
-
- @param pos1,pos2 bounding box defifinition
- """
-
- if self.settings['backgroundMap'] == '':
- Debug.msg(4, "VEdit.SelectLinesFromBackgroundMap(): []")
- return []
-
- x1, y1 = pos1
- x2, y2 = pos2
-
- vEditCmd = gcmd.Command(['v.edit',
- '--q',
- 'map=%s' % self.settings['backgroundMap'],
- 'tool=select',
- 'bbox=%f,%f,%f,%f' % (pos1[0], pos1[1], pos2[0], pos2[1])])
- #'polygon=%f,%f,%f,%f,%f,%f,%f,%f,%f,%f' % \
- # (x1, y1, x2, y1, x2, y2, x1, y2, x1, y1)])
-
- try:
- output = vEditCmd.ReadStdOutput()[0] # first line
- ids = output.split(',')
- ids = map(int, ids) # str -> int
- except:
- return []
-
- Debug.msg(4, "VEdit.SelectLinesFromBackgroundMap(): %s" % \
- ",".join(["%d" % v for v in ids]))
-
- return ids
-
def SelectLinesByQuery(self, pos1, pos2):
"""Select features by query
@@ -770,9 +770,9 @@
def GetLayers(self):
"""Return list of layers"""
layerCommand = gcmd.Command(cmd=["v.db.connect",
- "-g", "--q",
- "map=%s" % self.map],
- rerr=None, stderr=None)
+ "-g", "--q",
+ "map=%s" % self.map],
+ rerr=None, stderr=None)
if layerCommand.returncode == 0:
layers = []
for line in layerCommand.ReadStdOutput():
@@ -780,7 +780,7 @@
layers.append(int(lineList[0]))
return layers
- return [1]
+ return [1,]
class VDigit(AbstractDigit):
"""
@@ -972,7 +972,7 @@
@param ids list of line ids to be copied
"""
- return self.digit.CopyLines(ids, self.settings['backgroundMap'])
+ return self.digit.CopyLines(ids, str(self.settings['backgroundMap']))
def CopyCats(self, cats, ids):
"""Copy given categories to objects with id listed in ids
Modified: grass/trunk/gui/wxpython/vdigit/cats.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/cats.cpp 2008-02-18 10:12:35 UTC (rev 30227)
+++ grass/trunk/gui/wxpython/vdigit/cats.cpp 2008-02-18 12:04:57 UTC (rev 30228)
@@ -54,6 +54,9 @@
for (int i = 0; i < nfields; i++ ) {
field = Vect_cidx_get_field_number(display->mapInfo, i);
ncats = Vect_cidx_get_num_cats_by_index(display->mapInfo, i);
+ if (field <= 0) {
+ continue;
+ }
for (int j = 0; j < ncats; j++) {
Vect_cidx_get_cat_by_index (display->mapInfo, i, j, &cat, &type, &id);
if (cat > cats[field])
More information about the grass-commit
mailing list