Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-40524

ST_Distance returns incorrect minimum distance between a Point and a multi-segment LineString

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3, 11.8.6, 11.8.8
    • 10.11, 11.4, 11.8, 12.3
    • GIS
    • 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 |
      +--------------------+--------------------+
      

      Attachments

        Activity

          People

            rucha174 Rucha Deodhar
            uri2x Uri Hartmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.