Gave unique names to SpatialRefSysModels.
Prevented clashes in the app registry. Fixed #22790. Thanks timo for the report.
This commit is contained in:
parent
d8f6b55aa8
commit
6e5651e514
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
Base/mixin classes for the spatial backend database operations and the
|
Base/mixin classes for the spatial backend database operations and the
|
||||||
`SpatialRefSys` model the backend.
|
`<Backend>SpatialRefSys` model.
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ from django.utils.encoding import python_2_unicode_compatible
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class GeometryColumns(models.Model):
|
class OracleGeometryColumns(models.Model):
|
||||||
"Maps to the Oracle USER_SDO_GEOM_METADATA table."
|
"Maps to the Oracle USER_SDO_GEOM_METADATA table."
|
||||||
table_name = models.CharField(max_length=32)
|
table_name = models.CharField(max_length=32)
|
||||||
column_name = models.CharField(max_length=1024)
|
column_name = models.CharField(max_length=1024)
|
||||||
|
@ -21,6 +21,7 @@ class GeometryColumns(models.Model):
|
||||||
# TODO: Add support for `diminfo` column (type MDSYS.SDO_DIM_ARRAY).
|
# TODO: Add support for `diminfo` column (type MDSYS.SDO_DIM_ARRAY).
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
app_label = 'gis'
|
||||||
db_table = 'USER_SDO_GEOM_METADATA'
|
db_table = 'USER_SDO_GEOM_METADATA'
|
||||||
managed = False
|
managed = False
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ class GeometryColumns(models.Model):
|
||||||
return '%s - %s (SRID: %s)' % (self.table_name, self.column_name, self.srid)
|
return '%s - %s (SRID: %s)' % (self.table_name, self.column_name, self.srid)
|
||||||
|
|
||||||
|
|
||||||
class SpatialRefSys(models.Model, SpatialRefSysMixin):
|
class OracleSpatialRefSys(models.Model, SpatialRefSysMixin):
|
||||||
"Maps to the Oracle MDSYS.CS_SRS table."
|
"Maps to the Oracle MDSYS.CS_SRS table."
|
||||||
cs_name = models.CharField(max_length=68)
|
cs_name = models.CharField(max_length=68)
|
||||||
srid = models.IntegerField(primary_key=True)
|
srid = models.IntegerField(primary_key=True)
|
||||||
|
@ -57,6 +58,7 @@ class SpatialRefSys(models.Model, SpatialRefSysMixin):
|
||||||
objects = models.GeoManager()
|
objects = models.GeoManager()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
app_label = 'gis'
|
||||||
db_table = 'CS_SRS'
|
db_table = 'CS_SRS'
|
||||||
managed = False
|
managed = False
|
||||||
|
|
||||||
|
|
|
@ -289,12 +289,12 @@ class OracleOperations(DatabaseOperations, BaseSpatialOperations):
|
||||||
|
|
||||||
# Routines for getting the OGC-compliant models.
|
# Routines for getting the OGC-compliant models.
|
||||||
def geometry_columns(self):
|
def geometry_columns(self):
|
||||||
from django.contrib.gis.db.backends.oracle.models import GeometryColumns
|
from django.contrib.gis.db.backends.oracle.models import OracleGeometryColumns
|
||||||
return GeometryColumns
|
return OracleGeometryColumns
|
||||||
|
|
||||||
def spatial_ref_sys(self):
|
def spatial_ref_sys(self):
|
||||||
from django.contrib.gis.db.backends.oracle.models import SpatialRefSys
|
from django.contrib.gis.db.backends.oracle.models import OracleSpatialRefSys
|
||||||
return SpatialRefSys
|
return OracleSpatialRefSys
|
||||||
|
|
||||||
def modify_insert_params(self, placeholders, params):
|
def modify_insert_params(self, placeholders, params):
|
||||||
"""Drop out insert parameters for NULL placeholder. Needed for Oracle Spatial
|
"""Drop out insert parameters for NULL placeholder. Needed for Oracle Spatial
|
||||||
|
|
|
@ -7,7 +7,7 @@ from django.utils.encoding import python_2_unicode_compatible
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class GeometryColumns(models.Model):
|
class PostGISGeometryColumns(models.Model):
|
||||||
"""
|
"""
|
||||||
The 'geometry_columns' table from the PostGIS. See the PostGIS
|
The 'geometry_columns' table from the PostGIS. See the PostGIS
|
||||||
documentation at Ch. 4.2.2.
|
documentation at Ch. 4.2.2.
|
||||||
|
@ -47,7 +47,7 @@ class GeometryColumns(models.Model):
|
||||||
self.coord_dimension, self.type, self.srid)
|
self.coord_dimension, self.type, self.srid)
|
||||||
|
|
||||||
|
|
||||||
class SpatialRefSys(models.Model, SpatialRefSysMixin):
|
class PostGISSpatialRefSys(models.Model, SpatialRefSysMixin):
|
||||||
"""
|
"""
|
||||||
The 'spatial_ref_sys' table from PostGIS. See the PostGIS
|
The 'spatial_ref_sys' table from PostGIS. See the PostGIS
|
||||||
documentaiton at Ch. 4.2.1.
|
documentaiton at Ch. 4.2.1.
|
||||||
|
|
|
@ -13,7 +13,7 @@ from django.db.utils import ProgrammingError
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
|
|
||||||
from .models import GeometryColumns, SpatialRefSys
|
from .models import PostGISGeometryColumns, PostGISSpatialRefSys
|
||||||
|
|
||||||
|
|
||||||
#### Classes used in constructing PostGIS spatial SQL ####
|
#### Classes used in constructing PostGIS spatial SQL ####
|
||||||
|
@ -571,7 +571,7 @@ class PostGISOperations(DatabaseOperations, BaseSpatialOperations):
|
||||||
|
|
||||||
# Routines for getting the OGC-compliant models.
|
# Routines for getting the OGC-compliant models.
|
||||||
def geometry_columns(self):
|
def geometry_columns(self):
|
||||||
return GeometryColumns
|
return PostGISGeometryColumns
|
||||||
|
|
||||||
def spatial_ref_sys(self):
|
def spatial_ref_sys(self):
|
||||||
return SpatialRefSys
|
return PostGISSpatialRefSys
|
||||||
|
|
|
@ -7,7 +7,7 @@ from django.utils.encoding import python_2_unicode_compatible
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class GeometryColumns(models.Model):
|
class SpatialiteGeometryColumns(models.Model):
|
||||||
"""
|
"""
|
||||||
The 'geometry_columns' table from SpatiaLite.
|
The 'geometry_columns' table from SpatiaLite.
|
||||||
"""
|
"""
|
||||||
|
@ -19,6 +19,7 @@ class GeometryColumns(models.Model):
|
||||||
spatial_index_enabled = models.IntegerField()
|
spatial_index_enabled = models.IntegerField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
app_label = 'gis'
|
||||||
db_table = 'geometry_columns'
|
db_table = 'geometry_columns'
|
||||||
managed = False
|
managed = False
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ class GeometryColumns(models.Model):
|
||||||
self.coord_dimension, self.type, self.srid)
|
self.coord_dimension, self.type, self.srid)
|
||||||
|
|
||||||
|
|
||||||
class SpatialRefSys(models.Model, SpatialRefSysMixin):
|
class SpatialiteSpatialRefSys(models.Model, SpatialRefSysMixin):
|
||||||
"""
|
"""
|
||||||
The 'spatial_ref_sys' table from SpatiaLite.
|
The 'spatial_ref_sys' table from SpatiaLite.
|
||||||
"""
|
"""
|
||||||
|
@ -64,5 +65,6 @@ class SpatialRefSys(models.Model, SpatialRefSysMixin):
|
||||||
return SpatialReference(self.proj4text).wkt
|
return SpatialReference(self.proj4text).wkt
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
app_label = 'gis'
|
||||||
db_table = 'spatial_ref_sys'
|
db_table = 'spatial_ref_sys'
|
||||||
managed = False
|
managed = False
|
||||||
|
|
|
@ -372,9 +372,9 @@ class SpatiaLiteOperations(DatabaseOperations, BaseSpatialOperations):
|
||||||
|
|
||||||
# Routines for getting the OGC-compliant models.
|
# Routines for getting the OGC-compliant models.
|
||||||
def geometry_columns(self):
|
def geometry_columns(self):
|
||||||
from django.contrib.gis.db.backends.spatialite.models import GeometryColumns
|
from django.contrib.gis.db.backends.spatialite.models import SpatialiteGeometryColumns
|
||||||
return GeometryColumns
|
return SpatialiteGeometryColumns
|
||||||
|
|
||||||
def spatial_ref_sys(self):
|
def spatial_ref_sys(self):
|
||||||
from django.contrib.gis.db.backends.spatialite.models import SpatialRefSys
|
from django.contrib.gis.db.backends.spatialite.models import SpatialiteSpatialRefSys
|
||||||
return SpatialRefSys
|
return SpatialiteSpatialRefSys
|
||||||
|
|
|
@ -41,11 +41,11 @@ spatialite = _default_db == 'spatialite'
|
||||||
|
|
||||||
HAS_SPATIALREFSYS = True
|
HAS_SPATIALREFSYS = True
|
||||||
if oracle and 'gis' in settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE']:
|
if oracle and 'gis' in settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE']:
|
||||||
from django.contrib.gis.db.backends.oracle.models import SpatialRefSys
|
from django.contrib.gis.db.backends.oracle.models import OracleSpatialRefSys as SpatialRefSys
|
||||||
elif postgis:
|
elif postgis:
|
||||||
from django.contrib.gis.db.backends.postgis.models import SpatialRefSys
|
from django.contrib.gis.db.backends.postgis.models import PostGISSpatialRefSys as SpatialRefSys
|
||||||
elif spatialite:
|
elif spatialite:
|
||||||
from django.contrib.gis.db.backends.spatialite.models import SpatialRefSys
|
from django.contrib.gis.db.backends.spatialite.models import SpatialiteSpatialRefSys as SpatialRefSys
|
||||||
else:
|
else:
|
||||||
HAS_SPATIALREFSYS = False
|
HAS_SPATIALREFSYS = False
|
||||||
SpatialRefSys = None
|
SpatialRefSys = None
|
||||||
|
|
Loading…
Reference in New Issue