當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。