Opened 4 years ago

Closed 4 years ago

#2636 closed defect (fixed)

Regress ST_Distance_Sphere between 2.1.2dev and 2.0.4 with 2D

Reported by: robe Owned by: pramsey
Priority: critical Milestone: PostGIS 2.1.2
Component: postgis Version: 2.1.x
Keywords: Cc:

Description

Even though this is probably related to #2634 the use_spheroid issue, I'm ticketing it separetely since it involves 2 2D geometries.

CREATE TABLE test_geoms(gid integer, geom geometry);
INSERT INTO test_geoms(gid, geom )
 VALUES (1, ST_GeomFromText('POLYGON((-9.1111111 40,-9.14954053919354 39.6098193559677,-9.26335203497743 39.2346331352698,-9.44817187539491 38.8888595339608,-9.6968975376269 38.5857864376269,-9.99997063396079 38.3370607753949,-10.3457442352698 38.1522409349774,-10.7209304559677 38.0384294391935,-11.1111111 38,-11.5012917440323 38.0384294391935,-11.8764779647302 38.1522409349774,-12.2222515660392 38.3370607753949,-12.5253246623731 38.5857864376269,-12.7740503246051 38.8888595339608,-12.9588701650226 39.2346331352698,-13.0726816608065 39.6098193559677,-13.1111111 40,-13.0726816608065 40.3901806440322,-12.9588701650226 40.7653668647302,-12.7740503246051 41.1111404660392,-12.5253246623731 41.4142135623731,-12.2222515660392 41.6629392246051,-11.8764779647302 41.8477590650226,-11.5012917440323 41.9615705608065,-11.1111111 42,-10.7209304559678 41.9615705608065,-10.3457442352698 41.8477590650226,-9.9999706339608 41.6629392246051,-9.69689753762691 41.4142135623731,-9.44817187539491 41.1111404660392,-9.26335203497743 40.7653668647302,-9.14954053919354 40.3901806440323,-9.1111111 40))') )
,
(2, ST_GeomFromText( 'LINESTRING(-11.1111111 70,70 -11.1111111)' )  );

Testing on 2.1.2 dev I used this test: POSTGIS="2.1.2dev r12220" GEOS="3.4.2-CAPI-1.8.2 r0" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.10.0, released 2013/04/24" LIBXML="2.7.8" LIBJSON="UNKNOWN" RASTER PostgreSQL 9.2.4, compiled by Visual C++ build 1600, 32-bit

SELECT g1.gid As g1_gid, g2.gid As g2_gid, ST_Distance_Sphere(g1.geom, g2.geom) As dist_sphere, 
   _ST_DistanceUncached(g1.geom::geography, g2.geom::geography, false)
   , _ST_DistanceTree(g1.geom::geography, g2.geom::geography) As tree
FROM test_geoms g1 , test_geoms g2;


Which output:

 g1_gid | g2_gid |     dist_sp      |    dist_sp_un    |       tree
--------+--------+------------------+------------------+------------------
      1 |      1 |                0 |                0 |                0
      1 |      2 | 3038483.94086444 | 3034456.86712422 | 3038459.08820272
      2 |      1 | 3034456.86712422 | 3034456.86712422 | 3038459.08820272
      2 |      2 |                0 |                0 |                0
(4 rows)

Testing on 2.0 POSTGIS="2.0.4" GEOS="3.4.2-CAPI-1.8.2 r0" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.10.0, released 2013/04/24" LIBXML="2.7.8" LIBJSON="UNKNOWN" (core procs from "2.0.4" need upgrade) RASTER (raster procs from "2.0.4" need upgrade) PostgreSQL 9.2.4, compiled by Visual C++ build 1600, 32-bit

SELECT g1.gid As g1_gid, g2.gid As g2_gid, ST_Distance_Sphere(g1.geom, g2.geom) As dist_sphere, 
   ST_Distance(g1.geom::geography, g2.geom::geography) As dist_spheroid
FROM test_geoms g1 , test_geoms g2;

 g1_gid | g2_gid |   dist_sphere    |  dist_spheroid
--------+--------+------------------+------------------
      1 |      1 |                0 |                0
      1 |      2 | 3034456.86712422 | 3038459.08820272
      2 |      1 | 3034456.86712422 | 3038459.08820272
      2 |      2 |                0 |                0
(4 rows)

Have no idea where that 3038483.94086444 is coming from in the 2.1.1

Change History (2)

comment:1 Changed 4 years ago by robe

Summary: Regress ST_Distance_Sphere between 2.1.2dev and 2.0.4Regress ST_Distance_Sphere between 2.1.2dev and 2.0.4 with 2D

comment:2 Changed 4 years ago by pramsey

Resolution: fixed
Status: newclosed

Fixed, properly with it's friends, at r12307, in both 2.1 and trunk.

Note: See TracTickets for help on using tickets.