[GRASS-SVN] r53355 - grass/trunk/lib/python/pygrass/vector

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Oct 10 10:51:48 PDT 2012


Author: mmetz
Date: 2012-10-10 10:51:47 -0700 (Wed, 10 Oct 2012)
New Revision: 53355

Modified:
   grass/trunk/lib/python/pygrass/vector/basic.py
Log:
pygrass questions

Modified: grass/trunk/lib/python/pygrass/vector/basic.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/basic.py	2012-10-10 17:22:53 UTC (rev 53354)
+++ grass/trunk/lib/python/pygrass/vector/basic.py	2012-10-10 17:51:47 UTC (rev 53355)
@@ -10,8 +10,8 @@
 
 
 class Bbox(object):
-    """Instantiate a Bounding Box class that contain
-    a ctypes pointer to the C struct bound_box, that could be use
+    """Instantiate a Bounding Box class that contains
+    a ctypes pointer to the C struct bound_box, that could be used
     by C GRASS functions. ::
 
         >>> bbox = Bbox()
@@ -38,6 +38,7 @@
     """
     def __init__(self, north=0, south=0, east=0, west=0, top=0, bottom=0):
         self.c_bbox = ctypes.pointer(libvect.bound_box())
+	# self.c_bbox.contents.N = north ? etc
         self.north = north
         self.south = south
         self.east = east
@@ -100,7 +101,11 @@
 
 class BoxList(object):
     def __init__(self, boxlist=None):
+	# should this
         self.c_boxlist = ctypes.pointer(libvect.boxlist())
+	# not rather be
+	# self.c_boxlist = libvect.Vect_new_boxlist(1)
+	# ?
         # if set to 0, the list will hold only ids and no boxes
         self.c_boxlist.contents.have_boxes = 1
         if boxlist is not None:
@@ -120,7 +125,7 @@
         return bbox
 
     def __setitem__(self, indx, bbox):
-        self.c_boxlist.cotents.box[indx] = bbox
+        self.c_boxlist.contents.box[indx] = bbox
 
     def __iter__(self):
         return (self.__getitem__(box_id) for box_id in xrange(self.__len__()))
@@ -147,7 +152,9 @@
         ..
         """
         indx = self.__len__()
-        libvect.Vect_boxlist_append(self.c_boxlist, indx, box.c_bbox.contents)
+	# MM: I am not sure about ctypes.byref
+	# Vect_boxlist_append() wants a pointer to the box, not the box itself
+        libvect.Vect_boxlist_append(self.c_boxlist, indx, ctypes.byref(box.c_bbox.contents))
 
 #    def extend(self, boxlist):
 #        """Extend a boxlist with another boxlist or using a list of Bbox, using
@@ -225,7 +232,11 @@
     """Instantiate a list of integer using the C GRASS struct ``ilist``,
     the class contains this struct as ``c_ilist`` attribute. """
     def __init__(self, integer_list=None):
+	# should this
         self.c_ilist = ctypes.pointer(libvect.struct_ilist())
+	# not rather be
+	# self.c_ilist = libvect.Vect_new_list()
+	# ?
         if integer_list is not None:
             self.extend(integer_list)
 
@@ -305,7 +316,11 @@
         if c_cats is not None:
             self.c_cats = c_cats
         else:
+	    # should this
             self.c_cats = ctypes.pointer(libvect.line_cats())
+	    # not rather be
+	    # self.c_cats = libvect.Vect_new_cats_struct()
+	    # ?
             self.get_area_cats()
 
     def get_area_cats(self):
@@ -316,4 +331,4 @@
 
     def reset(self):
         """Reset the C cats struct from previous values."""
-        libvect.Vect_reset_cats(self.c_cats)
\ No newline at end of file
+        libvect.Vect_reset_cats(self.c_cats)



More information about the grass-commit mailing list