def get_shape_within(self, shp, polys):
"""Find shape in set of shapes which another given shape is within.
Args:
shp (shape): shape object
polys (List[shape]): list of shapes
Returns:
If shape is found in polys which shp is within, return shape.
If not shape is found, return None.
"""
if not hasattr(shp, 'geom_type'):
raise Exception("CoreMSR [get_shape_within] : invalid shp given")
if not isinstance(polys, list):
raise Exception("CoreMSR [get_shape_within] : invalid polys given")
for poly in polys:
tmp_poly = shape(poly)
if shp.within(tmp_poly):
return tmp_poly
print "CoreMSR [get_shape_within] : shp not within any given poly"
return "None"
评论列表
文章目录