I am going to create a function in my last project, preferably using PHP. When each user signs up, they are about to enter their zip code. Then, hopefully, I will convert this to lat / long using the Open Street Map.
In any case, I want to know other users who are close to the current user. I have seen many people using the Haversin formula, however this would mean that the user requested all other user data to determine the distance. I could cache this, but it will soon become obsolete when new users arrive.
How will the following query be executed on my system?
sql = "SELECT zipcode, ( 3959 * acos( cos( radians( {$coords['latitude']} ) )
* cos( radians( latitude ) ) * cos( radians( longitude )
- radians( {$coords['longitude']} ) )
+ sin( radians( {$coords['latitude']} ) ) * sin( radians( latitude ) ) ) )
AS distance FROM zipcodes HAVING distance <= {$radius} ORDER BY distance";
What pulled from someone’s blog.
I do not have any numbers for the registration speed or the number of users who are still under development.
I would appreciate any feedback or other methods that I could use to find suitable users within a certain radius.
user140291
source
share