[GRASS-SVN] r44819 - grass/trunk/doc/python

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Dec 30 16:13:55 EST 2010


Author: martinl
Date: 2010-12-30 13:13:55 -0800 (Thu, 30 Dec 2010)
New Revision: 44819

Modified:
   grass/trunk/doc/python/vector_example_ctypes.py
Log:
vector ctypes sample script working now


Modified: grass/trunk/doc/python/vector_example_ctypes.py
===================================================================
--- grass/trunk/doc/python/vector_example_ctypes.py	2010-12-30 20:38:27 UTC (rev 44818)
+++ grass/trunk/doc/python/vector_example_ctypes.py	2010-12-30 21:13:55 UTC (rev 44819)
@@ -28,10 +28,8 @@
 G_gisinit('')
 
 # find vector map in the search path
-mapset = G_find_vector2(input, '')
-if mapset:
-    print "Vector map found in mapset <%s>" % mapset
-else:
+mapset = G_find_vector2(input, "")
+if not mapset:
     sys.exit("Vector map <%s> not found" % input)
 
 # define map structure
@@ -41,13 +39,13 @@
 Vect_set_open_level(2)
 
 # open existing vector map
-Vect_open_old(map, input, mapset)
+Vect_open_old(byref(map), input, mapset)
 
 # query
-print 'Vect map: ',      input
-print 'Vect is 3D: ',    Vect_is_3d(map)
-print 'Vect DB links: ', Vect_get_num_dblinks(map)
-print 'Map Scale:  1:',  Vect_get_scale(map)
+print 'Vector map     :', Vect_get_full_name(byref(map))
+print 'Vector is 3D   :', Vect_is_3d(byref(map))
+print 'Vector DB links:', Vect_get_num_dblinks(byref(map))
+print 'Map Scale:  1  :', Vect_get_scale(byref(map))
 
 # vector box tests
 box = bound_box()
@@ -55,18 +53,14 @@
 c_northing  = 4921010.0
 c_easting2  = 4599505.0
 
-Vect_get_map_box(map, box)
-print 'Position 1   in box? ', Vect_point_in_box(c_easting1, c_northing, 0, box)
-print 'Position 2   in box? ', Vect_point_in_box(c_easting2, c_northing, 0, box)
-print 'Feature id 2 in box? ', Vect_get_line_box(map, 2, box)
+Vect_get_map_box(byref(map), byref(box))
+print 'Position 1 in box? ', Vect_point_in_box(c_easting1, c_northing, 0, byref(box))
+print 'Position 2 in box? ', Vect_point_in_box(c_easting2, c_northing, 0, byref(box))
 
-print 'Number of features:', 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: ', grassvect.Vect_get_num_primitives(map,GV_LINE)
-#print 'Number of areas:', grassvect.Vect_get_num_primitives(map,GV_AREA)
-print 'Number of areas:',   Vect_get_num_areas(map)
+print 'Number of features:', Vect_get_num_lines(byref(map))
+print 'Number of points  :', Vect_get_num_primitives(byref(map), GV_POINT)
+print 'Number of lines   :', Vect_get_num_primitives(byref(map), GV_LINE)
+print 'Number of areas   :', Vect_get_num_areas(byref(map))
 
 # close map
-Vect_close(map)
+Vect_close(byref(map))



More information about the grass-commit mailing list