فهرست منبع

wxGUI/query: report also 'nothing found'

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54982 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 12 سال پیش
والد
کامیت
43c0a8170e
3فایلهای تغییر یافته به همراه21 افزوده شده و 10 حذف شده
  1. 13 5
      gui/wxpython/gui_core/query.py
  2. 2 1
      gui/wxpython/mapdisp/frame.py
  3. 6 4
      lib/python/script/vector.py

+ 13 - 5
gui/wxpython/gui_core/query.py

@@ -35,7 +35,7 @@ class QueryDialog(wx.Dialog):
         self.tree.AddColumn("Feature")
         self.tree.AddColumn("Feature")
         self.tree.AddColumn("Value")
         self.tree.AddColumn("Value")
         self.tree.SetMainColumn(0)
         self.tree.SetMainColumn(0)
-        self.tree.SetColumnWidth(0, 180)
+        self.tree.SetColumnWidth(0, 220)
         self.tree.SetColumnWidth(1, 400)
         self.tree.SetColumnWidth(1, 400)
 
 
         self.mainSizer.Add(item = self.tree, proportion = 1, flag = wx.EXPAND | wx.ALL, border = 5)
         self.mainSizer.Add(item = self.tree, proportion = 1, flag = wx.EXPAND | wx.ALL, border = 5)
@@ -62,9 +62,16 @@ class QueryDialog(wx.Dialog):
         # TODO: move elsewhere
         # TODO: move elsewhere
         for part in self.data:
         for part in self.data:
             if 'Map' in part:
             if 'Map' in part:
-                item = self.tree.AppendItem(self.root, text = part['Map'])
+                itemText = part['Map']
+                if 'Mapset' in part:
+                    itemText += '@' + part['Mapset']
+                    del part['Mapset']
+                item = self.tree.AppendItem(self.root, text = itemText)
                 del part['Map']
                 del part['Map']
-                self._addItem(item, part)
+                if part:
+                    self._addItem(item, part)
+                else:
+                    self.tree.AppendItem(item, text = _("Nothing found"))
             else:
             else:
                 self._addItem(self.root, part)
                 self._addItem(self.root, part)
         self.tree.UnselectAll()
         self.tree.UnselectAll()
@@ -115,8 +122,9 @@ def test():
     testdata1 = grast.raster_what(map = ('elevation_shade@PERMANENT','landclass96'),
     testdata1 = grast.raster_what(map = ('elevation_shade@PERMANENT','landclass96'),
                                   coord = [(638509.051416,224742.348346)])
                                   coord = [(638509.051416,224742.348346)])
 
 
-    testdata2 = gvect.vector_what(map=('firestations','firestations'),
-                                 coord=(633177.897487,221352.921257), distance=10)
+    testdata2 = gvect.vector_what(map=('firestations','bridges'),
+                                  coord=(633177.897487,221352.921257), distance=10)
+    
     testdata = testdata1 + testdata2
     testdata = testdata1 + testdata2
     frame = QueryDialog(parent = None, data = testdata)
     frame = QueryDialog(parent = None, data = testdata)
     frame.ShowModal()
     frame.ShowModal()

+ 2 - 1
gui/wxpython/mapdisp/frame.py

@@ -726,7 +726,8 @@ class MapFrame(SingleMapFrame):
         if vect:
         if vect:
             vectQuery = grass.vector_what(map=vect, coord=(east, north), distance=qdist)
             vectQuery = grass.vector_what(map=vect, coord=(east, north), distance=qdist)
         self._QueryMapDone()
         self._QueryMapDone()
-        self._queryHighlight(vectQuery)
+        if 'Id' in vectQuery:
+            self._queryHighlight(vectQuery)
 
 
         result = rastQuery + vectQuery
         result = rastQuery + vectQuery
         if self.dialogs['query']:
         if self.dialogs['query']:

+ 6 - 4
lib/python/script/vector.py

@@ -371,9 +371,10 @@ def vector_what(map, coord, distance = 0.0, ttype = None):
         
         
         if key == 'Map':
         if key == 'Map':
             # attach the last one from the previous map
             # attach the last one from the previous map
-            if dict_layer is not None:
+            if dict_map is not None:
                 dict_main = copy.copy(dict_map)
                 dict_main = copy.copy(dict_map)
-                dict_main.update(dict_layer)
+                if dict_layer is not None:
+                    dict_main.update(dict_layer)
                 data.append(dict_main)
                 data.append(dict_main)
             dict_map  = { key : value }
             dict_map  = { key : value }
             dict_layer = None
             dict_layer = None
@@ -403,9 +404,10 @@ def vector_what(map, coord, distance = 0.0, ttype = None):
             # examples: Sq_Meters, Hectares, Acres, Sq_Miles
             # examples: Sq_Meters, Hectares, Acres, Sq_Miles
     
     
     # attach the last one
     # attach the last one
-    if dict_layer is not None:
+    if dict_map is not None:
         dict_main = copy.copy(dict_map)
         dict_main = copy.copy(dict_map)
-        dict_main.update(dict_layer)
+        if dict_layer:
+            dict_main.update(dict_layer)
         data.append(dict_main)
         data.append(dict_main)
     
     
     return data
     return data