Ticket Hash: | 74ba14876cbcfa9abeb487aae14b1b4c9f8ca9d1 | |||
Title: | GeomFromGeoJSON requires properties in a specific order | |||
Status: | Fixed | Type: | Code_Defect | |
Severity: | Important | Priority: | Immediate | |
Subsystem: | Resolution: | Fixed | ||
Last Modified: | 2019-07-25 18:52:30 | |||
Version Found In: | version 4.3 | |||
User Comments: | ||||
anonymous added on 2016-10-03 18:12:05:
GeomFromGeoJSON requires the 'type' property to come before the 'coordinates' property or parsing fails: pass: SELECT AsText( GeomFromGeoJSON('{"type":"Point","coordinates":[1, 1]}') ); fail: SELECT AsText( GeomFromGeoJSON('{"coordinates":[1, 1],"type":"Point"}') ); The GeoJSON spec does not say that property order is significant. A workaround is to re-order the JSON properties in the application; however this is really inconvenient, a better solution would be to allow the libspatialite parser to handle these cases internally. If this is not possible then it should be added to the documentation so developers understand that the property ordering is the responsibility of the application. sandro added on 2016-11-28 16:19:28: you are absolutely right; the GeoJSON specification (IETF RFC 7946) clearly states that "The ordering of the members of any JSON object defined in this document MUST be considered irrelevant, as specified by [RFC7159]". now the GeoJSON parser has been patched accordingly to the above specification. anonymous added on 2019-07-25 18:52:30: As a workaround for versions prior to this being fixed, it's possible to use the JSON1 extension to rewrite the property order as so: SELECT AsText( GeomFromGeoJson( json_object( 'type', json_extract(json, '$.type' ), 'coordinates', json_extract(json, '$.coordinates' ) ))); |