Created
November 20, 2013 10:31
-
-
Save timbunce/7560988 to your computer and use it in GitHub Desktop.
Postgis GeoJSON silent massive loss of precision with coordinates specified as string values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This works as expected: | |
corp=> SELECT ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[-48.23456,20.12345]}')) As wkt; | |
wkt | |
--------------------------- | |
POINT(-48.23456 20.12345) | |
but this doesn't: | |
corp=> SELECT ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":["-48.23456","20.12345"]}')) As wkt; | |
wkt | |
--------------- | |
POINT(-48 20) | |
It seems that when coordinates are provided as strings they are truncated to integers. | |
Significant and silent data loss! | |
I'd prefer that it "just work", but I'd much prefer an exception being thrown rather than the current silent data loss. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi @timbunce I see the issue is because of this in
liblwgeom/lwin_geojson.c
and the corresponding statement for
pt.y
andpt.z
. I will get it fixed. Thanks for reporting this!