Loading django/contrib/gis/db/backends/spatialite/introspection.py +2 −3 Original line number Diff line number Diff line Loading @@ -29,10 +29,9 @@ class SpatiaLiteIntrospection(DatabaseIntrospection): cursor = self.connection.cursor() try: # Querying the `geometry_columns` table to get additional metadata. type_col = 'type' if self.connection.ops.spatial_version < (4, 0, 0) else 'geometry_type' cursor.execute('SELECT coord_dimension, srid, %s ' cursor.execute('SELECT coord_dimension, srid, geometry_type ' 'FROM geometry_columns ' 'WHERE f_table_name=%%s AND f_geometry_column=%%s' % type_col, 'WHERE f_table_name=%s AND f_geometry_column=%s', (table_name, geo_col)) row = cursor.fetchone() if not row: Loading django/contrib/gis/db/backends/spatialite/models.py +3 −18 Original line number Diff line number Diff line Loading @@ -2,9 +2,7 @@ The GeometryColumns and SpatialRefSys models for the SpatiaLite backend. """ from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin from django.contrib.gis.db.backends.spatialite.base import DatabaseWrapper from django.db import connection, models from django.db.backends.signals import connection_created from django.db import models from django.utils.encoding import python_2_unicode_compatible Loading @@ -18,6 +16,7 @@ class SpatialiteGeometryColumns(models.Model): coord_dimension = models.IntegerField() srid = models.IntegerField(primary_key=True) spatial_index_enabled = models.IntegerField() type = models.IntegerField(db_column='geometry_type') class Meta: app_label = 'gis' Loading Loading @@ -55,6 +54,7 @@ class SpatialiteSpatialRefSys(models.Model, SpatialRefSysMixin): auth_srid = models.IntegerField() ref_sys_name = models.CharField(max_length=256) proj4text = models.CharField(max_length=2048) srtext = models.CharField(max_length=2048) @property def wkt(self): Loading @@ -67,18 +67,3 @@ class SpatialiteSpatialRefSys(models.Model, SpatialRefSysMixin): app_label = 'gis' db_table = 'spatial_ref_sys' managed = False def add_spatial_version_related_fields(sender, **kwargs): """ Adds fields after establishing a database connection to prevent database operations at compile time. """ if connection_created.disconnect(add_spatial_version_related_fields, sender=DatabaseWrapper): spatial_version = connection.ops.spatial_version[0] if spatial_version >= 4: SpatialiteSpatialRefSys.add_to_class('srtext', models.CharField(max_length=2048)) SpatialiteGeometryColumns.add_to_class('type', models.IntegerField(db_column='geometry_type')) else: SpatialiteGeometryColumns.add_to_class('type', models.CharField(max_length=30)) connection_created.connect(add_spatial_version_related_fields, sender=DatabaseWrapper) django/contrib/gis/db/backends/spatialite/operations.py +4 −9 Original line number Diff line number Diff line """ SQL functions reference lists: http://www.gaia-gis.it/spatialite-3.0.0-BETA/spatialite-sql-3.0.0.html https://web.archive.org/web/20130407175746/http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.0.0.html http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.2.1.html """ Loading Loading @@ -90,18 +89,14 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations): 'Length': 'ST_Length', 'Reverse': 'ST_Reverse', 'Scale': 'ScaleCoords', 'Translate': 'ST_Translate' if self.spatial_version >= (3, 1, 0) else 'ShiftCoords', 'Translate': 'ST_Translate', 'Union': 'ST_Union', } @cached_property def unsupported_functions(self): unsupported = {'BoundingCircle', 'ForceRHR', 'IsValid', 'MakeValid', 'MemSize'} if self.spatial_version < (3, 1, 0): unsupported.add('SnapToGrid') if self.spatial_version < (4, 0, 0): unsupported.update({'Perimeter', 'Reverse'}) elif not self.lwgeom_version(): if not self.lwgeom_version(): unsupported.add('GeoHash') return unsupported Loading @@ -116,8 +111,8 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations): 'database (error was "%s"). Was the SpatiaLite initialization ' 'SQL loaded on this database?') % (self.connection.settings_dict['NAME'], msg) six.reraise(ImproperlyConfigured, ImproperlyConfigured(new_msg), sys.exc_info()[2]) if version < (3, 0, 0): raise ImproperlyConfigured('GeoDjango only supports SpatiaLite versions 3.0.0 and above.') if version < (4, 0, 0): raise ImproperlyConfigured('GeoDjango only supports SpatiaLite versions 4.0.0 and above.') return version def convert_extent(self, box, srid): Loading docs/ref/contrib/gis/db-api.txt +4 −4 Original line number Diff line number Diff line Loading @@ -388,7 +388,7 @@ Function PostGIS Oracle MySQL SpatiaLite :class:`Distance` X X X (≥ 5.6.1) X :class:`Envelope` X X X :class:`ForceRHR` X :class:`GeoHash` X X (≥ 4.0, LWGEOM) :class:`GeoHash` X X (LWGEOM) :class:`Intersection` X X X (≥ 5.6.1) X :class:`IsValid` X :class:`Length` X X X X Loading @@ -396,11 +396,11 @@ Function PostGIS Oracle MySQL SpatiaLite :class:`MemSize` X :class:`NumGeometries` X X X X :class:`NumPoints` X X X X :class:`Perimeter` X X X (≥ 4.0) :class:`Perimeter` X X X :class:`PointOnSurface` X X X :class:`Reverse` X X X (≥ 4.0) :class:`Reverse` X X X :class:`Scale` X X :class:`SnapToGrid` X X (≥ 3.1) :class:`SnapToGrid` X X :class:`SymDifference` X X X (≥ 5.6.1) X :class:`Transform` X X X :class:`Translate` X X Loading docs/ref/contrib/gis/functions.txt +4 −4 Original line number Diff line number Diff line Loading @@ -263,7 +263,7 @@ right-hand rule. .. class:: GeoHash(expression, **extra) *Availability*: PostGIS, SpatiaLite (≥ 4.0, LWGEOM) *Availability*: PostGIS, SpatiaLite (LWGEOM) Accepts a single geographic field or expression and returns a `GeoHash`__ representation of the geometry. Loading Loading @@ -367,7 +367,7 @@ in the first linestring in the geometry field; otherwise returns ``None``. .. class:: Perimeter(expression, **extra) *Availability*: PostGIS, Oracle, SpatiaLite (≥ 4.0) *Availability*: PostGIS, Oracle, SpatiaLite Accepts a single geographic field or expression and returns the perimeter of the geometry field as a :class:`~django.contrib.gis.measure.Distance` object. On Loading @@ -389,7 +389,7 @@ guaranteed to lie on the surface of the field; otherwise returns ``None``. .. class:: Reverse(expression, **extra) *Availability*: PostGIS, Oracle, SpatiaLite (≥ 4.0) *Availability*: PostGIS, Oracle, SpatiaLite Accepts a single geographic field or expression and returns a geometry with reversed coordinates. Loading @@ -410,7 +410,7 @@ scaled coordinates by multiplying them with the ``x``, ``y``, and optionally .. class:: SnapToGrid(expression, *args, **extra) *Availability*: PostGIS, SpatiaLite (≥ 3.1) *Availability*: PostGIS, SpatiaLite Accepts a single geographic field or expression and returns a geometry with all points snapped to the given grid. How the geometry is snapped to the grid Loading Loading
django/contrib/gis/db/backends/spatialite/introspection.py +2 −3 Original line number Diff line number Diff line Loading @@ -29,10 +29,9 @@ class SpatiaLiteIntrospection(DatabaseIntrospection): cursor = self.connection.cursor() try: # Querying the `geometry_columns` table to get additional metadata. type_col = 'type' if self.connection.ops.spatial_version < (4, 0, 0) else 'geometry_type' cursor.execute('SELECT coord_dimension, srid, %s ' cursor.execute('SELECT coord_dimension, srid, geometry_type ' 'FROM geometry_columns ' 'WHERE f_table_name=%%s AND f_geometry_column=%%s' % type_col, 'WHERE f_table_name=%s AND f_geometry_column=%s', (table_name, geo_col)) row = cursor.fetchone() if not row: Loading
django/contrib/gis/db/backends/spatialite/models.py +3 −18 Original line number Diff line number Diff line Loading @@ -2,9 +2,7 @@ The GeometryColumns and SpatialRefSys models for the SpatiaLite backend. """ from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin from django.contrib.gis.db.backends.spatialite.base import DatabaseWrapper from django.db import connection, models from django.db.backends.signals import connection_created from django.db import models from django.utils.encoding import python_2_unicode_compatible Loading @@ -18,6 +16,7 @@ class SpatialiteGeometryColumns(models.Model): coord_dimension = models.IntegerField() srid = models.IntegerField(primary_key=True) spatial_index_enabled = models.IntegerField() type = models.IntegerField(db_column='geometry_type') class Meta: app_label = 'gis' Loading Loading @@ -55,6 +54,7 @@ class SpatialiteSpatialRefSys(models.Model, SpatialRefSysMixin): auth_srid = models.IntegerField() ref_sys_name = models.CharField(max_length=256) proj4text = models.CharField(max_length=2048) srtext = models.CharField(max_length=2048) @property def wkt(self): Loading @@ -67,18 +67,3 @@ class SpatialiteSpatialRefSys(models.Model, SpatialRefSysMixin): app_label = 'gis' db_table = 'spatial_ref_sys' managed = False def add_spatial_version_related_fields(sender, **kwargs): """ Adds fields after establishing a database connection to prevent database operations at compile time. """ if connection_created.disconnect(add_spatial_version_related_fields, sender=DatabaseWrapper): spatial_version = connection.ops.spatial_version[0] if spatial_version >= 4: SpatialiteSpatialRefSys.add_to_class('srtext', models.CharField(max_length=2048)) SpatialiteGeometryColumns.add_to_class('type', models.IntegerField(db_column='geometry_type')) else: SpatialiteGeometryColumns.add_to_class('type', models.CharField(max_length=30)) connection_created.connect(add_spatial_version_related_fields, sender=DatabaseWrapper)
django/contrib/gis/db/backends/spatialite/operations.py +4 −9 Original line number Diff line number Diff line """ SQL functions reference lists: http://www.gaia-gis.it/spatialite-3.0.0-BETA/spatialite-sql-3.0.0.html https://web.archive.org/web/20130407175746/http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.0.0.html http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.2.1.html """ Loading Loading @@ -90,18 +89,14 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations): 'Length': 'ST_Length', 'Reverse': 'ST_Reverse', 'Scale': 'ScaleCoords', 'Translate': 'ST_Translate' if self.spatial_version >= (3, 1, 0) else 'ShiftCoords', 'Translate': 'ST_Translate', 'Union': 'ST_Union', } @cached_property def unsupported_functions(self): unsupported = {'BoundingCircle', 'ForceRHR', 'IsValid', 'MakeValid', 'MemSize'} if self.spatial_version < (3, 1, 0): unsupported.add('SnapToGrid') if self.spatial_version < (4, 0, 0): unsupported.update({'Perimeter', 'Reverse'}) elif not self.lwgeom_version(): if not self.lwgeom_version(): unsupported.add('GeoHash') return unsupported Loading @@ -116,8 +111,8 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations): 'database (error was "%s"). Was the SpatiaLite initialization ' 'SQL loaded on this database?') % (self.connection.settings_dict['NAME'], msg) six.reraise(ImproperlyConfigured, ImproperlyConfigured(new_msg), sys.exc_info()[2]) if version < (3, 0, 0): raise ImproperlyConfigured('GeoDjango only supports SpatiaLite versions 3.0.0 and above.') if version < (4, 0, 0): raise ImproperlyConfigured('GeoDjango only supports SpatiaLite versions 4.0.0 and above.') return version def convert_extent(self, box, srid): Loading
docs/ref/contrib/gis/db-api.txt +4 −4 Original line number Diff line number Diff line Loading @@ -388,7 +388,7 @@ Function PostGIS Oracle MySQL SpatiaLite :class:`Distance` X X X (≥ 5.6.1) X :class:`Envelope` X X X :class:`ForceRHR` X :class:`GeoHash` X X (≥ 4.0, LWGEOM) :class:`GeoHash` X X (LWGEOM) :class:`Intersection` X X X (≥ 5.6.1) X :class:`IsValid` X :class:`Length` X X X X Loading @@ -396,11 +396,11 @@ Function PostGIS Oracle MySQL SpatiaLite :class:`MemSize` X :class:`NumGeometries` X X X X :class:`NumPoints` X X X X :class:`Perimeter` X X X (≥ 4.0) :class:`Perimeter` X X X :class:`PointOnSurface` X X X :class:`Reverse` X X X (≥ 4.0) :class:`Reverse` X X X :class:`Scale` X X :class:`SnapToGrid` X X (≥ 3.1) :class:`SnapToGrid` X X :class:`SymDifference` X X X (≥ 5.6.1) X :class:`Transform` X X X :class:`Translate` X X Loading
docs/ref/contrib/gis/functions.txt +4 −4 Original line number Diff line number Diff line Loading @@ -263,7 +263,7 @@ right-hand rule. .. class:: GeoHash(expression, **extra) *Availability*: PostGIS, SpatiaLite (≥ 4.0, LWGEOM) *Availability*: PostGIS, SpatiaLite (LWGEOM) Accepts a single geographic field or expression and returns a `GeoHash`__ representation of the geometry. Loading Loading @@ -367,7 +367,7 @@ in the first linestring in the geometry field; otherwise returns ``None``. .. class:: Perimeter(expression, **extra) *Availability*: PostGIS, Oracle, SpatiaLite (≥ 4.0) *Availability*: PostGIS, Oracle, SpatiaLite Accepts a single geographic field or expression and returns the perimeter of the geometry field as a :class:`~django.contrib.gis.measure.Distance` object. On Loading @@ -389,7 +389,7 @@ guaranteed to lie on the surface of the field; otherwise returns ``None``. .. class:: Reverse(expression, **extra) *Availability*: PostGIS, Oracle, SpatiaLite (≥ 4.0) *Availability*: PostGIS, Oracle, SpatiaLite Accepts a single geographic field or expression and returns a geometry with reversed coordinates. Loading @@ -410,7 +410,7 @@ scaled coordinates by multiplying them with the ``x``, ``y``, and optionally .. class:: SnapToGrid(expression, *args, **extra) *Availability*: PostGIS, SpatiaLite (≥ 3.1) *Availability*: PostGIS, SpatiaLite Accepts a single geographic field or expression and returns a geometry with all points snapped to the given grid. How the geometry is snapped to the grid Loading