Skip to content

Instantly share code, notes, and snippets.

@robozavri
Last active June 23, 2018 10:25
Show Gist options
  • Select an option

  • Save robozavri/e34a4388dc310a79ec4bfdcec2eba5dd to your computer and use it in GitHub Desktop.

Select an option

Save robozavri/e34a4388dc310a79ec4bfdcec2eba5dd to your computer and use it in GitHub Desktop.
php find hotels by coordinate by radius
SELECT * FROM Table1 a
WHERE (
acos(sin(a.Latitude * 0.0175) * sin(YOUR_LATITUDE_X * 0.0175)
+ cos(a.Latitude * 0.0175) * cos(YOUR_LATITUDE_X * 0.0175) *
cos((YOUR_LONGITUDE_Y * 0.0175) - (a.Longitude * 0.0175))
) * 3959 <= YOUR_RADIUS_INMILES
)
//////////////////////////////////////////////////////////////////////////////////////////////////
/*********** for hotels guest houses *****************/
SELECT type,name,town,region,district FROM `object_records` WHERE (
acos(sin(object_records.Lat * 0.0175) * sin(42.24273839 * 0.0175)
+ cos(object_records.Lat * 0.0175) * cos(42.24273839 * 0.0175) *
cos((42.69934396 * 0.0175) - (object_records.Lng * 0.0175))
) * 3959 <= 2
) and lookups_id IN (2,3,4,5,6) and lang = 'GEO'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment