1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Simplified Transform GIS function by setting output_field.

This commit is contained in:
Sergey Fedoseev 2016-12-08 20:48:26 +06:00 committed by Simon Charette
parent 413216fb9f
commit 82fd779af5

View File

@ -425,6 +425,8 @@ class Transform(GeoFunc):
expression,
self._handle_param(srid, 'srid', six.integer_types),
]
if 'output_field' not in extra:
extra['output_field'] = GeometryField(srid=srid)
super(Transform, self).__init__(*expressions, **extra)
@property
@ -432,13 +434,6 @@ class Transform(GeoFunc):
# Make srid the resulting srid of the transformation
return self.source_expressions[self.geom_param_pos + 1].value
def convert_value(self, value, expression, connection, context):
value = super(Transform, self).convert_value(value, expression, connection, context)
if not connection.ops.postgis and not value.srid:
# Some backends do not set the srid on the returning geometry
value.srid = self.srid
return value
class Translate(Scale):
def as_sqlite(self, compiler, connection):