diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py index 2d27be14ca..7e1712bc7f 100644 --- a/django/contrib/gis/db/backends/postgis/operations.py +++ b/django/contrib/gis/db/backends/postgis/operations.py @@ -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) diff --git a/django/contrib/gis/db/backends/postgis/pgraster.py b/django/contrib/gis/db/backends/postgis/pgraster.py index 555fc17f1e..ff06f11895 100644 --- a/django/contrib/gis/db/backends/postgis/pgraster.py +++ b/django/contrib/gis/db/backends/postgis/pgraster.py @@ -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. diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py index 9f8c5a1e16..a69c10b6b4 100644 --- a/django/contrib/gis/db/models/fields.py +++ b/django/contrib/gis/db/models/fields.py @@ -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