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

Feature request: Support for ST_Distance_Sphere()

Details

    Description

      Spatial Convenience Function:

      This function does not exist in any version of MariaDB but does on MySQL 5.7+ and is critical for spatial conversions. ST_Distance_Sphere makes use for calculating the distance of coordinates from points.

      For more information reference MySQL's documentation directly at:
      https://dev.mysql.com/doc/refman/5.7/en/spatial-convenience-functions.html

      Source Code Reference (thanks to Daniel Black for the commit number):
      https://github.com/mysql/mysql-server/commit/60e7f702ac3929c0e38afa7e6dd75fcd5a54c6a9

      Attachments

        Issue Links

          Activity

            Hi,

            Are there any news on implementing this feature?

            Thanks

            cyBerManIA Dusan Dzurdzic added a comment - Hi, Are there any news on implementing this feature? Thanks

            I am waiting for this one too !

            Aurelien_LEQUOY Aurélien LEQUOY added a comment - I am waiting for this one too !

            Is it possible to give some broad ETA like weeks, months, years? For one of our project this is show stopper. We need to decide next step and without at least idea about "when" we would have to switch back to MySQL

            Thanks

            kepi Ondra KudlĂ­k added a comment - Is it possible to give some broad ETA like weeks, months, years? For one of our project this is show stopper. We need to decide next step and without at least idea about "when" we would have to switch back to MySQL Thanks

            about ST_Distance_Sphere, we can add function witch do this but without index

            Aurelien_LEQUOY Aurélien LEQUOY added a comment - about ST_Distance_Sphere, we can add function witch do this but without index
            danblack Daniel Black added a comment -

            lots of voters and watchers. Anyone want to get their hands dirty with C/C++ and merge MySQL's implementation into MariaDB? There are a few differences so its a little more than a quick cherr-pic. Commit 60e7f702ac3929c0e38afa7e6dd75fcd5a54c6a9 and others from MySQL.

            danblack Daniel Black added a comment - lots of voters and watchers. Anyone want to get their hands dirty with C/C++ and merge MySQL's implementation into MariaDB? There are a few differences so its a little more than a quick cherr-pic. Commit 60e7f702ac3929c0e38afa7e6dd75fcd5a54c6a9 and others from MySQL.
            TEL Tom Lahey added a comment -

            Another request for an update on this feature. We rely heavily on this feature. Currently running two DB's to support it MySql for spacial, MariaDB for everything else which is a pain. May need to switch to all MySql if this feature is not included soon.

            TEL Tom Lahey added a comment - Another request for an update on this feature. We rely heavily on this feature. Currently running two DB's to support it MySql for spacial, MariaDB for everything else which is a pain. May need to switch to all MySql if this feature is not included soon.
            bhelm Bernd Helm added a comment -

            Required this feature for a project and switching now to mysql 8.0 only because of this.

            Please fix.

            bhelm Bernd Helm added a comment - Required this feature for a project and switching now to mysql 8.0 only because of this. Please fix.
            morrow95 Steve added a comment -

            Another vote from me. Been waiting on these functions for awhile now only to find this one in particular isn't offered. If I had known before starting the project I would have went with mysql purely based on this as we have some ideas in mind which need better spatial support to do them.

            morrow95 Steve added a comment - Another vote from me. Been waiting on these functions for awhile now only to find this one in particular isn't offered. If I had known before starting the project I would have went with mysql purely based on this as we have some ideas in mind which need better spatial support to do them.

            Would be badly needed ... were already forced to switch some Customer VMs to MySQL because of this missing Feature ... :-/

            Futureweb Andreas Schnederle-Wagner added a comment - Would be badly needed ... were already forced to switch some Customer VMs to MySQL because of this missing Feature ... :-/
            kylemcnally Kyle McNally added a comment -

            Would love if this got added soon. Having to hack around and use ST_CONTAINS is annoying

            kylemcnally Kyle McNally added a comment - Would love if this got added soon. Having to hack around and use ST_CONTAINS is annoying

            Issue almost 3 years old and still nothing? Isn't there anyone capable of implementing this Feature?

            Futureweb Andreas Schnederle-Wagner added a comment - Issue almost 3 years old and still nothing? Isn't there anyone capable of implementing this Feature?

            Here is an equivalent of the function in MariaDB: https://stackoverflow.com/a/56669074/4458956

            JuanPCH Juan Poma Chavez added a comment - Here is an equivalent of the function in MariaDB: https://stackoverflow.com/a/56669074/4458956
            robin850 Robin Dupret added a comment -

            @Anel Husakovic : Hello, I took the liberty to work on this feature a few days ago as there was nobody assigned to it. Is this something you are actively working on or just assigning it to yourself for the future ? Maybe I can share what I already have if it can be helpful.

            robin850 Robin Dupret added a comment - @Anel Husakovic : Hello, I took the liberty to work on this feature a few days ago as there was nobody assigned to it. Is this something you are actively working on or just assigning it to yourself for the future ? Maybe I can share what I already have if it can be helpful.

            Hi robin850 yes I have done some patch 55c0b1c99ccfcc41caa, you can take a look.
            It is in review currently so I will change it.

            anel Anel Husakovic added a comment - Hi robin850 yes I have done some patch 55c0b1c99ccfcc41caa , you can take a look. It is in review currently so I will change it.
            robin850 Robin Dupret added a comment -

            @anel: Oh, the good news is, I wouldn't have been able to write such patch.

            I took the liberty to leave some comments in your commit on GitHub.

            But, IIUC, currently there are two differences with the MySQL implementation:

            • If the two geometries aren't in the same SRS, nothing is raised.
            • The SRID attached with a geometry is ignored to define the radius ; you either pass an argument or the earth's radius is implied. MySQL defines the default value based on the based on the geometry's SRS.
            robin850 Robin Dupret added a comment - @anel: Oh, the good news is, I wouldn't have been able to write such patch. I took the liberty to leave some comments in your commit on GitHub. But, IIUC, currently there are two differences with the MySQL implementation: If the two geometries aren't in the same SRS, nothing is raised. The SRID attached with a geometry is ignored to define the radius ; you either pass an argument or the earth's radius is implied. MySQL defines the default value based on the based on the geometry's SRS .

            robin850 great thanks will take a look into your comments after review process.
            Exactly, those comments are explained in the code and after review we will update everything accordingly.
            Try to test and let us know how we can help further .

            anel Anel Husakovic added a comment - robin850 great thanks will take a look into your comments after review process. Exactly, those comments are explained in the code and after review we will update everything accordingly. Try to test and let us know how we can help further .

            danblack and robin850 thanks for the review of the previous patch-55c0b1c99.
            Here is the new patch to review 66454ee564cfb
            Here are examples from MySQL dbfiddle
            And here are list of all tests that patch passed:

            subselect_gis.test gis.test gis-precise.test gis_notembedded.test gis-rt-precise.test sp_gis.test gis-rtree.test gis-debug.test gis-alter_table_online.test archive_gis.test rpl_fail_register.test innodb_gis.test maria-gis-rtree-trans.test maria-gis-recovery.test maria-gis-rtree.test maria-gis-rtree-dynamic.test
            

            Thanks

            anel Anel Husakovic added a comment - danblack and robin850 thanks for the review of the previous patch-55c0b1c99 . Here is the new patch to review 66454ee564cfb Here are examples from MySQL dbfiddle And here are list of all tests that patch passed: subselect_gis.test gis.test gis-precise.test gis_notembedded.test gis-rt-precise.test sp_gis.test gis-rtree.test gis-debug.test gis-alter_table_online.test archive_gis.test rpl_fail_register.test innodb_gis.test maria-gis-rtree-trans.test maria-gis-recovery.test maria-gis-rtree.test maria-gis-rtree-dynamic.test Thanks

            Hello.
            I'm not a pro programmer, so please forgive any naive question.
            I am just converting from MySQL 5.7 to MariaDB 10.3 because our host requires us to really.
            I use ST_DISTANCE_SPHERE() so I am naturally interested to know approximately when your work will be available ?
            Is it possible (and relatively easy) for me to apply a patch to our 10.3 so I can use the function before it is available in a later version ?
            Many thanks.

            mikemcc Mike McCutcheon added a comment - Hello. I'm not a pro programmer, so please forgive any naive question. I am just converting from MySQL 5.7 to MariaDB 10.3 because our host requires us to really. I use ST_DISTANCE_SPHERE() so I am naturally interested to know approximately when your work will be available ? Is it possible (and relatively easy) for me to apply a patch to our 10.3 so I can use the function before it is available in a later version ? Many thanks.
            bhelm Bernd Helm added a comment -

            This feature is critical for all projects that work with lon/lat gps coordinates. The most basic usecase is to find rows in a database table that are close to a users location like other users nearby, the nearest store, the nearest gas station and so on.
            For performance and accuracy reasons, this has to be a native function.

            As soon as a requirement like this pops up, we have to migrate everything to mysql 8.0 which is sad.

            I hope the stale status does not mean that it will take some more years for this feature to become merged.

            bhelm Bernd Helm added a comment - This feature is critical for all projects that work with lon/lat gps coordinates. The most basic usecase is to find rows in a database table that are close to a users location like other users nearby, the nearest store, the nearest gas station and so on. For performance and accuracy reasons, this has to be a native function. As soon as a requirement like this pops up, we have to migrate everything to mysql 8.0 which is sad. I hope the stale status does not mean that it will take some more years for this feature to become merged.

            Hi mikemcc, bhelm ,
            stall means (at least for this feature that had some work done already), that the review (that was before) is finished and some corrections are needed.
            Work was done on 10.1 and needs to be rebased on 10.2 and merged all way to the 10.6 and some fine tuning of code and tests has to be done.
            So this feature will be finished/pushed soon.

            anel Anel Husakovic added a comment - Hi mikemcc , bhelm , stall means (at least for this feature that had some work done already), that the review (that was before) is finished and some corrections are needed. Work was done on 10.1 and needs to be rebased on 10.2 and merged all way to the 10.6 and some fine tuning of code and tests has to be done. So this feature will be finished/pushed soon.
            bhelm Bernd Helm added a comment -

            Glad to hear! Thank you for your Work to make this happen!

            bhelm Bernd Helm added a comment - Glad to hear! Thank you for your Work to make this happen!

            �

            mikemcc Mike McCutcheon added a comment - �

            Pushed with 6769d1a0782f140dcd12c to 10.2 after passing protected branch.
            Will be merged soon to 10.3+.

            anel Anel Husakovic added a comment - Pushed with 6769d1a0782f140dcd12c to 10.2 after passing protected branch . Will be merged soon to 10.3+ .
            robin850 Robin Dupret added a comment -

            Thank you very much for working on this Anel ; really glad to see that feature in MariaDB, great addition. (And thanks for the credit in the commit.)

            robin850 Robin Dupret added a comment - Thank you very much for working on this Anel ; really glad to see that feature in MariaDB, great addition. (And thanks for the credit in the commit.)
            Yi Yang Yi Yang added a comment - - edited

            I believe this might be causing a regression of MDEV-12462

            I have a CI running some ST_WITHIN() based address lookup, something like

            SELECT * FROM ST_WITHIN(@point, @polygon);
            

            was working fine in 10.4.18, but is not working in 10.4.19, returning empty result (the point is within the polygon).

            In 10.4.19 you have to use something like

            SELECT * FROM ST_WITHIN(@point, @polygon) = 1;
            

            or drop the index, to get the correct result.

            Can someone reopen the old issue or create a new issue and fix it?

            Yi Yang Yi Yang added a comment - - edited I believe this might be causing a regression of MDEV-12462 I have a CI running some ST_WITHIN() based address lookup, something like SELECT * FROM ST_WITHIN(@point, @polygon); was working fine in 10.4.18, but is not working in 10.4.19, returning empty result (the point is within the polygon). In 10.4.19 you have to use something like SELECT * FROM ST_WITHIN(@point, @polygon) = 1; or drop the index, to get the correct result. Can someone reopen the old issue or create a new issue and fix it?

            People

              anel Anel Husakovic
              tfont Travis van der Font
              Votes:
              29 Vote for this issue
              Watchers:
              33 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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