Skip to content
Browse files

Merge pull request #5 from ivebeenlinuxed/master

Improve reverse geocode query - thanks Will!
  • Loading branch information...
2 parents c01a7ce + 741a565 commit 732e115afdf07b901f8aa2b9741ee625eb49d2eb @pezholio committed Nov 5, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 postcode.php
View
4 postcode.php
@@ -45,8 +45,8 @@
} else {
$lat = mysql_real_escape_string($_GET['lat']);
$lng = mysql_real_escape_string($_GET['lng']);
- //$result = mysql_query("SELECT postcode, ( 3959 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance FROM postcodes WHERE ".($lat-0.1)." < lat AND ".($lat+0.1)." > lat AND ".($lng-0.1)." < lng AND ".($lng+0.1)." > lng ORDER BY distance LIMIT 0,1");
- $result = mysql_query("SELECT postcode, ( 3959 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance FROM postcodes ORDER BY distance LIMIT 0,1");
+ $result = mysql_query("SELECT postcode, ( 3959 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance FROM postcodes WHERE ".($lat-0.1)." < lat AND ".($lat+0.1)." > lat AND ".($lng-0.1)." < lng AND ".($lng+0.1)." > lng ORDER BY distance LIMIT 0,1");
+ //$result = mysql_query("SELECT postcode, ( 3959 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance FROM postcodes ORDER BY distance LIMIT 0,1");
$row = mysql_fetch_array($result);
$query = "SELECT postcode, lat, lng, easting, northing, postcodes.county AS countygss, counties.county AS countyname, counties.snacid AS countysnac, postcodes.council AS councilgss, councils.snacid AS councilsnac, councils.council AS councilname, postcodes.ward AS wardgss, wards.ward as wardname, wards.snacid as wardsnac, postcodes.constituency AS constituencygss, constituencies.constituency AS constituencyname, constituencies.snacid AS constituencycode, postcodes.parish AS parishgss, parishes.snacid AS parishsnac, parishes.parish AS parishname FROM postcodes LEFT JOIN councils ON postcodes.council = councils.code LEFT JOIN wards ON postcodes.ward = wards.code LEFT JOIN counties ON postcodes.county = counties.code LEFT JOIN constituencies ON postcodes.constituency = constituencies.code LEFT JOIN parishes ON postcodes.parish = parishes.code WHERE postcodes.postcode = '$row[postcode]' LIMIT 0,1";

0 comments on commit 732e115

Please sign in to comment.
Something went wrong with that request. Please try again.