Refs #25588 -- Removed obsolete bits of RasterField support.

Unused since bbfad84dd9.
This commit is contained in:
Tim Graham 2017-07-12 15:20:40 -04:00
parent 3b56f2191d
commit f86b6f351d
3 changed files with 2 additions and 33 deletions

View File

@ -15,7 +15,7 @@ from django.utils.version import get_version_tuple
from .adapter import PostGISAdapter
from .models import PostGISGeometryColumns, PostGISSpatialRefSys
from .pgraster import from_pgraster, get_pgraster_srid, to_pgraster
from .pgraster import from_pgraster
# Identifier to mark raster lookups as bilateral.
BILATERAL = 'bilateral'
@ -297,8 +297,6 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
# Get the srid for this object
if value is None:
value_srid = None
elif f.geom_type == 'RASTER' and isinstance(value, str):
value_srid = get_pgraster_srid(value)
else:
value_srid = value.srid
@ -306,8 +304,6 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
# is not equal to the field srid.
if value_srid is None or value_srid == f.srid:
placeholder = '%s'
elif f.geom_type == 'RASTER' and isinstance(value, str):
placeholder = '%s((%%s)::raster, %s)' % (tranform_func, f.srid)
else:
placeholder = '%s(%%s, %s)' % (tranform_func, f.srid)
@ -376,10 +372,6 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
def spatial_ref_sys(self):
return PostGISSpatialRefSys
# Methods to convert between PostGIS rasters and dicts that are
# readable by GDALRaster.
def parse_raster(self, value):
"""Convert a PostGIS HEX String into a dict readable by GDALRaster."""
return from_pgraster(value)
def deconstruct_raster(self, value):
return to_pgraster(value)

View File

@ -30,18 +30,6 @@ def chunk(data, index):
return data[:index], data[index:]
def get_pgraster_srid(data):
"""
Extract the SRID from a PostGIS raster string.
"""
if data is None:
return
# The positional arguments here extract the hex-encoded srid from the
# header of the PostGIS raster string. This can be understood through
# the POSTGIS_HEADER_STRUCTURE constant definition in the const module.
return unpack('i', data[106:114])[0]
def from_pgraster(data):
"""
Convert a PostGIS HEX String into a dictionary.
@ -112,10 +100,6 @@ def to_pgraster(rast):
"""
Convert a GDALRaster into PostGIS Raster format.
"""
# Return if the raster is null
if rast is None or rast == '':
return
# Prepare the raster header data as a tuple. The first two numbers are
# the endianness and the PostGIS Raster Version, both are fixed by
# PostGIS at the moment.

View File

@ -361,13 +361,6 @@ class RasterField(BaseSpatialField):
def from_db_value(self, value, expression, connection, context):
return connection.ops.parse_raster(value)
def get_db_prep_value(self, value, connection, prepared=False):
self._check_connection(connection)
# Prepare raster for writing to database.
if not prepared:
value = connection.ops.deconstruct_raster(value)
return super().get_db_prep_value(value, connection, prepared)
def contribute_to_class(self, cls, name, **kwargs):
super().contribute_to_class(cls, name, **kwargs)
# Setup for lazy-instantiated Raster object. For large querysets, the