From: Paul Ramsey Date: Fri, 7 Mar 2014 23:20:25 +0000 (+0000) Subject: #2546, GeoJSON with string coordinates parses incorrectly X-Git-Tag: 2.2.0rc1~1206 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fae22a2b8571605fb68cc39a49554a2009a517cf;p=postgis #2546, GeoJSON with string coordinates parses incorrectly git-svn-id: http://svn.osgeo.org/postgis/trunk@12302 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index 732b8ebe0..2da914487 100644 --- a/NEWS +++ b/NEWS @@ -47,6 +47,7 @@ PostGIS 2.2.0 - #2534, st_distance is returning incorrect results for large geographies - #2540, Change GUC name for GDAL_DATA to postgis.gdal_datapath - #2543, invalid join selectivity error from simple query + - #2546, GeoJSON with string coordinates parses incorrectly - #2552, Fix handling of NULL raster in ST_AsTIFF, ST_AsPNG and ST_AsJPEG - #2555, Fix parsing issue of range arguments of ST_Reclass diff --git a/liblwgeom/lwin_geojson.c b/liblwgeom/lwin_geojson.c index e4de54a16..87dba6606 100644 --- a/liblwgeom/lwin_geojson.c +++ b/liblwgeom/lwin_geojson.c @@ -82,29 +82,19 @@ parse_geojson_coord(json_object *poObj, int *hasz, POINTARRAY *pa) // Read X coordinate poObjCoord = json_object_array_get_idx( poObj, 0 ); - iType = json_object_get_type(poObjCoord); - if (iType == json_type_double) - pt.x = json_object_get_double( poObjCoord ); - else - pt.x = json_object_get_int( poObjCoord ); + pt.x = json_object_get_double( poObjCoord ); LWDEBUGF(3, "parse_geojson_coord pt.x = %f.", pt.x ); - // Read Y coordiante + // Read Y coordinate poObjCoord = json_object_array_get_idx( poObj, 1 ); - if (iType == json_type_double) - pt.y = json_object_get_double( poObjCoord ); - else - pt.y = json_object_get_int( poObjCoord ); + pt.y = json_object_get_double( poObjCoord ); LWDEBUGF(3, "parse_geojson_coord pt.y = %f.", pt.y ); if( nSize == 3 ) /* should this be >= 3 ? */ { - // Read Z coordiante + // Read Z coordinate poObjCoord = json_object_array_get_idx( poObj, 2 ); - if (iType == 3) - pt.z = json_object_get_double( poObjCoord ); - else - pt.z = json_object_get_int( poObjCoord ); + pt.z = json_object_get_double( poObjCoord ); LWDEBUGF(3, "parse_geojson_coord pt.z = %f.", pt.z ); *hasz = LW_TRUE; }