[postgis-tickets] [PostGIS] #2742: Rounding bug using ST_GeomFromGeojson()
PostGIS
trac at osgeo.org
Mon May 19 09:41:19 PDT 2014
#2742: Rounding bug using ST_GeomFromGeojson()
---------------------+------------------------------------------------------
Reporter: jakeorr | Owner: pramsey
Type: task | Status: new
Priority: medium | Milestone:
Component: postgis | Version: 2.1.x
Keywords: |
---------------------+------------------------------------------------------
Let's say I have the following geographical point represented in GeoJSON:
{{{{"type":"Point","coordinates":[-109.0,35.292506]}}}}
When I run the following conversion, things work as expected:
{{{
SELECT
ST_AsText(ST_GeomFromGeojson('{"type":"Point","coordinates":[-109.0,35.292506]}'));
st_astext
-----------------------
POINT(-109 35.292506)
(1 row)
}}}
The problem occurs if the string passed to {{{ST_GeomFromGeojson()}}}
omits the trailing decimal on {{{-109.0}}}:
{{{
SELECT
ST_AsText(ST_GeomFromGeojson('{"type":"Point","coordinates":[-109,35.292506]}'));
st_astext
----------------
POINT(-109 35)
(1 row)
}}}
Notice how in this case rounding to an Integer value occurs on both
latitude and longitude. The loss of precision on the latitude value in
this case is very significant (32.53 km).
'''Note:''' I left out the CRS field for clarify, the problem occurs
either way.
The same problem does not occur using the {{{ST_GeomFromText()}}}
function. Both numbers are ''not'' rounded to Integers if the first looks
like an integer.
Here is my postGIS full version:
POSTGIS="2.1.0 r11822" GEOS="3.4.2-CAPI-1.8.2 r3921" PROJ="Rel. 4.8.0, 6
March 2012" GDAL="GDAL 1.10.1, released 2013/08/26" LIBXML="2.9.1"
LIBJSON="UNKNOWN" RASTER
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2742>
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