当前位置: 首页>>代码示例>>Python>>正文


Python Polygon.area方法代码示例

本文整理汇总了Python中Polygon.Polygon.area方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.area方法的具体用法?Python Polygon.area怎么用?Python Polygon.area使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Polygon.Polygon的用法示例。


在下文中一共展示了Polygon.area方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fetch_grid

# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import area [as 别名]
def fetch_grid((i, j)):
    """on demand generation of empty grid squares."""
    (i, j) = unwrap((i, j))
    if (i, j) not in grid:
        xloc = i * grid_spacing
        yloc = j * grid_spacing
        r = Polygon(
            [
                (xloc, yloc),
                (xloc + grid_spacing, yloc),
                (xloc + grid_spacing, yloc + grid_spacing),
                (xloc, yloc + grid_spacing),
            ]
        )
        p = sample.sample(r)
        t = random.expovariate(r.area())
        grid[i, j] = (p, t, r)
    return grid[(i, j)]
开发者ID:thouis,项目名称:linear-poisson-disk,代码行数:20,代码来源:linear_poisson.py

示例2: __init__

# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import area [as 别名]
class MPolygon:
	"""
	this class will eventually stop the mess with Polygon classes
	
	"""
	def __init__(self, id, points, mode='tuple', data=None):
		from Polygon import Polygon as Poly
		self.poly = Poly()
		
	def __str__(self):
		return '<M;Polygon ('+str(len(self.points))+' points)>'


	def svgPathString(self, useInt=True):
		"""
		returns the path string representation of this polygon
		"""
		ps = ''
		pts = self.points[:]
		if self.closed:
			pts.append(pts[0])
		for pt in pts:
			if pt.deleted: continue #ignore deleted points
			if ps == '': ps = 'M'
			else: ps += 'L'
			if useInt:
				ps += '%d,%d' % (round(pt.x), round(pt.y))
			else:
				ps += '%.3f,%.3f' % (pt.x, pt.y)
		if self.closed: 
			ps += 'Z' # close path
		return ps
		

	def area(self):
		return self.poly.area()
开发者ID:kartograph,项目名称:kartograph.py-old,代码行数:38,代码来源:gisutils.py


注:本文中的Polygon.Polygon.area方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。