diff options
| author | Denis Rouzaud <denis.rouzaud@gmail.com> | 2023-10-06 05:25:32 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-10-06 05:27:04 +0200 |
| commit | df3f97a7d6593900300ebe163561719d68355aa4 (patch) | |
| tree | 3df69c6cfcc42ed632818d1b16f02a6d55c8bc3a /tests | |
| parent | 0e34ac8981035dfefd622e7fd180e5e813d3846b (diff) | |
[5.0.x] Fixed #34882 -- Fixed no options in AsGeoJSON() for geometries in non-default CRS.
Backport of 96e7a752b6c44a84e18d82d37524c1df64b32e12 from main
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/gis_tests/geoapp/test_functions.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py index b75f053b3d..777e17420e 100644 --- a/tests/gis_tests/geoapp/test_functions.py +++ b/tests/gis_tests/geoapp/test_functions.py @@ -11,7 +11,7 @@ from django.db.models import IntegerField, Sum, Value from django.test import TestCase, skipUnlessDBFeature from ..utils import FuncTestMixin -from .models import City, Country, CountryWebMercator, State, Track +from .models import City, Country, CountryWebMercator, ManyPointModel, State, Track class GISFunctionsTests(FuncTestMixin, TestCase): @@ -119,6 +119,25 @@ class GISFunctionsTests(FuncTestMixin, TestCase): chicago_json, ) + @skipUnlessDBFeature("has_AsGeoJSON_function") + def test_asgeojson_option_0(self): + p1 = Point(1, 1, srid=4326) + p2 = Point(2, 2, srid=4326) + obj = ManyPointModel.objects.create( + point1=p1, + point2=p2, + point3=p2.transform(3857, clone=True), + ) + self.assertJSONEqual( + ManyPointModel.objects.annotate(geojson=functions.AsGeoJSON("point3")) + .get(pk=obj.pk) + .geojson, + # GeoJSON without CRS. + json.loads( + '{"type":"Point","coordinates":[222638.98158655,222684.20850554]}' + ), + ) + @skipUnlessDBFeature("has_AsGML_function") def test_asgml(self): # Should throw a TypeError when trying to obtain GML from a |
