PHP/MySQL: Select locations close to a given location from DB

后端 未结 7 1555
隐瞒了意图╮
隐瞒了意图╮ 2021-02-02 03:15

In PHP, I have the following code for calculating the distance between two locations:



        
7条回答
  •  花落未央
    2021-02-02 03:51

    MySQL Great Circle Distance (Haversine formula) does exactly what you need.

    With only 200 records however you may as well just load them all and check them with code. The data set is really way too small to be worrying too much about database vs code or any other such optimizations.

    Calculating distance between zip codes in PHP has a couple of PHP implementations of this algorithm.

    Geo Proximity Search is pretty much the exact same problem you have.

提交回复
热议问题