Opened 3 days ago

#5752 new defect

Wrong calculation in geography variant of ST_ClosestPoint()

Reported by: vogg Owned by: pramsey
Priority: high Milestone: PostGIS 3.4.3
Component: postgis Version: 3.4.x
Keywords: Cc: vogg

Description

The geography variant of ST_ClosestPoint() fails to calculate the closest point correctly.

Example query to reproduce this issue:

SELECT ST_AsText(ST_ClosestPoint(
  'LINESTRING (18 9, 18 1)'::geography,
  'POINT (16 4)'::geography
)) AS cp;

Expected result:

 cp
-------------
 POINT(18 4)

Actual result:

 cp
-------------
 POINT(16 4)

When using geometry instead of geography, the calculation of ST_ClosestPoint() works correctly:

SELECT ST_AsText(ST_ClosestPoint(
  'LINESTRING (18 9, 18 1)'::geometry,
  'POINT (16 4)'::geometry
)) AS cp;

Result:

 cp
-------------
 POINT(18 4)

PostgreSQL version:

PostgreSQL 13.15 (Debian 13.15-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit

PostGIS version:

POSTGIS="3.4.2 c19ce56" [EXTENSION] PGSQL="130" GEOS="3.9.0-CAPI-1.16.2" PROJ="7.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.10" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)"

Change History (0)

Note: See TracTickets for help on using tickets.