Commit 60428ed5 authored by Claude Paroz's avatar Claude Paroz
Browse files

Removed some more hardcoded backends in GIS tests

Refs #22632. Thanks Tim Graham for the review.
parent 5675eb37
Loading
Loading
Loading
Loading
+20 −7
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@ class BaseSpatialFeatures(object):
    # Does the database contain a SpatialRefSys model to store SRID information?
    has_spatialrefsys_table = True

    # Reference implementation of 3D functions is:
    # http://postgis.net/docs/PostGIS_Special_Functions_Index.html#PostGIS_3D_Functions
    supports_3d_functions = False
    # Does the database support SRID transform operations?
    supports_transform = True
    # Do geometric relationship operations operate on real shapes (or only on bounding boxes)?
@@ -29,24 +32,34 @@ class BaseSpatialFeatures(object):

    # The following properties indicate if the database backend support
    # certain lookups (dwithin, left and right, relate, ...)
    supports_distances_lookups = True
    supports_left_right_lookups = False

    @property
    def supports_relate_lookup(self):
        return 'relate' in self.connection.ops.geometry_functions
    def supports_bbcontains_lookup(self):
        return 'bbcontains' in self.connection.ops.gis_terms

    @property
    def supports_contained_lookup(self):
        return 'contained' in self.connection.ops.gis_terms

    @property
    def has_dwithin_lookup(self):
    def supports_dwithin_lookup(self):
        return 'dwithin' in self.connection.ops.distance_functions

    @property
    def supports_relate_lookup(self):
        return 'relate' in self.connection.ops.gis_terms

    # For each of those methods, the class will have a property named
    # `has_<name>_method` (defined in __init__) which accesses connection.ops
    # to determine GIS method availability.
    geoqueryset_methods = (
        'centroid', 'difference', 'envelope', 'force_rhr', 'geohash', 'gml',
        'intersection', 'kml', 'num_geom', 'perimeter', 'point_on_surface',
        'reverse', 'scale', 'snap_to_grid', 'svg', 'sym_difference',
        'transform', 'translate', 'union', 'unionagg',
        'area', 'centroid', 'difference', 'distance', 'distance_spheroid',
        'envelope', 'force_rhr', 'geohash', 'gml', 'intersection', 'kml',
        'length', 'num_geom', 'perimeter', 'point_on_surface', 'reverse',
        'scale', 'snap_to_grid', 'svg', 'sym_difference', 'transform',
        'translate', 'union', 'unionagg',
    )

    # Specifies whether the Collect and Extent aggregates are supported by the database
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ from django.contrib.gis.db.backends.mysql.operations import MySQLOperations

class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures):
    has_spatialrefsys_table = False
    supports_distances_lookups = False
    supports_transform = False
    supports_real_shape_operations = False
    supports_null_geometries = False
+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ from django.contrib.gis.db.backends.postgis.schema import PostGISSchemaEditor


class DatabaseFeatures(BaseSpatialFeatures, Psycopg2DatabaseFeatures):
    supports_3d_functions = True
    supports_left_right_lookups = True


+4 −4
Original line number Diff line number Diff line
@@ -631,8 +631,8 @@ class GeoQuerySet(QuerySet):
                u, unit_name, s = get_srid_info(self.query.transformed_srid, connection)
                geodetic = unit_name.lower() in geo_field.geodetic_units

            if backend.spatialite and geodetic:
                raise ValueError('SQLite does not support linear distance calculations on geodetic coordinate systems.')
            if geodetic and not connection.features.supports_distance_geodetic:
                raise ValueError('This database does not support linear distance calculations on geodetic coordinate systems.')

            if distance:
                if self.query.transformed_srid:
@@ -690,8 +690,8 @@ class GeoQuerySet(QuerySet):
                    # works on 3D geometries.
                    procedure_fmt += ",'%(spheroid)s'"
                    procedure_args.update({'function': backend.length_spheroid, 'spheroid': params[1]})
                elif geom_3d and backend.postgis:
                    # Use 3D variants of perimeter and length routines on PostGIS.
                elif geom_3d and connection.features.supports_3d_functions:
                    # Use 3D variants of perimeter and length routines on supported backends.
                    if perimeter:
                        procedure_args.update({'function': backend.perimeter3d})
                    elif length:
+2 −1
Original line number Diff line number Diff line
from django.contrib.gis.db import models
from django.contrib.gis.tests.utils import gisfield_may_be_null
from django.utils.encoding import python_2_unicode_compatible


@@ -38,7 +39,7 @@ class CensusZipcode(NamedModel):

class SouthTexasZipcode(NamedModel):
    "Model for a few South Texas ZIP codes."
    poly = models.PolygonField(srid=32140, null=True)
    poly = models.PolygonField(srid=32140, null=gisfield_may_be_null)


class Interstate(NamedModel):
Loading