Opened 11 months ago
Closed 11 months 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 , 11 months ago
| Type: | Uncategorized → Bug |
|---|
comment:2 by , 11 months ago
| Description: | modified (diff) |
|---|
comment:3 by , 11 months ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:4 by , 11 months ago
| Triage Stage: | Unreviewed → Accepted |
|---|---|
| Version: | 5.1 → dev |
comment:5 by , 11 months ago
| Has patch: | set |
|---|
comment:6 by , 11 months 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.
comment:7 by , 11 months ago
Thanks for the update. Yes, this change still makes sense, however with lesser priority.
comment:8 by , 11 months ago
| Patch needs improvement: | set |
|---|
comment:10 by , 11 months ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
Many thanks for noticing!