[postgis-tickets] [PostGIS] #2546: GeoJSON with string coordinates parses incorrectly instead of throwing error

PostGIS trac at osgeo.org
Wed Nov 20 03:59:54 PST 2013


#2546: GeoJSON with string coordinates parses incorrectly instead of throwing
error
-----------------------+----------------------------------------------------
 Reporter:  crschmidt  |       Owner:  pramsey
     Type:  defect     |      Status:  new    
 Priority:  medium     |   Milestone:         
Component:  postgis    |     Version:  2.0.x  
 Keywords:             |  
-----------------------+----------------------------------------------------
 SELECT
 ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[-48.23456,20.12345]}'))
 returns POINT(-48.23456 20.12345)

 SELECT
 ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":["-48.23456","20.12345"]}'))
 returns POINT(-48 20)

 Although the data in the second example is *wrong* -- coordinates
 shouldn't be enclosed in strings -- it seems an odd choice to truncate the
 values instead of just reporting an error back to the user. (I think
 parsing them as floats would also be reasonable, but I wouldn't say it's
 at all a requirement.)

 This was brought up by timbunce in the GeoJSON channel; he had a login
 issue so I am reporting on his behalf.

 POSTGIS="2.0.3 r11128" GEOS="3.3.8-CAPI-1.7.8" PROJ="Rel. 4.8.0, 6 March
 2012" LIBXML="2.7.6" LIBJSON="UNKNOWN"

 Adding on Tim's behalf as well (I personally disagree):
 "< timbunce_> Please add a note to the case that supporting coords in
 string form would make life a lot easier for people working in dynamically
 typed languages where the string/number distinction is subtle."

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2546>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list