Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SELECT * FROM postcodelatlng  WHERE ( 3958 * 3.1415926 * sqrt( (latitude - '.$lat.') * (latitude - '.$lat.') + cos(latitude/57.29578) * cos('.$lat.'/57.29578) * (longitude-'.$lon.') * (longitude-'.$lon.') ) / 180 ) <= '.$radius.';'


this query is working perfectly fine .but i dont get the formula .how is it working . can anyone kindly explain this formula or can share any reference link where i find this . (Note : this question is asked after investing alot of time to find the explanation of this formula ).

What I have tried:

formula is working perfectly fine . but needs explanation
Posted
Updated 26-May-22 0:07am

1 solution

Quote:
this query is working perfectly fine .but i dont get the formula .how is it working .

For distance between 2 point on earth, the answer is 'great circle formula'
Great circle - Wikipedia[^]
Great-circle distance - Wikipedia[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900