[GRASS-SVN] r66665 - grass/trunk/lib/python/pygrass/vector
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Oct 29 09:49:16 PDT 2015
Author: zarch
Date: 2015-10-29 09:49:16 -0700 (Thu, 29 Oct 2015)
New Revision: 66665
Modified:
grass/trunk/lib/python/pygrass/vector/geometry.py
Log:
pygrass: Verify pp_isle[i] is not a NULL pointer before trying to use it to instantiate line coordinates, get Area cat as an attribute from th centroid
Modified: grass/trunk/lib/python/pygrass/vector/geometry.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/geometry.py 2015-10-29 16:47:03 UTC (rev 66664)
+++ grass/trunk/lib/python/pygrass/vector/geometry.py 2015-10-29 16:49:16 UTC (rev 66665)
@@ -1147,10 +1147,10 @@
dist_x, dist_y, angle,
int(round_), int(caps), tol,
p_bound, pp_isle, n_isles)
- return(Line(c_points=p_bound.contents),
- self[0],
- [Line(c_points=pp_isle[i].contents)
- for i in range(n_isles.contents.value)])
+ boundary = Line(c_points=p_bound.contents)
+ isles = [Line(c_points=pp_isle[i].contents)
+ for i in range(n_isles.contents.value) if pp_isle[i]]
+ return(boundary, self[0], isles)
def reset(self):
"""Reset line, using `Vect_reset_line` C function. ::
@@ -1576,12 +1576,17 @@
super(Area, self).__init__(**kargs)
# set the attributes
- if self.attrs and self.cat:
- self.attrs.cat = self.cat
+ #if self.attrs and self.cat:
+ # self.attrs.cat = self.cat
def __repr__(self):
return "Area(%d)" % self.id if self.id else "Area( )"
+ @property
+ def cat(self):
+ centroid = self.centroid()
+ return centroid.cat if centroid else None
+
@mapinfo_must_be_set
def points(self, line=None):
"""Return a Line object with the outer ring
More information about the grass-commit
mailing list