MCPcopy
hub / github.com/django/django / __init__

Method __init__

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

The initialization function may take an OGREnvelope structure, 4-element tuple or list, or 4 individual arguments.

(self, *args)

Source from the content-addressed store, hash-verified

38 """
39
40 def __init__(self, *args):
41 """
42 The initialization function may take an OGREnvelope structure,
43 4-element tuple or list, or 4 individual arguments.
44 """
45
46 if len(args) == 1:
47 if isinstance(args[0], OGREnvelope):
48 # OGREnvelope (a ctypes Structure) was passed in.
49 self._envelope = args[0]
50 elif isinstance(args[0], (tuple, list)):
51 # A tuple was passed in.
52 if len(args[0]) != 4:
53 raise GDALException(
54 "Incorrect number of tuple elements (%d)." % len(args[0])
55 )
56 else:
57 self._from_sequence(args[0])
58 else:
59 raise TypeError("Incorrect type of argument: %s" % type(args[0]))
60 elif len(args) == 4:
61 # Individual parameters passed in.
62 # Thanks to ww for the help
63 self._from_sequence([float(a) for a in args])
64 else:
65 raise GDALException("Incorrect number (%d) of arguments." % len(args))
66
67 # Checking the x,y coordinates
68 if self.min_x > self.max_x:
69 raise GDALException("Envelope minimum X > maximum X.")
70 if self.min_y > self.max_y:
71 raise GDALException("Envelope minimum Y > maximum Y.")
72
73 def __eq__(self, other):
74 """

Callers

nothing calls this directly

Calls 2

_from_sequenceMethod · 0.95
GDALExceptionClass · 0.90

Tested by

no test coverage detected