Browse Source

updated to current API

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@35523 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 16 years ago
parent
commit
e2e19e40d5
1 changed files with 16 additions and 14 deletions
  1. 16 14
      swig/python/examples/vectoraccess.py

+ 16 - 14
swig/python/examples/vectoraccess.py

@@ -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 @@ else:
 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