[postgis-tickets] [PostGIS] #4290: bug in Postgis geodetic code impacting distance calculation with geography multipolygon

PostGIS trac at osgeo.org
Thu Jan 10 06:18:17 PST 2019


#4290: bug in Postgis geodetic code impacting distance calculation with geography
multipolygon
---------------------------+---------------------------
  Reporter:  dmkaplan2000  |      Owner:  pramsey
      Type:  defect        |     Status:  new
  Priority:  medium        |  Milestone:  PostGIS 2.5.2
 Component:  postgis       |    Version:  2.4.x
Resolution:                |   Keywords:
---------------------------+---------------------------

Comment (by dmkaplan2000):

 More readable code for error:

 {{{
 CREATE TEMP TABLE tt (gid int PRIMARY KEY, geom geometry);

 \copy tt FROM 'bad_geography_dist_calcs.csv' WITH (FORMAT 'csv',HEADER
 TRUE)

 -- Incorrect dist_geography and dist_geography_tree for t1.gid=1 and
 t2.gid=3
 SELECT t1.gid AS gid1, t2.gid AS gid2,
        ST_Distance(t1.geom,t2.geom) AS dist_lonlat,
        ST_Distance(ST_Transform(t1.geom,26918),
                    ST_Transform(t2.geom,26918)) AS dist_utm,
        ST_Distance(t1.geom::geography,t2.geom::geography) AS
 dist_geography,
        _ST_DistanceTree(t1.geom::geography,t2.geom::geography) AS
 dist_geography_tree,
        _ST_DistanceUncached(t1.geom::geography,t2.geom::geography) AS
 dist_geography_uncached,
 ST_Distance((ST_Dump(t1.geom)).geom::geography,(ST_Dump(t2.geom)).geom::geography)
 AS dist_geography_dump
 FROM tt t1 JOIN tt t2 ON t1.gid<t2.gid
 WHERE t1.gid=1
 ;

 -- No error for postgis 2.4.3, but error for 2.5.0
 SELECT t1.gid AS gid1, t2.gid AS gid2,
        ST_Distance(t1.geom,t2.geom) AS dist_lonlat,
        ST_Distance(ST_Transform(t1.geom,26918),
                    ST_Transform(t2.geom,26918)) AS dist_utm,
        ST_Distance(t1.geom::geography,t2.geom::geography) AS
 dist_geography,
        _ST_DistanceTree(t1.geom::geography,t2.geom::geography) AS
 dist_geography_tree,
        _ST_DistanceUncached(t1.geom::geography,t2.geom::geography) AS
 dist_geography_uncached,
 ST_Distance((ST_Dump(t1.geom)).geom::geography,(ST_Dump(t2.geom)).geom::geography)
 AS dist_geography_dump
 FROM tt t1 JOIN tt t2 ON t1.gid<t2.gid
 WHERE t1.gid=1 AND t2.gid=3
 ;
 }}}

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4290#comment:1>
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