Opened 12 months ago

Closed 11 months ago

Last modified 11 months ago

#5604 closed defect (fixed)

ST_Distance doesn't return the minimum distance of two geometries.

Reported by: Wenjing Owned by: pramsey
Priority: medium Milestone: PostGIS 3.4.2
Component: postgis Version: 3.4.x
Keywords: Cc:

Description

Consider this statement:

SELECT ST_Distance(a2, a1), ST_Distance(a1, a2)
FROM ST_GeomFromText('MULTIPOINT((-2 0), EMPTY)') As a1
,ST_GeomFromText(' GEOMETRYCOLLECTION(POINT(1 0),LINESTRING(0 0,1 0))') As a2;
--actual{3,2}
--expected{2,2}

According to the following definition, ST_Distance returns the minimum distance between two geometries :

returns the minimum 2D Cartesian (planar) distance between two geometries

Therefore, the result of ST_Distance(a2, a1) should be the same as ST_Distance(a1, a2) which is 2. However, ST_Distance(a2, a1) returns 3, which seems to be a bug.

Version:

POSTGIS="3.5.0dev 3.4.0rc1-748-gaedf3b14f" [EXTENSION] PGSQL="170" GEOS="3.13.0dev-CAPI-1.18.0" PROJ="8.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/tmp/proj DATABASE_PATH=/usr/share/proj/proj.db" LIBXML="2.9.13"

Change History (9)

comment:1 by robe, 12 months ago

Milestone: PostGIS 3.4.1PostGIS 3.4.2

comment:2 by pramsey, 11 months ago

Simple reproducer

SELECT ST_Distance(
  'MULTIPOINT((1 0),(0 0))'::geometry,
  'MULTIPOINT((-2 0), EMPTY)'::geometry
);

comment:3 by Paul Ramsey <pramsey@…>, 11 months ago

In c1dbf8e/git:

Correctly handle distances between collections with empty elements, references #5604

comment:4 by Paul Ramsey <pramsey@…>, 11 months ago

In 63b123db/git:

Correctly handle distances between collections with empty elements, references #5604

comment:5 by Paul Ramsey <pramsey@…>, 11 months ago

In e5dec40/git:

Correctly handle distances between collections with empty elements, references #5604

comment:6 by Paul Ramsey <pramsey@…>, 11 months ago

In 61ce8ba/git:

Correctly handle distances between collections with empty elements, references #5604

comment:7 by pramsey, 11 months ago

Resolution: fixed
Status: newclosed

comment:8 by Paul Ramsey <pramsey@…>, 11 months ago

In 78414fa/git:

Correctly handle distances between collections with empty elements, references #5604

comment:9 by Paul Ramsey <pramsey@…>, 11 months ago

In f45df01/git:

Correctly handle distances between collections with empty elements, references #5604

Note: See TracTickets for help on using tickets.