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

LP:1043845 - st_distance() results are incorrect depending on variable order

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      Using MariaDB 5.3.3 on CentOS 6.0

      The st_distance() function returns different results depending on the order of the variables. The results appear to be more accurate when the least complex spatial object is used as the first variable. For instance, st_distance(point, linestring) appears to consistently return accurate results but st_distance(linestring, point) often returns incorrect results depending on the linestring and point data. See below for a specific example.

      As a workaround we have had success using the least complex spatial object first where point < linestring < polygon (from a complexity standpoint).

      select st_distance(geomfromtext('
      LINESTRING(
      -95.9673005697771 36.13509598461,
      -95.9673057475387 36.1344478941074,
      -95.9673063519371 36.134484524621,
      -95.9673049102515 36.1343976584193
      )
      '),geomfromtext('point(-95.96269500000000000000 36.14181833333330000000)'))
      ;
      Result: 0.000574275965624497

      select st_distance(geomfromtext('point(-95.96269500000000000000 36.14181833333330000000)')
      , geomfromtext('
      LINESTRING(
      -95.9673005697771 36.13509598461,
      -95.9673057475387 36.1344478941074,
      -95.9673063519371 36.134484524621,
      -95.9673049102515 36.1343976584193
      )
      '))
      ;
      Result: 0.00791407398682628

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            elenst Elena Stepanova added a comment -

            Re: st_distance() results are incorrect depending on variable order
            Also filed as https://mariadb.atlassian.net/browse/MDEV-499

            Show
            elenst Elena Stepanova added a comment - Re: st_distance() results are incorrect depending on variable order Also filed as https://mariadb.atlassian.net/browse/MDEV-499
            Hide
            holyfoot Alexey Botchkov added a comment -

            Re: st_distance() results are incorrect depending on variable order
            The fix is pushed to the maria/5.3 tree.

            Show
            holyfoot Alexey Botchkov added a comment - Re: st_distance() results are incorrect depending on variable order The fix is pushed to the maria/5.3 tree.
            Hide
            ratzpo Rasmus Johansson added a comment -

            Launchpad bug id: 1043845

            Show
            ratzpo Rasmus Johansson added a comment - Launchpad bug id: 1043845

              People

              • Assignee:
                holyfoot Alexey Botchkov
                Reporter:
                mattwoods Matt Woods
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: