summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2020-11-11 01:39:15 -0500
committerGitHub <noreply@github.com>2020-11-11 07:39:15 +0100
commitc9e85443211715993d7b27af2bf772380e26f6de (patch)
tree0cdb83e9b43a8b6cd668be1386a7a8cf7e7737ed
parentf90fcc222bbccf7915aaadbfa375243e9612d5f1 (diff)
Added SpatialFeatures.unsupported_geojson_options.
-rw-r--r--django/contrib/gis/db/backends/base/features.py3
-rw-r--r--django/contrib/gis/db/backends/mysql/features.py1
-rw-r--r--django/contrib/gis/db/backends/oracle/features.py1
-rw-r--r--tests/gis_tests/geoapp/test_functions.py7
4 files changed, 8 insertions, 4 deletions
diff --git a/django/contrib/gis/db/backends/base/features.py b/django/contrib/gis/db/backends/base/features.py
index e714440e58..a88ad03684 100644
--- a/django/contrib/gis/db/backends/base/features.py
+++ b/django/contrib/gis/db/backends/base/features.py
@@ -51,6 +51,9 @@ class BaseSpatialFeatures:
# Can SchemaEditor alter geometry fields?
can_alter_geometry_field = True
+ # Set of options that AsGeoJSON() doesn't support.
+ unsupported_geojson_options = {}
+
@property
def supports_bbcontains_lookup(self):
return 'bbcontains' in self.connection.ops.gis_operators
diff --git a/django/contrib/gis/db/backends/mysql/features.py b/django/contrib/gis/db/backends/mysql/features.py
index 424df28d94..63e2fa1dd3 100644
--- a/django/contrib/gis/db/backends/mysql/features.py
+++ b/django/contrib/gis/db/backends/mysql/features.py
@@ -14,6 +14,7 @@ class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures):
supports_transform = False
supports_null_geometries = False
supports_num_points_poly = False
+ unsupported_geojson_options = {'crs'}
@cached_property
def supports_empty_geometry_collection(self):
diff --git a/django/contrib/gis/db/backends/oracle/features.py b/django/contrib/gis/db/backends/oracle/features.py
index f2ed4d3076..80c71e0dcb 100644
--- a/django/contrib/gis/db/backends/oracle/features.py
+++ b/django/contrib/gis/db/backends/oracle/features.py
@@ -10,3 +10,4 @@ class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures):
supports_geometry_field_unique_index = False
supports_perimeter_geodetic = True
supports_dwithin_distance_expr = False
+ unsupported_geojson_options = {'bbox', 'crs', 'precision'}
diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py
index c2e06db4c5..b518f9cb53 100644
--- a/tests/gis_tests/geoapp/test_functions.py
+++ b/tests/gis_tests/geoapp/test_functions.py
@@ -44,14 +44,13 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
'{"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:4326"}},'
'"bbox":[-87.65018,41.85039,-87.65018,41.85039],"coordinates":[-87.65018,41.85039]}'
)
- # MySQL and Oracle ignore the crs option.
- if mysql or oracle:
+ if 'crs' in connection.features.unsupported_geojson_options:
del houston_json['crs']
del chicago_json['crs']
- # Oracle ignores also the bbox and precision options.
- if oracle:
+ if 'bbox' in connection.features.unsupported_geojson_options:
del chicago_json['bbox']
del victoria_json['bbox']
+ if 'precision' in connection.features.unsupported_geojson_options:
chicago_json['coordinates'] = [-87.650175, 41.850385]
# Precision argument should only be an integer