MCPcopy
hub / github.com/django/django / _create_polygon

Method _create_polygon

django/contrib/gis/geos/polygon.py:70–93  ·  view source on GitHub ↗
(self, length, items)

Source from the content-addressed store, hash-verified

68
69 # ### These routines are needed for list-like operation w/ListMixin ###
70 def _create_polygon(self, length, items):
71 # Instantiate LinearRing objects if necessary, but don't clone them yet
72 # _construct_ring will throw a TypeError if a parameter isn't a valid
73 # ring If we cloned the pointers here, we wouldn't be able to clean up
74 # in case of error.
75 if not length:
76 return capi.create_empty_polygon()
77
78 rings = []
79 for r in items:
80 if isinstance(r, GEOM_PTR):
81 rings.append(r)
82 else:
83 rings.append(self._construct_ring(r))
84
85 shell = self._clone(rings.pop(0))
86
87 n_holes = length - 1
88 if n_holes:
89 holes_param = (GEOM_PTR * n_holes)(*[self._clone(r) for r in rings])
90 else:
91 holes_param = None
92
93 return capi.create_polygon(shell, holes_param, n_holes)
94
95 def _clone(self, g):
96 if isinstance(g, GEOM_PTR):

Callers 2

__init__Method · 0.95
_set_listMethod · 0.95

Calls 4

_construct_ringMethod · 0.95
_cloneMethod · 0.95
appendMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected