Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 11.8.6, 11.8.8
-
MariaDB Community Server 11.8.6, 11.8.8 and 12.3.2
Operating system: Win64 and AMD64
Architecture: x64
-
Unexpected results
Description
ST_Distance() returns an incorrect result when calculating the Cartesian distance between a POINT and a LINESTRING containing multiple segments.
Adding a segment to a LINESTRING causes the reported minimum distance to increase, even though the original segment remains part of the resulting LINESTRING.
The distance between a geometry and a superset of that geometry cannot be greater than the distance to the original geometry.
How to reproduce
Run the following standalone query:
SELECT
|
ST_Distance(
|
ST_GeomFromText('POINT(5 5)'), |
ST_GeomFromText('LINESTRING(4 6,6 5)') |
) AS distance1, |
ST_Distance(
|
ST_GeomFromText('POINT(5 5)'), |
ST_GeomFromText('LINESTRING(4 6,6 5,6 6)') |
) AS distance2; |
|
Actual Result |
+--------------------+-----------+
|
| distance1 | distance2 |
|
+--------------------+-----------+
|
| 0.4472135954999579 | 1 |
|
+--------------------+-----------+
|
|
Expected result |
+--------------------+--------------------+
|
| distance1 | distance2 |
|
+--------------------+--------------------+
|
| 0.4472135954999579 | 0.4472135954999579 |
|
+--------------------+--------------------+
|