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


Python Polygon.__init__方法代码示例

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


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

示例1: set

# 需要导入模块: from shapely.geometry import Polygon [as 别名]
# 或者: from shapely.geometry.Polygon import __init__ [as 别名]
  def set(self, center, northern_most_unit_vector_direction, side_length, parent, depth=None):
    # The Hexagon class is a representation of a 2D planar hexagon,
    #  represented in Cartesian coordinates of the center and all vertices.
    #
    # center := an absolute point, as a 2D numpy column vector, representing
    #  the center of hexagon in a Cartesian coordinate system.
    #
    # northern_most_vertex_direction := a free unit vector, as a 2D numpy
    #  column vector, indicating the direction of the northern-most vertex.
    #
    # side_length := a scalar representing the length of any side of the
    #  resulting hexagon.
    self.initialized = True
    if depth is not None:
      self.depth = depth
    self.center = center.copy()
    self.north_unit_dir = northern_most_unit_vector_direction.copy()
    self.side_length = side_length
    scaled_north_dir = side_length * northern_most_unit_vector_direction
    north = scaled_north_dir + self.center

    # From the center point and the north vertex, we can compute the other
    #  vertices of the hexagon. Each vertex, relative to the center, is
    #  simply the previous vector rotated by 60 degrees (pi/3 radians).
    # Perform this rotation five times to calculate the direction of all
    #  six hexagon vertices.
    self.vertex_directions = [scaled_north_dir]
    self.vertices = [north]
    for i in range(5):
      prev_direction = self.vertex_directions[-1]
      rotated_direction = rotate_60 * prev_direction
      self.vertex_directions.append(rotated_direction)

      # Calculate Cartesian coordinates of vertex.
      vertex = rotated_direction + self.center
      self.vertices.append(vertex)

    self.north_dir,\
    self.northeast_dir,\
    self.southeast_dir,\
    self.south_dir,\
    self.southwest_dir,\
    self.northwest_dir = self.vertex_directions

    self.north_vertex,\
    self.northeast_vertex,\
    self.southeast_vertex,\
    self.south_vertex,\
    self.southwest_vertex,\
    self.northwest_vertex = self.vertices
    Polygon.__init__(self, self.vertices)

    # The following member variables correspond to points to neighboring
    #  hexagons related to the topological relationship between this hexagon
    #  and neighboring hexagons.
    self.neighboring_hexagons = [None for i in range(6)]
    self.internal_hexagons = [None for i in range(7)]
    self.parent = parent
开发者ID:koulevprime,项目名称:token_ring,代码行数:60,代码来源:hexagon.py

示例2: __init__

# 需要导入模块: from shapely.geometry import Polygon [as 别名]
# 或者: from shapely.geometry.Polygon import __init__ [as 别名]
  def __init__(self, x, y, width, height, rotation, visible):
    self.x = x
    self.y = y
    self.width = width
    self.height = height
    self.rotation = rotation
    self.visible = visible

    w2 = width / 2.
    h2 = height / 2.
    l = []
    for k in range(4):
      l.append(rotate((mx[k] * w2, my[k] * h2), rotation))

    l = [(a[0] + x, a[1] + y) for a in l]
    Polygon.__init__(self, l)
开发者ID:wilburyang,项目名称:AppADay,代码行数:18,代码来源:objects.py

示例3: __init__

# 需要导入模块: from shapely.geometry import Polygon [as 别名]
# 或者: from shapely.geometry.Polygon import __init__ [as 别名]
 def __init__(self, poly_points):
     Polygon.__init__(self, poly_points)
开发者ID:jerryhan88,项目名称:taxi_projects,代码行数:4,代码来源:geo_functions.py

示例4: __init__

# 需要导入模块: from shapely.geometry import Polygon [as 别名]
# 或者: from shapely.geometry.Polygon import __init__ [as 别名]
 def __init__(self, tid, points):
     Polygon.__init__(self, points)
     self.tid = tid
开发者ID:jerryhan88,项目名称:workspace_SMU,代码行数:5,代码来源:location_check.py

示例5: __init__

# 需要导入模块: from shapely.geometry import Polygon [as 别名]
# 或者: from shapely.geometry.Polygon import __init__ [as 别名]
 def __init__(self, minx, miny, maxx, maxy):
     minx = float(minx)
     miny = float(miny)
     maxx = float(maxx)
     maxy = float(maxy)
     Polygon.__init__(self, [(minx, miny), (minx, maxy), (maxx, maxy), (maxx, miny)])
开发者ID:andytilia,项目名称:txt2shp,代码行数:8,代码来源:txt2shp.py


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