jeudi 26 février 2015

ST_GeomFromGeoJSON strips coordinates, is it a bug?


I'm storing some geo paths in PostGIS using GeoJSON and the ST_GeomFromGeoJSON()-function but I just found an issue with it:



SELECT ST_NumPoints(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[-122.023468,37.330232,0],[-122.02345,37.330233,0],[-122.02345,37.330233,0],[-122.023405,37.330236,0]]}')) = 4; -- FALSE

SELECT ST_NumPoints(ST_GeomFromText('LINESTRING (-122.023468 37.330232 0, -122.02345 37.330233 0, -122.02345 37.330233 0, -122.023405 37.330236 0)')) = 4; -- TRUE


It seems to strip the two 'middle' coordinates because they are the same. And I can buy that it would do that but it doesn't do it consistently, like when I use ST_GeomFromText() with the same list of coordinates. It also does not strip the coordinates when using "type": "MultiPoints" instead, but it would be the wrong semantics.


It's a problem for me because I need the points to match a sequence of timestamps as well or data will be lost. And the reason I'm using GeoJSON is that the app server is written in Javascript so it just seems natural.


I'm running Postgres 9.4.1 and SELECT PostGIS_Full_Version() gives me:



POSTGIS="2.1.5 r13152" GEOS="3.4.2-CAPI-1.8.2 r3921" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.11.1, released 2014/09/24" LIBXML="2.9.1" LIBJSON="UNKNOWN" RASTER




Aucun commentaire:

Enregistrer un commentaire