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 )
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 , 9 days ago
Type: | Uncategorized → Bug |
---|
comment:2 by , 9 days ago
Description: | modified (diff) |
---|
comment:3 by , 9 days ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:4 by , 9 days ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Version: | 5.1 → dev |
comment:5 by , 9 days ago
Has patch: | set |
---|
comment:6 by , 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. When I created a Python dict with the same information, things worked as expected.
I think this issue still might be relevant though? But not for my original reason.
comment:7 by , 8 days ago
Thanks for the update. Yes, this change still makes sense, however with lesser priority.
comment:8 by , 8 days ago
Patch needs improvement: | set |
---|
comment:10 by , 7 days ago
Triage Stage: | Accepted → Ready for checkin |
---|
Many thanks for noticing!