Opened 9 days ago

Closed 7 days ago

#35989 closed Bug (fixed)

GeoJSON serializer producing invalid output (crs attribute)

Reported by: Jeremy Thompson Owned by: Jeremy Thompson
Component: GIS Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Jeremy Thompson)

The built-in GeoJSON serializer is producing invalid GeoJSON. The serialized output has a section like:

"crs": {"type": "name", "properties": {"name": "EPSG:4326"}}

However, according to the GeoJSON spec the crs attribute was removed from the spec in August of 2016 (ref: https://datatracker.ietf.org/doc/html/rfc7946#appendix-B.1)

This is causing issues when trying to use GeoJSON as the intermediary data format for passing data to other libraries (e.g. Leaflet https://leafletjs.com considers GeoJSON with the crs attribute as invalid and fails to parse it).

More information in the forum discussion here: https://forum.djangoproject.com/t/geojson-serializer-producing-invalid-output-crs/37097

Change History (11)

comment:1 by Jeremy Thompson, 9 days ago

Type: UncategorizedBug

comment:2 by Jeremy Thompson, 9 days ago

Description: modified (diff)

comment:3 by Jeremy Thompson, 9 days ago

Owner: set to Jeremy Thompson
Status: newassigned

comment:4 by Claude Paroz, 9 days ago

Triage Stage: UnreviewedAccepted
Version: 5.1dev

Many thanks for noticing!

comment:5 by Jeremy Thompson, 9 days ago

Has patch: set

comment:6 by Jeremy Thompson, 9 days ago

After a bit more investigation, I think my initial problem with Leaflet was due to how I was using the json_script filter. I was passing the string that was output from the serializer, which meant that the double quotes were getting escaped, which led to invalid JSON.

I think this issue still might be relevant though? But not for my original reason.

Version 0, edited 9 days ago by Jeremy Thompson (next)

comment:7 by Claude Paroz, 8 days ago

Thanks for the update. Yes, this change still makes sense, however with lesser priority.

comment:8 by Sarah Boyce, 8 days ago

Patch needs improvement: set

comment:9 by Jeremy Thompson, 8 days ago

Patch needs improvement: unset

Comments in PR addressed!

comment:10 by Claude Paroz, 8 days ago

Triage Stage: AcceptedReady for checkin

comment:11 by Sarah Boyce <42296566+sarahboyce@…>, 7 days ago

Resolution: fixed
Status: assignedclosed

In 918e7a2:

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

Note: See TracTickets for help on using tickets.
Back to Top