當前位置: 首頁>>代碼示例>>Python>>正文


Python linestring.LinearRing方法代碼示例

本文整理匯總了Python中django.contrib.gis.geos.linestring.LinearRing方法的典型用法代碼示例。如果您正苦於以下問題:Python linestring.LinearRing方法的具體用法?Python linestring.LinearRing怎麽用?Python linestring.LinearRing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.contrib.gis.geos.linestring的用法示例。


在下文中一共展示了linestring.LinearRing方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _create_polygon

# 需要導入模塊: from django.contrib.gis.geos import linestring [as 別名]
# 或者: from django.contrib.gis.geos.linestring import LinearRing [as 別名]
def _create_polygon(self, length, items):
        # Instantiate LinearRing objects if necessary, but don't clone them yet
        # _construct_ring will throw a TypeError if a parameter isn't a valid ring
        # If we cloned the pointers here, we wouldn't be able to clean up
        # in case of error.
        rings = []
        for r in items:
            if isinstance(r, GEOM_PTR):
                rings.append(r)
            else:
                rings.append(self._construct_ring(r))

        shell = self._clone(rings.pop(0))

        n_holes = length - 1
        if n_holes:
            holes = get_pointer_arr(n_holes)
            for i, r in enumerate(rings):
                holes[i] = self._clone(r)
                holes_param = byref(holes)
        else:
            holes_param = None

        return capi.create_polygon(shell, holes_param, c_uint(n_holes)) 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:26,代碼來源:polygon.py

示例2: __init__

# 需要導入模塊: from django.contrib.gis.geos import linestring [as 別名]
# 或者: from django.contrib.gis.geos.linestring import LinearRing [as 別名]
def __init__(self, *args, **kwargs):
        """
        Initializes on an exterior ring and a sequence of holes (both
        instances may be either LinearRing instances, or a tuple/list
        that may be constructed into a LinearRing).

        Examples of initialization, where shell, hole1, and hole2 are
        valid LinearRing geometries:
        >>> from django.contrib.gis.geos import LinearRing, Polygon
        >>> shell = hole1 = hole2 = LinearRing()
        >>> poly = Polygon(shell, hole1, hole2)
        >>> poly = Polygon(shell, (hole1, hole2))

        >>> # Example where a tuple parameters are used:
        >>> poly = Polygon(((0, 0), (0, 10), (10, 10), (0, 10), (0, 0)),
        ...                ((4, 4), (4, 6), (6, 6), (6, 4), (4, 4)))
        """
        if not args:
            raise TypeError('Must provide at least one LinearRing, or a tuple, to initialize a Polygon.')

        # Getting the ext_ring and init_holes parameters from the argument list
        ext_ring = args[0]
        init_holes = args[1:]
        n_holes = len(init_holes)

        # If initialized as Polygon(shell, (LinearRing, LinearRing)) [for backward-compatibility]
        if n_holes == 1 and isinstance(init_holes[0], (tuple, list)):
            if len(init_holes[0]) == 0:
                init_holes = ()
                n_holes = 0
            elif isinstance(init_holes[0][0], LinearRing):
                init_holes = init_holes[0]
                n_holes = len(init_holes)

        polygon = self._create_polygon(n_holes + 1, (ext_ring,) + init_holes)
        super(Polygon, self).__init__(polygon, **kwargs) 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:38,代碼來源:polygon.py

示例3: _construct_ring

# 需要導入模塊: from django.contrib.gis.geos import linestring [as 別名]
# 或者: from django.contrib.gis.geos.linestring import LinearRing [as 別名]
def _construct_ring(self, param, msg=(
            'Parameter must be a sequence of LinearRings or objects that can initialize to LinearRings')):
        "Helper routine for trying to construct a ring from the given parameter."
        if isinstance(param, LinearRing):
            return param
        try:
            ring = LinearRing(param)
            return ring
        except TypeError:
            raise TypeError(msg) 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:12,代碼來源:polygon.py

示例4: __init__

# 需要導入模塊: from django.contrib.gis.geos import linestring [as 別名]
# 或者: from django.contrib.gis.geos.linestring import LinearRing [as 別名]
def __init__(self, *args, **kwargs):
        """
        Initializes on an exterior ring and a sequence of holes (both
        instances may be either LinearRing instances, or a tuple/list
        that may be constructed into a LinearRing).

        Examples of initialization, where shell, hole1, and hole2 are
        valid LinearRing geometries:
        >>> from django.contrib.gis.geos import LinearRing, Polygon
        >>> shell = hole1 = hole2 = LinearRing()
        >>> poly = Polygon(shell, hole1, hole2)
        >>> poly = Polygon(shell, (hole1, hole2))

        >>> # Example where a tuple parameters are used:
        >>> poly = Polygon(((0, 0), (0, 10), (10, 10), (0, 10), (0, 0)),
        ...                ((4, 4), (4, 6), (6, 6), (6, 4), (4, 4)))
        """
        if not args:
            super(Polygon, self).__init__(self._create_polygon(0, None), **kwargs)
            return

        # Getting the ext_ring and init_holes parameters from the argument list
        ext_ring = args[0]
        init_holes = args[1:]
        n_holes = len(init_holes)

        # If initialized as Polygon(shell, (LinearRing, LinearRing)) [for backward-compatibility]
        if n_holes == 1 and isinstance(init_holes[0], (tuple, list)):
            if len(init_holes[0]) == 0:
                init_holes = ()
                n_holes = 0
            elif isinstance(init_holes[0][0], LinearRing):
                init_holes = init_holes[0]
                n_holes = len(init_holes)

        polygon = self._create_polygon(n_holes + 1, (ext_ring,) + init_holes)
        super(Polygon, self).__init__(polygon, **kwargs) 
開發者ID:KimJangHyeon,項目名稱:NarshaTech,代碼行數:39,代碼來源:polygon.py

示例5: _create_polygon

# 需要導入模塊: from django.contrib.gis.geos import linestring [as 別名]
# 或者: from django.contrib.gis.geos.linestring import LinearRing [as 別名]
def _create_polygon(self, length, items):
        # Instantiate LinearRing objects if necessary, but don't clone them yet
        # _construct_ring will throw a TypeError if a parameter isn't a valid ring
        # If we cloned the pointers here, we wouldn't be able to clean up
        # in case of error.
        if not length:
            return capi.create_empty_polygon()

        rings = []
        for r in items:
            if isinstance(r, GEOM_PTR):
                rings.append(r)
            else:
                rings.append(self._construct_ring(r))

        shell = self._clone(rings.pop(0))

        n_holes = length - 1
        if n_holes:
            holes = get_pointer_arr(n_holes)
            for i, r in enumerate(rings):
                holes[i] = self._clone(r)
                holes_param = byref(holes)
        else:
            holes_param = None

        return capi.create_polygon(shell, holes_param, c_uint(n_holes)) 
開發者ID:KimJangHyeon,項目名稱:NarshaTech,代碼行數:29,代碼來源:polygon.py


注:本文中的django.contrib.gis.geos.linestring.LinearRing方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。