def extent(self, srid=None):
        """Returns the GeoQuerySet extent as a 4-tuple.

        The method chaining approach of
        geoqset.objects.transform(srid).extent() returns the extent in the
        original coordinate system, this method allows for transformation.

        Keyword args:
        srid -- EPSG id for for transforming the output geometry.
        """
        if not srid and not connection.ops.spatialite:
            return super(GeoQuerySet, self).extent()
        transform = self._transform(srid)
        # Spatialite extent() is supported post-1.7.
        if connection.ops.spatialite:
            ext = {'extent': 'AsText(%s(%s))' % ('Extent', transform)}
        else:
            ext = {'extent': '%s(%s)' % (connection.ops.extent, transform)}
        # The bare order_by() is needed to remove the default sort field which
        # is not present in this aggregation. Empty querysets will return
        # [None] here.
        extent = (self.extra(select=ext)
                      .values_list('extent', flat=True)
                      .order_by()[0])
        if not extent:
            return ()
        try:
            try:
                # Django<=1.7
                return connection.ops.convert_extent(extent)
            except TypeError:
                # Django 1.8
                return connection.ops.convert_extent(extent, get_srid(self))
        except NotImplementedError:
            return geos.GEOSGeometry(extent, srid).extent
dataset/ETHPy150Open bkg/django-spillway/spillway/query.py/GeoQuerySet.extent/original