-2

I currently have the users longitude and latitude and will show rows in my database from other offers where the radius is 150 meter example.

How can i make this? Each offer has latitude and longitude also.

I am really confused if this can be possible.

Please some expert help me.

 $o->prepare("offers",array(
    "longtitude" => "10.2039494", 
    "latitude"   => "55.203949",
    "radius"     => 150 //in meters
 )
 );

Prepare should make some kind of MySQL query that shows offers in the radius from the users latitude and longitude for 150 meter (or 2km, i should be available to change this?). Example (OFFERS IN DATABASE WITH LONG AND LATITUDE)

 '55.395591', '10.385513'
 '55.395554', '10.385208'

I am really stuck from here

jesper
  • 15
  • 6
  • How about giving this http://dev.mysql.com/doc/refman/5.0/en/spatial-extensions.html a try? – Smuuf Aug 29 '13 at 17:06

1 Answers1

0

Calculating a rough distance or more exact distance between two long / lat points (straight line distance that is) is pretty straight forward math and you can find a ton of examples by searching e.g.: http://www.movable-type.co.uk/scripts/latlong.html

Note this will not be routable (driving/walking) distance for which you must leverage something like Google Maps.

Matthew
  • 9,851
  • 4
  • 46
  • 77
  • Ok thanks for answer, i am really bad as math, so that was why i asked the question to hope someone could help me out. – jesper Aug 29 '13 at 16:58
  • @jesper Also very searchable: http://stackoverflow.com/questions/1006654/fastest-way-to-find-distance-between-two-lat-long-points http://stackoverflow.com/questions/2234204/latitude-longitude-find-nearest-latitude-longitude-complex-sql-or-complex-calc – Matthew Aug 29 '13 at 17:04