diff options
| author | Jeremy Thompson <jeremythompson.918@gmail.com> | 2024-12-09 12:55:27 -0500 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-12-11 10:45:47 +0100 |
| commit | 918e7a2c766e67144f1e2bfcc029abe16ce28f54 (patch) | |
| tree | 2544a2072f12b34a680ed352763b4007255e97af | |
| parent | 5e998d717f7b4220a1728bd49b66ca0162e2a6cb (diff) | |
Fixed #35989 -- Removed crs from GeoJSON serializer.
Specification of coordinate reference systems (crs) was removed from the GeoJSON spec in 2016.
https://datatracker.ietf.org/doc/html/rfc7946#appendix-B.1
| -rw-r--r-- | django/contrib/gis/serializers/geojson.py | 6 | ||||
| -rw-r--r-- | docs/ref/contrib/gis/serializers.txt | 1 | ||||
| -rw-r--r-- | tests/gis_tests/geoapp/test_serializers.py | 2 |
3 files changed, 3 insertions, 6 deletions
diff --git a/django/contrib/gis/serializers/geojson.py b/django/contrib/gis/serializers/geojson.py index 072ee9dc48..187af26eed 100644 --- a/django/contrib/gis/serializers/geojson.py +++ b/django/contrib/gis/serializers/geojson.py @@ -25,11 +25,7 @@ class Serializer(JSONSerializer): def start_serialization(self): self._init_options() self._cts = {} # cache of CoordTransform's - self.stream.write( - '{"type": "FeatureCollection", ' - '"crs": {"type": "name", "properties": {"name": "EPSG:%d"}},' - ' "features": [' % self.srid - ) + self.stream.write('{"type": "FeatureCollection", "features": [') def end_serialization(self): self.stream.write("]}") diff --git a/docs/ref/contrib/gis/serializers.txt b/docs/ref/contrib/gis/serializers.txt index e62b6ef306..2ce2e22c33 100644 --- a/docs/ref/contrib/gis/serializers.txt +++ b/docs/ref/contrib/gis/serializers.txt @@ -46,7 +46,6 @@ Would output:: { "type": "FeatureCollection", - "crs": {"type": "name", "properties": {"name": "EPSG:4326"}}, "features": [ { "type": "Feature", diff --git a/tests/gis_tests/geoapp/test_serializers.py b/tests/gis_tests/geoapp/test_serializers.py index 40a4f47487..d57d221add 100644 --- a/tests/gis_tests/geoapp/test_serializers.py +++ b/tests/gis_tests/geoapp/test_serializers.py @@ -23,6 +23,8 @@ class GeoJSONSerializerTests(TestCase): def test_serialization_base(self): geojson = serializers.serialize("geojson", City.objects.order_by("name")) geodata = json.loads(geojson) + self.assertEqual(list(geodata.keys()), ["type", "features"]) + self.assertEqual(geodata["type"], "FeatureCollection") self.assertEqual(len(geodata["features"]), len(City.objects.all())) self.assertEqual(geodata["features"][0]["geometry"]["type"], "Point") self.assertEqual(geodata["features"][0]["properties"]["name"], "Chicago") |
