user3354485 user3354485 - 4 months ago 12
MySQL Question

How to find latitude and longitude lies within radius?

I have latitude and longitude of place. How to find these latitude and longitude lies within some other locations radius?

for example having (6.8914,79.8522) (lat,long) of location,and find within location (6.9584218,80.1783008) of radius 10.

please help me.

Answer
lat1 = 6.8914 # latitude of point 1
long1 = 79.8522 # longitude of point 1
lat2 = 6.9584218 # latitude of point 2
long2 = 80.1783008 # longitude of point 2

if distance between two geographical points < 10:
   point2 lies inside radius
else:
   it doesn't

You may seek idea how to calculate distance between two geographical points and the programmatical implementation by using Haversine Formula here.