MCPcopy
hub / github.com/django/django / expand_to_include

Method expand_to_include

django/contrib/gis/gdal/envelope.py:107–153  ·  view source on GitHub ↗

Modify the envelope to expand to include the boundaries of the passed-in 2-tuple (a point), 4-tuple (an extent) or envelope.

(self, *args)

Source from the content-addressed store, hash-verified

105 self._envelope.MaxY = seq[3]
106
107 def expand_to_include(self, *args):
108 """
109 Modify the envelope to expand to include the boundaries of
110 the passed-in 2-tuple (a point), 4-tuple (an extent) or
111 envelope.
112 """
113 # We provide a number of different signatures for this method,
114 # and the logic here is all about converting them into a
115 # 4-tuple single parameter which does the actual work of
116 # expanding the envelope.
117 if len(args) == 1:
118 if isinstance(args[0], Envelope):
119 return self.expand_to_include(args[0].tuple)
120 elif hasattr(args[0], "x") and hasattr(args[0], "y"):
121 return self.expand_to_include(
122 args[0].x, args[0].y, args[0].x, args[0].y
123 )
124 elif isinstance(args[0], (tuple, list)):
125 # A tuple was passed in.
126 if len(args[0]) == 2:
127 return self.expand_to_include(
128 (args[0][0], args[0][1], args[0][0], args[0][1])
129 )
130 elif len(args[0]) == 4:
131 minx, miny, maxx, maxy = args[0]
132 if minx < self._envelope.MinX:
133 self._envelope.MinX = minx
134 if miny < self._envelope.MinY:
135 self._envelope.MinY = miny
136 if maxx > self._envelope.MaxX:
137 self._envelope.MaxX = maxx
138 if maxy > self._envelope.MaxY:
139 self._envelope.MaxY = maxy
140 else:
141 raise GDALException(
142 "Incorrect number of tuple elements (%d)." % len(args[0])
143 )
144 else:
145 raise TypeError("Incorrect type of argument: %s" % type(args[0]))
146 elif len(args) == 2:
147 # An x and an y parameter were passed in
148 return self.expand_to_include((args[0], args[1], args[0], args[1]))
149 elif len(args) == 4:
150 # Individual parameters passed in.
151 return self.expand_to_include(args)
152 else:
153 raise GDALException("Incorrect number (%d) of arguments." % len(args[0]))
154
155 @property
156 def min_x(self):

Calls 1

GDALExceptionClass · 0.90