-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #34882 -- Fixed no options in AsGeoJSON() for geometries in non-default CRS. #17320
Conversation
fixes #34882
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello! Thank you for your contribution 💪
As it's your first contribution be sure to check out the patch review checklist.
If you're fixing a ticket from Trac make sure to set the "Has patch" flag and include a link to this PR in the ticket!
If you have any design or process questions then you can ask in the Django forum.
Welcome aboard ⛵️!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@3nids Thanks 👍 Please add a regression test.
@3nids Do you have time to keep working on this? |
I'm a rookie in the code, but I can give it a shot. Could you point me to a similar case in the tests? |
We could add a test for geometry with non-default diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py
index e9e2a5dcae..91441bf90c 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
|
@3nids Check out #17320 (comment). |
@felixxm many thanks!!!! |
@3nids Welcome aboard ⛵ |
@felixxm small question, guessing that main is the current dev branch, is a backport to 4.2.x possible? how is this handled? |
No, it doesn't qualify for a backport to 4.2 based on our supported versions policy. |
Oh, pity. Thanks for the feedback! |
When calling AssGeoJSON, if bbox and crs are both false, then options = 0, there fore not added to the expression.
In Postgis, with geometries, the default is not 0 but 8, meaning the CRS is returned, not respecting the original call arguments.
fixes #34882 https://code.djangoproject.com/ticket/34882#ticket