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

Method __init__

django/contrib/gis/db/models/functions.py:30–57  ·  view source on GitHub ↗
(self, *expressions, **extra)

Source from the content-addressed store, hash-verified

28 geom_param_pos = (0,)
29
30 def __init__(self, *expressions, **extra):
31 super().__init__(*expressions, **extra)
32
33 # Ensure that value expressions are geometric.
34 for pos in self.geom_param_pos:
35 expr = self.source_expressions[pos]
36 if not isinstance(expr, Value):
37 continue
38 try:
39 output_field = expr.output_field
40 except FieldError:
41 output_field = None
42 geom = expr.value
43 if (
44 not isinstance(geom, GEOSGeometry)
45 or output_field
46 and not isinstance(output_field, GeometryField)
47 ):
48 raise TypeError(
49 "%s function requires a geometric argument in position %d."
50 % (self.name, pos + 1)
51 )
52 if not geom.srid and not output_field:
53 raise ValueError("SRID is required for all geometries.")
54 if not output_field:
55 self.source_expressions[pos] = Value(
56 geom, output_field=GeometryField(srid=geom.srid)
57 )
58
59 @property
60 def name(self):

Callers

nothing calls this directly

Calls 3

ValueClass · 0.90
GeometryFieldClass · 0.90
__init__Method · 0.45

Tested by

no test coverage detected