I am creating an application with Geo Proximity Search capability using PHP as server scripting language and MySQL as Databse.
Consider a situation:
Where we have certain set of objects having latitude and longitude positions assosciated with respective objects. On specifying location details like country and/or city along with range/radius in KM we are getting objects that are lying withing that radius/range using MySQL query for example:
"SELECT [columns] FROM [column] WHERE 1=1 AND 3963.191 * ACOS((SIN(PI() * [latitude] / 180) * SIN(PI() * [column].latitude / 180)) + (COS(PI() * [latitude] /180) * cos(PI() * [column].latitude / 180) * COS(PI() * [column].longitude / 180 - PI() * [longitude] / 180)) ) <= 10"
Above calculations will give the objects that are within the 10 KM area from the country/city center point on earth.
Now suppose i have one object (with latitude and longitude) which is not in this 10 KM area, but for example 15 KM from the country/city center point on earth. This object has service range 10 KM (giving service upto 10 KM area).
Now the question is if i am looking for the objects within the 10 KM range from country/city center point then the object (15 KM apart from country/city center point) having service range 10 KM should also be included in search.
How can i make it possible? I have country/city center lat, long coordinates,range/radius(in which we have to find out objects) and object having delivery radius (for e.g.10 KM) and its corresponding coordinates.
Can you guide me how to do that using PHP, MySQL?