Near Latitide&Longitide; for given postcode |
[eluser]veledrom[/eluser]
Hi, Apologised if not relevant to CI. I am using http://codeigniter.com/wiki/Google_Maps_API_V3_Library for my purposes. Let me explain what I need with an example. I have a postcode NW1 5LR and its LATITUDE:51.546069024064 LONGITUDE:-0.235949008191785 coming from user entry. I also have many other postcodes and their Latitide&Longitide; values in database. What formula should I use to get only those postcodes which are in 1 mil away maximum? Thanks
[eluser]Learn CodeIgniter[/eluser]
You have a whole table full of places with latitude and longitude’s associated with them. Just replace the $lat and $lon with the center point you want to find distances from. You can also change the distance => 1 to a number you want to search from. This will limit your results to all results that are greater then 1 miles from the starting point. You can change the distance for what you need. Code: $sql =
[eluser]veledrom[/eluser]
LOVELY. This works perfectly fine. One more question: What if I want distance in KMs instead of MILEs? Code: SELECT postcode, ((ACOS(SIN('51.546069024064' * PI() / 180) * SIN(latitude * PI() / 180) +
[eluser]veledrom[/eluser]
I don't understand how this query knows that value 1 in HAVING clause represents MILE? Is it really 1 MILE or 1 KM?
[eluser]veledrom[/eluser]
This is in KMs. Code: SELECT |
Welcome Guest, Not a member yet? Register Sign In |