Opened 11 years ago
Closed 11 years ago
#2351 closed defect (fixed)
Postgis 2.1 st_distance between geographies wrong
Reported by: | mamay | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.1.0 |
Component: | postgis | Version: | 2.0.x |
Keywords: | Cc: |
Description
Results between the below queries are very different (but assumed to be identical, or very closed):
1) SELECT st_distance('SRID=4283;LINESTRING(149.386990599235 -26.3567415843982,149.386990599247 -26.3567415843965,149.387026257283 -26.3567362980298,149.387125078815 -26.3567216575441,149.387223900317 -26.3567070169918,149.387322721788 -26.356692376373,149.387421625802 -26.3566777343106,149.387520447213 -26.3566630935584,149.387619268592 -26.3566484527397,149.387718089941 -26.3566338118544,149.38781691126 -26.3566191709025,149.387915732548 -26.3566045298841,149.388014553806 -26.356589888799,149.388113375033 -26.3565752476473,149.38821219623 -26.356560606429,149.388311017396 -26.3565459651442,149.388409838532 -26.3565313237927,149.38850874221 -26.3565166809971,149.388607563285 -26.3565020395124,149.388706384329 -26.3564873979611,149.388720054423 -26.3564853653255,149.388755888538 -26.3564806169646,149.388805686816 -26.3564760867424,149.388855694739 -26.3564737184747,149.388905749016 -26.3564736051138,149.388955768932 -26.3564758382342,149.388991180786 -26.3564786760044,149.389005666353 -26.3564801486226,149.389105155017 -26.3564899474185,149.389204726265 -26.3564997447661,149.389304295669 -26.3565094518463,149.389403866939 -26.356519249053,149.38950343822 -26.3565290461892,149.389603009512 -26.3565388432549,149.389702580815 -26.3565486402502,149.389802152129 -26.356558437175,149.389901723455 -26.3565682340293,149.390001294791 -26.3565780308132,149.390100864283 -26.3565877373297,149.390200435641 -26.3565975339727,149.390300007011 -26.3566073305452,149.390399578391 -26.3566171270472,149.390499149782 -26.3566269234787,149.390598721185 -26.3566367198398,149.390698210025 -26.3566465175092,149.39079778145 -26.3566563137294,149.390897352885 -26.3566661098792,149.390996922476 -26.3566758157616,149.391096493934 -26.3566856117704,149.391138458852 -26.3566897832034)'::geometry::geography, 'SRID=4283;POINT(149.386990599235 -26.3567415843982)'::geometry::geography);
— results 15630629.1006441 meters!
2) SELECT st_distance(st_transform('SRID=4283;LINESTRING(149.386990599235 -26.3567415843982,149.386990599247 -26.3567415843965,149.387026257283 -26.3567362980298,149.387125078815 -26.3567216575441,149.387223900317 -26.3567070169918,149.387322721788 -26.356692376373,149.387421625802 -26.3566777343106,149.387520447213 -26.3566630935584,149.387619268592 -26.3566484527397,149.387718089941 -26.3566338118544,149.38781691126 -26.3566191709025,149.387915732548 -26.3566045298841,149.388014553806 -26.356589888799,149.388113375033 -26.3565752476473,149.38821219623 -26.356560606429,149.388311017396 -26.3565459651442,149.388409838532 -26.3565313237927,149.38850874221 -26.3565166809971,149.388607563285 -26.3565020395124,149.388706384329 -26.3564873979611,149.388720054423 -26.3564853653255,149.388755888538 -26.3564806169646,149.388805686816 -26.3564760867424,149.388855694739 -26.3564737184747,149.388905749016 -26.3564736051138,149.388955768932 -26.3564758382342,149.388991180786 -26.3564786760044,149.389005666353 -26.3564801486226,149.389105155017 -26.3564899474185,149.389204726265 -26.3564997447661,149.389304295669 -26.3565094518463,149.389403866939 -26.356519249053,149.38950343822 -26.3565290461892,149.389603009512 -26.3565388432549,149.389702580815 -26.3565486402502,149.389802152129 -26.356558437175,149.389901723455 -26.3565682340293,149.390001294791 -26.3565780308132,149.390100864283 -26.3565877373297,149.390200435641 -26.3565975339727,149.390300007011 -26.3566073305452,149.390399578391 -26.3566171270472,149.390499149782 -26.3566269234787,149.390598721185 -26.3566367198398,149.390698210025 -26.3566465175092,149.39079778145 -26.3566563137294,149.390897352885 -26.3566661098792,149.390996922476 -26.3566758157616,149.391096493934 -26.3566856117704,149.391138458852 -26.3566897832034)'::geometry, 999155), st_transform('SRID=4283;POINT(149.386990599235 -26.3567415843982)'::geometry, 999155));
— result 0, which is correct.
POSTGIS="2.1.0beta3dev r11503" GEOS="3.3.8-CAPI-1.7.8" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.10dev, released 2011/12/29" LIBXML="2.7.3" LIBJSON="UNKNOWN" RASTER
OSX 10.7.5
same result on ubuntu 11.10 postgis 2.1
Change History (5)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Replicated here, OSX 10.6. Since the test point is equal to the first point, the answer should certainly be zero, so there's something interesting going on there.
comment:3 by , 11 years ago
Also demonstrable with a much smaller line:
SELECT st_distance( 'SRID=4283;LINESTRING(149.386990599235 -26.3567415843982,149.386990599247 -26.3567415843965)'::geometry::geography, 'SRID=4283;POINT(149.386990599235 -26.3567415843982)'::geometry::geography);
comment:4 by , 11 years ago
And noting that the line is small in the absolute sense. The start and end points are extremely close together. I've added tests to cunit but they curiously are not duplicating the error, so I'll have to trace it in the backend.
comment:5 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
PostgreSQL 9.2.4 on x86_64-apple-darwin11.4.2, compiled by Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn), 64-bit