Переглянути джерело

grass.script doxygen updated (db, raster, vector)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@37498 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 16 роки тому
батько
коміт
068e65065a
4 змінених файлів з 91 додано та 7 видалено
  1. 17 2
      lib/python/db.py
  2. 44 0
      lib/python/grasspythonlib.dox
  3. 12 2
      lib/python/raster.py
  4. 18 3
      lib/python/vector.py

+ 17 - 2
lib/python/db.py

@@ -28,7 +28,15 @@ from core import *
 
 
 def db_describe(table, **args):
 def db_describe(table, **args):
     """Return the list of columns for a database table
     """Return the list of columns for a database table
-    (interface to `db.describe -c').
+    (interface to `db.describe -c'). Example:
+
+    \code
+    >>> grass.db_describe('lakes')
+    {'nrows': 15279, 'cols': [['cat', 'INTEGER', '11'], ['AREA', 'DOUBLE PRECISION', '20'],
+    ['PERIMETER', 'DOUBLE PRECISION', '20'], ['FULL_HYDRO', 'DOUBLE PRECISION', '20'],
+    ['FULL_HYDR2', 'DOUBLE PRECISION', '20'], ['FTYPE', 'CHARACTER', '24'],
+    ['FCODE', 'INTEGER', '11'], ['NAME', 'CHARACTER', '99']], 'ncols': 8}
+    \endcode
 
 
     @param table table name
     @param table table name
     @param args
     @param args
@@ -58,7 +66,14 @@ def db_describe(table, **args):
 
 
 def db_connection():
 def db_connection():
     """Return the current database connection parameters
     """Return the current database connection parameters
-    (interface to `db.connect -p').
+    (interface to `db.connect -p'). Example:
+
+    \code
+    >>> grass.db_connection()
+    {'group': 'x', 'schema': '', 'driver': 'dbf', 'database': '$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'}
+    \endcode
+
+    @return parsed output of db.connect
     """
     """
     s = read_command('db.connect', flags = 'p')
     s = read_command('db.connect', flags = 'p')
     return parse_key_val(s, sep = ':')
     return parse_key_val(s, sep = ':')

+ 44 - 0
lib/python/grasspythonlib.dox

@@ -189,5 +189,49 @@ Returns the name of a temporary file, created with g.tempfile.
 
 
  - float_or_dms()
  - float_or_dms()
 
 
+\section db Database
+
+Interface for <tt>db.*</tt> modules.
+
+\code
+from grass.script import db as grass
+\endcode
+
+ - db_connection()
+
+ - db_describe()
+
+\section raster Raster
+
+Interface for <tt>r.*</tt> modules.
+
+\code
+from grass.script import raster as grass
+\endcode
+
+ - raster_history()
+
+ - raster_info()
+
+ - mapcalc()
+
+\section vector Vector
+
+Interface for <tt>v.*</tt> modules.
+
+\code
+from grass.script import vector as grass
+\endcode
+
+ - vector_columns()
+
+ - vector_db()
+
+ - vector_history()
+
+ - vector_info_topo()
+
+ - vector_layer_db()
+
 */
 */
 
 

+ 12 - 2
lib/python/raster.py

@@ -51,11 +51,21 @@ def raster_history(map):
 # run "r.info -rgstmpud ..." and parse output
 # run "r.info -rgstmpud ..." and parse output
 
 
 def raster_info(map):
 def raster_info(map):
-    """Return information about a raster map (interface to `r.info').
+    """Return information about a raster map (interface to
+    `r.info'). Example:
+
+    \code
+    >>> grass.raster_info('elevation')
+    {'north': 228500.0, 'timestamp': '"none"', 'min': 55.578792572021499,
+    'datatype': 'FCELL', 'max': 156.32986450195301, 'ewres': 10.0,
+    'vertical_datum': '', 'west': 630000.0, 'units': '',
+    'title': 'South-West Wake county: Elevation NED 10m (elev_ned10m)',
+    'east': 645000.0, 'nsres': 10.0, 'south': 215000.0}
+    \endcode
 
 
     @param map map name
     @param map map name
     
     
-    @return parsed modile output
+    @return parsed raster info
     """
     """
     s = read_command('r.info', flags = 'rgstmpud', map = map)
     s = read_command('r.info', flags = 'rgstmpud', map = map)
     kv = parse_key_val(s)
     kv = parse_key_val(s)

+ 18 - 3
lib/python/vector.py

@@ -32,7 +32,14 @@ from core import *
 
 
 def vector_db(map, **args):
 def vector_db(map, **args):
     """Return the database connection details for a vector map
     """Return the database connection details for a vector map
-    (interface to `v.db.connect -g').
+    (interface to `v.db.connect -g'). Example:
+    
+    \code
+    >>> grass.vector_db('lakes')
+    {1: {'layer': '1', 'name': '',
+    'database': '/home/martin/grassdata/nc_spm_08/PERMANENT/dbf/',
+    'driver': 'dbf', 'key': 'cat', 'table': 'lakes'}}
+    \endcode
 
 
     @param map vector map
     @param map vector map
     @param args
     @param args
@@ -117,8 +124,16 @@ def vector_history(map):
 # run "v.info -t" and parse output
 # run "v.info -t" and parse output
 
 
 def vector_info_topo(map):
 def vector_info_topo(map):
-    """Return information about a vector map (interface to `v.info -t').
-
+    """Return information about a vector map (interface to `v.info
+    -t'). Example:
+
+    \code
+    >>> grass.vector_info_topo('lakes')
+    {'kernels': 0, 'lines': 0, 'centroids': 15279,
+    'boundaries': 27764, 'points': 0, 'faces': 0,
+    'primitives': 43043, 'islands': 7470, 'nodes': 35234, 'map3d': 0, 'areas': 15279}
+    \endcode
+    
     @param map map name
     @param map map name
 
 
     @return parsed output
     @return parsed output