def getExtentFromRectifiedDS( ds , eps=1e-6 ):
    """ Calculates the extent tuple of the given gdal.Dataset. The dataset 
    must be rectified, i.e. projected to a recognized CRS, and the geocoding 
    must be encoded by the GDAL's Geo-Transformation matrix.
    
    The ``eps`` parameter is the relative threshold for non-zero values of
    non-diagonal terms of the GDAL's Geo-Transformation matrix.
    """

    size_x = ds.RasterXSize
    size_y = ds.RasterYSize

    x0 , dxx , dxy , y0 , dyx , dyy = ds.GetGeoTransform()

    if ( abs(eps*dxx) < abs(dxy) ) or ( abs(eps*dyy) < abs(dyx) ) :  
        raise RuntimeError( "Rectified datasets with non-orthogonal or"
            " rotated axes are not supported" ) 

    if ( dxx < 0 ) or ( dyy > 0 ) :  
        raise RuntimeError( "Rectified datasets with flipped axes directions"
            " are not supported" ) 

    x1 , y1 = ( x0 + size_x * dxx ) , ( y0 + size_y * dyy )

    return ( x0 , y1 , x1 , y0 )