[postgis-tickets] [PostGIS] #2534: st_distance is returning incorrect results for large geographies
PostGIS
trac at osgeo.org
Wed Nov 6 08:32:36 PST 2013
#2534: st_distance is returning incorrect results for large geographies
------------------------------------+---------------------------------------
Reporter: samuelb | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.1.1
Component: postgis | Version: 2.0.x
Keywords: st_distance, geography |
------------------------------------+---------------------------------------
Following geography distance query:
SELECT st_distance(st_geographyfromtext('POINT(-0 0)'),
st_geographyfromtext('POLYGON((-20 -20,-20 60,90 60,90 -20,-20 -20))'))
returns 2226389.81558413 instead of the expected result 0 as you get for
the same query but with geometries:
SELECT st_distance(st_geomfromewkt('SRID=4326;POINT(-0 0)'),
st_geomfromewkt('SRID=4326;POLYGON((-20 -20,-20 60,90 60,90 -20,-20
-20))'))
I've tried adding extra vertices to my rectangle but that didn't help.
When you slightly decrease to a maximum latitude of 55 then it works:
SELECT st_distance(st_geographyfromtext('POINT(-0 0)'),
st_geographyfromtext('POLYGON((-20 -20,-20 55,90 55,90 -20,-20 -20))'))
Changing the order of the coordinates didn't work. In the end I would like
to be able to check if a point is within 2km of the bounding box (-179
-85) (179 85) as this is one of the geometries in my database.
Note that st_dwithin also returns false instead of true.
Tested on
"PostgreSQL 9.1.10 on x86_64-unknown-linux-gnu, compiled by gcc
(Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit POSTGIS="1.5.3"
GEOS="3.2.2-CAPI-1.6.2" PROJ="Rel. 4.7.1, 23 September 2009"
LIBXML="2.7.8" USE_STATS"
and on:
"PostgreSQL 9.2.4, compiled by Visual C++ build 1600, 32-bit
POSTGIS="2.0.3 r11132" GEOS="3.3.8-CAPI-1.7.8" PROJ="Rel. 4.8.0, 6 March
2012" GDAL="GDAL 1.9.2, released 2012/10/08 GDAL_DATA not found"
LIBXML="2.7.8" LIBJSON="UNKNOWN" RASTER"
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2534>
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