[Django] #35989: GeoJSON serializer producing invalid output (crs attribute)

18 views
Skip to first unread message

Django

unread,
Dec 9, 2024, 8:29:19 AM12/9/24
to django-...@googlegroups.com
#35989: GeoJSON serializer producing invalid output (crs attribute)
---------------------------------+-----------------------------------------
Reporter: Jeremy Thompson | Type: Uncategorized
Status: new | Component: GIS
Version: 5.1 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
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 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
--
Ticket URL: <https://code.djangoproject.com/ticket/35989>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 9, 2024, 8:29:32 AM12/9/24
to django-...@googlegroups.com
#35989: GeoJSON serializer producing invalid output (crs attribute)
---------------------------------+--------------------------------------
Reporter: Jeremy Thompson | Owner: (none)
Type: Bug | Status: new
Component: GIS | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Jeremy Thompson):

* type: Uncategorized => Bug

--
Ticket URL: <https://code.djangoproject.com/ticket/35989#comment:1>

Django

unread,
Dec 9, 2024, 8:30:58 AM12/9/24
to django-...@googlegroups.com
#35989: GeoJSON serializer producing invalid output (crs attribute)
---------------------------------+--------------------------------------
Reporter: Jeremy Thompson | Owner: (none)
Type: Bug | Status: new
Component: GIS | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Description changed by Jeremy Thompson:

Old description:

> 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 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

New description:

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

--
--
Ticket URL: <https://code.djangoproject.com/ticket/35989#comment:2>

Django

unread,
Dec 9, 2024, 8:32:34 AM12/9/24
to django-...@googlegroups.com
#35989: GeoJSON serializer producing invalid output (crs attribute)
-------------------------------------+-------------------------------------
Reporter: Jeremy Thompson | Owner: Jeremy
| Thompson
Type: Bug | Status: assigned
Component: GIS | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jeremy Thompson):

* owner: (none) => Jeremy Thompson
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35989#comment:3>

Django

unread,
Dec 9, 2024, 8:49:49 AM12/9/24
to django-...@googlegroups.com
#35989: GeoJSON serializer producing invalid output (crs attribute)
-------------------------------------+-------------------------------------
Reporter: Jeremy Thompson | Owner: Jeremy
| Thompson
Type: Bug | Status: assigned
Component: GIS | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* stage: Unreviewed => Accepted
* version: 5.1 => dev

Comment:

Many thanks for noticing!
--
Ticket URL: <https://code.djangoproject.com/ticket/35989#comment:4>

Django

unread,
Dec 9, 2024, 12:57:08 PM12/9/24
to django-...@googlegroups.com
#35989: GeoJSON serializer producing invalid output (crs attribute)
-------------------------------------+-------------------------------------
Reporter: Jeremy Thompson | Owner: Jeremy
| Thompson
Type: Bug | Status: assigned
Component: GIS | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jeremy Thompson):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35989#comment:5>

Django

unread,
Dec 9, 2024, 11:12:29 PM12/9/24
to django-...@googlegroups.com
#35989: GeoJSON serializer producing invalid output (crs attribute)
-------------------------------------+-------------------------------------
Reporter: Jeremy Thompson | Owner: Jeremy
| Thompson
Type: Bug | Status: assigned
Component: GIS | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jeremy Thompson):

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.
--
Ticket URL: <https://code.djangoproject.com/ticket/35989#comment:6>

Django

unread,
Dec 10, 2024, 5:59:30 AM12/10/24
to django-...@googlegroups.com
#35989: GeoJSON serializer producing invalid output (crs attribute)
-------------------------------------+-------------------------------------
Reporter: Jeremy Thompson | Owner: Jeremy
| Thompson
Type: Bug | Status: assigned
Component: GIS | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Claude Paroz):

Thanks for the update. Yes, this change still makes sense, however with
lesser priority.
--
Ticket URL: <https://code.djangoproject.com/ticket/35989#comment:7>

Django

unread,
Dec 10, 2024, 7:14:06 AM12/10/24
to django-...@googlegroups.com
#35989: GeoJSON serializer producing invalid output (crs attribute)
-------------------------------------+-------------------------------------
Reporter: Jeremy Thompson | Owner: Jeremy
| Thompson
Type: Bug | Status: assigned
Component: GIS | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35989#comment:8>

Django

unread,
Dec 10, 2024, 10:11:15 PM12/10/24
to django-...@googlegroups.com
#35989: GeoJSON serializer producing invalid output (crs attribute)
-------------------------------------+-------------------------------------
Reporter: Jeremy Thompson | Owner: Jeremy
| Thompson
Type: Bug | Status: assigned
Component: GIS | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jeremy Thompson):

* needs_better_patch: 1 => 0

Comment:

Comments in PR addressed!
--
Ticket URL: <https://code.djangoproject.com/ticket/35989#comment:9>

Django

unread,
Dec 11, 2024, 2:07:58 AM12/11/24
to django-...@googlegroups.com
#35989: GeoJSON serializer producing invalid output (crs attribute)
-------------------------------------+-------------------------------------
Reporter: Jeremy Thompson | Owner: Jeremy
| Thompson
Type: Bug | Status: assigned
Component: GIS | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/35989#comment:10>

Django

unread,
Dec 11, 2024, 4:45:56 AM12/11/24
to django-...@googlegroups.com
#35989: GeoJSON serializer producing invalid output (crs attribute)
-------------------------------------+-------------------------------------
Reporter: Jeremy Thompson | Owner: Jeremy
| Thompson
Type: Bug | Status: closed
Component: GIS | Version: dev
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"918e7a2c766e67144f1e2bfcc029abe16ce28f54" 918e7a2]:
{{{#!CommitTicketReference repository=""
revision="918e7a2c766e67144f1e2bfcc029abe16ce28f54"
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
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35989#comment:11>
Reply all
Reply to author
Forward
0 new messages