3

I am working on a dating application in PHP: My application has a search page that searches suitable user profiles within certain distance of a person's location (need to specify the no. of miles/kms to search for).

I understand the logic to implement this (ref: Get nearest places on Google Maps, using MySQL spatial data), just not sure where I can get the database that stores the geographical position of each location from around the world. Is this available for free? Would be interested to check out the premium version as well if available.

Also concerned about the query search speeds. Searching across such a huge database is going to cost some overhead, what is the best way to tackle this?

Any suggestions highly appreciated.

Best regards, Seniel

Community
  • 1
  • 1
Sunil Silumala
  • 917
  • 5
  • 22
  • 1
    You need to have the data you're searching for. Meaning in your app, your user profiles need to be updated with geodata. – Khez Apr 05 '11 at 13:22
  • See the answers to questions 2283689 and 98449. They have information on where to find geocoders. Note that the free commercial ones (Google, Yahoo, Microsoft) all have some strings in their license agreement, such as must be used in conjunction with displaying maps and can't store the results for other purposes. That might still meet your needs (I think with some of these you can store the data for use in a map, but check the particular licensing terms to be sure). You'd want to store the lat/lon for each entry, not re-look each time. – ViennaMike Apr 05 '11 at 13:47

1 Answers1

1

It sounds very simple ... you ask the user for his address and then request google maps api for the longtitude and latitude like this

http://maps.googleapis.com/maps/api/geocode/json?address=San+Stefano+1+Sofia&sensor=false

and write them in the database.

When the user searchest for nearby people

edit (not going to be a circle, but it will do the job):

SELECT * FROM `users` AS u
WHERE u.lat IS BETWEEN {$my_lat-100} AND {$my_lat+100}
AND u.alt IS BETWEEN {$my_alt-100} AND {$my_lat+100}

like in the post you've mentioned.

Teneff
  • 30,564
  • 13
  • 72
  • 103