php/mysql zip code proximity search

前端 未结 7 1956
南笙
南笙 2020-12-02 15:08

I\'m just looking for suggestions on the best way to do this...

I need to create a search function that searches for \"users\" within a 50 mile radius of a zip code

相关标签:
7条回答
  • 2020-12-02 15:34

    I'd consider reducing the number of candidates with a bounding square first, then worrying about the radius as a second step. You start off with the coordinates of the zipcode, then calculate the long/lat of 50 miles in all 4 directions, then select only candidates within that box using simple greater/less than criteria. If your user base is well spread out this reduces your candidate set considerably, then you only have to do vector distance math to eliminate the "corners".

    0 讨论(0)
提交回复
热议问题