Forráskód Böngészése

pythonlib/vector: add option to query different topology types (related to https://trac.osgeo.org/grass/changeset/52425)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@52478 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 12 éve
szülő
commit
0176d44f2e
1 módosított fájl, 12 hozzáadás és 7 törlés
  1. 12 7
      lib/python/vector.py

+ 12 - 7
lib/python/vector.py

@@ -269,7 +269,7 @@ def vector_db_select(map, layer = 1, **kwargs):
              'values' : values }
 
 # interface to v.what
-def vector_what(map, coord, distance = 0.0):
+def vector_what(map, coord, distance = 0.0, ttype = None):
     """!Query vector map at given locations
     
     To query one vector map at one location
@@ -306,6 +306,7 @@ def vector_what(map, coord, distance = 0.0):
     @param map vector map(s) to query given as string or list/tuple
     @param coord coordinates of query given as tuple (easting, northing) or list of tuples
     @param distance query threshold distance (in map units)
+    @param ttype list of topology types (default of v.what are point, line, area, face)
 
     @return parsed list
     """
@@ -327,13 +328,17 @@ def vector_what(map, coord, distance = 0.0):
         for e, n in coord:
             coord_list.append('%f,%f' % (e, n))
     
+    cmdParams = dict(quiet      = True,
+                     flags      = 'ag',
+                     map        = ','.join(map_list),
+                     layer      = ','.join(layer_list),
+                     coordinates = ','.join(coord_list),
+                     distance   = float(distance))
+    if ttype:
+        cmdParams['type'] = ','.join(ttype)
+
     ret = read_command('v.what',
-                       quiet      = True,
-                       flags      = 'ag',
-                       map        = ','.join(map_list),
-                       layer      = ','.join(layer_list),
-                       coordinates = ','.join(coord_list),
-                       distance   = float(distance))
+                       **cmdParams)
     
     if "LC_ALL" in os.environ:
         os.environ["LC_ALL"] = locale