[GRASS-SVN] r35523 - grass/trunk/swig/python/examples

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jan 20 16:10:55 EST 2009


Author: neteler
Date: 2009-01-20 16:10:55 -0500 (Tue, 20 Jan 2009)
New Revision: 35523

Modified:
   grass/trunk/swig/python/examples/vectoraccess.py
Log:
updated to current API

Modified: grass/trunk/swig/python/examples/vectoraccess.py
===================================================================
--- grass/trunk/swig/python/examples/vectoraccess.py	2009-01-20 20:52:54 UTC (rev 35522)
+++ grass/trunk/swig/python/examples/vectoraccess.py	2009-01-20 21:10:55 UTC (rev 35523)
@@ -3,7 +3,8 @@
 # run within GRASS Spearfish session
 
 import os, sys
-import python_grass7 as g7lib
+import swig.grass as grasslib
+import swig.vector as grassvect
 
 if not os.environ.has_key("GISBASE"):
     print "You must be in GRASS GIS to run this program."
@@ -17,31 +18,32 @@
 mapset = 'PERMANENT'
 
 # initialize
-g7lib.G_gisinit('')
+grasslib.G_gisinit('')
 
 # define map structure
-map = g7lib.Map_info()
+map = grassvect.Map_info()
 
 # define open level (level 2: topology)
-g7lib.Vect_set_open_level (2)
+grassvect.Vect_set_open_level (2)
 
 # open existing map
-g7lib.Vect_open_old(map, input, mapset)
+grassvect.Vect_open_old(map, input, mapset)
 
 # query
 print 'Vect map: ', input
-print 'Vect is 3D: ', g7lib.Vect_is_3d (map)
-print 'Vect DB links: ', g7lib.Vect_get_num_dblinks(map)
-print 'Map Scale:  1:', g7lib.Vect_get_scale(map)
+print 'Vect is 3D: ', grassvect.Vect_is_3d (map)
+print 'Vect DB links: ', grassvect.Vect_get_num_dblinks(map)
+print 'Map Scale:  1:', grassvect.Vect_get_scale(map)
 # misleading:
-# print 'Number of lines:', g7lib.Vect_get_num_lines(map)
-print 'Number of points: ', g7lib.Vect_get_num_primitives(map,g7lib.GV_POINT)
+# print 'Number of lines:', grassvect.Vect_get_num_lines(map)
+# how to access GV_POINT?
+# print 'Number of points: ', grassvect.Vect_get_num_primitives(map,GV_POINT)
 # confusing:
-#print 'Number of lines: ', g7lib.Vect_get_num_primitives(map,g7lib.GV_LINE)
-#print 'Number of areas:', g7lib.Vect_get_num_primitives(map,g7lib.GV_AREA)
-print 'Number of areas:', g7lib.Vect_get_num_areas(map)
+#print 'Number of lines: ', Vect_get_num_primitives(map,GV_LINE)
+#print 'Number of areas:', Vect_get_num_primitives(map,GV_AREA)
+print 'Number of areas:', grassvect.Vect_get_num_areas(map)
 
 # close map
-g7lib.Vect_close(map)
+grassvect.Vect_close(map)
 ## end of the python script
 



More information about the grass-commit mailing list