mirror of
https://github.com/django/django.git
synced 2025-10-30 00:56:09 +00:00
Fixed #30994 -- Added Oracle support for AsGeoJSON GIS function.
This commit is contained in:
committed by
Mariusz Felisiak
parent
7f0946298e
commit
f95b59a1b3
@@ -32,24 +32,27 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
|
||||
return
|
||||
|
||||
pueblo_json = '{"type":"Point","coordinates":[-104.609252,38.255001]}'
|
||||
houston_json = (
|
||||
houston_json = json.loads(
|
||||
'{"type":"Point","crs":{"type":"name","properties":'
|
||||
'{"name":"EPSG:4326"}},"coordinates":[-95.363151,29.763374]}'
|
||||
)
|
||||
victoria_json = (
|
||||
victoria_json = json.loads(
|
||||
'{"type":"Point","bbox":[-123.30519600,48.46261100,-123.30519600,48.46261100],'
|
||||
'"coordinates":[-123.305196,48.462611]}'
|
||||
)
|
||||
chicago_json = (
|
||||
chicago_json = json.loads(
|
||||
'{"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:4326"}},'
|
||||
'"bbox":[-87.65018,41.85039,-87.65018,41.85039],"coordinates":[-87.65018,41.85039]}'
|
||||
)
|
||||
# MySQL ignores the crs option.
|
||||
if mysql:
|
||||
houston_json = json.loads(houston_json)
|
||||
# MySQL and Oracle ignore the crs option.
|
||||
if mysql or oracle:
|
||||
del houston_json['crs']
|
||||
chicago_json = json.loads(chicago_json)
|
||||
del chicago_json['crs']
|
||||
# Oracle ignores also the bbox and precision options.
|
||||
if oracle:
|
||||
del chicago_json['bbox']
|
||||
del victoria_json['bbox']
|
||||
chicago_json['coordinates'] = [-87.650175, 41.850385]
|
||||
|
||||
# Precision argument should only be an integer
|
||||
with self.assertRaises(TypeError):
|
||||
@@ -75,10 +78,10 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
|
||||
# WHERE "geoapp_city"."name" = 'Houston';
|
||||
# This time we include the bounding box by using the `bbox` keyword.
|
||||
self.assertJSONEqual(
|
||||
victoria_json,
|
||||
City.objects.annotate(
|
||||
geojson=functions.AsGeoJSON('point', bbox=True)
|
||||
).get(name='Victoria').geojson
|
||||
).get(name='Victoria').geojson,
|
||||
victoria_json,
|
||||
)
|
||||
|
||||
# SELECT ST_AsGeoJson("geoapp_city"."point", 5, 3) FROM "geoapp_city"
|
||||
|
||||
Reference in New Issue
Block a user