Location Database help!

Associate
Joined
25 Aug 2008
Posts
947
Hi,

I am creating a site that uses location data. The easiest way to make it consistant around the globe would be by the use of lat/long details - but I would like to incorporate a worldwide postcode format if possible as well.

I will try to raise my concern as an example(not related to my site).

Lets say my mobile gives the site my lat/lon details, and I want to know all the indian takeaways in a 1km radius.

I could setup a calculation in my SQL statement to pull back results, but thats a lot of calculations - especially if the database has thousands of entries.

So to speed this up, I could for example create a box around my location 2km by 2km. That way I could say if a<lattitude<b and c<longitude<d then display results. Results not so accurate, but that should prove a faster search right? With a lot of users this would still slow the server - so could I make this faster again?

Accuracy is not so much my concern here.

My only thought of making this any faster, would be to 'grid' up the globe, on a variety of scales. I could then say my current location is in grid box A, I want to search a distance of Y, so my search results should return all entries in grid boxes ....

Does this seem feesible? To speed things up, I think I could have a database that stores say grid box A, and then has a subset of grid boxes to include, based on a search of distances 1k/5k/10k/25k/50k and so on.

Would this be faster, and require less use of the server? The onlything I am not sure about then would be the space required in the database.
 
Associate
OP
Joined
25 Aug 2008
Posts
947
At the equator, Earth's circumference is 24,901.55 miles (40,075.16 km). It is slightly smaller between the North and South poles at 24,859.82 miles (40,008 km). Earth's diameter at the poles is 7,899.80 miles (12,713.5 km) while it is 7,926.28 miles (12,756.1 km) at the equator.
 
Associate
OP
Joined
25 Aug 2008
Posts
947
Thanks for the comments.

cats_five - I want to avoid calculations for every user as much as possible, a spacial index does sound what I am looking for.
D.P - I eventually expect to hold hundred of thousands of entries in a database, I dont think having to recalculate each time would be a good idea.

I need to think of the spacial index more - I might start limiting the location details to say LAT/LONG/AREA/TOWN/REGION/COUNTRY.

The zoom level on the map might help with choosing the field to use to reduce the results.
 
Back
Top Bottom