Storing geographical locations in Django/MySQL model, and querying based on proximity

We're trying to make an iOS app that allows users to create geographical points of interest on a map. We are currently evaluating whether we can use Django/MySQL as a backend for the app.

When the app asks our server for 'points' we only want to return those that are within 5km of the user. Thus we need some way of storing the latitude & longitude in the database model and then being able to query the database for points near the users co-ordinates.

E.g. in pseudo code:

SELECT Point FROM Database,
WHERE Point IS WITHIN 5KM OF [LATITUDE]-[LONGITUDE]

Can this be done with Django and MySQL?

Answers


You can find a VERY good answer to your question here: SQL abs calculation - using latitudes and longitudes - MATH!

Also if you search a bit more, you probably will find another gazilion answers to how to calculate abs using sql.


Need Your Help

How to Access Sitecore Lucene Search through the Item Web API?

lucene sitecore lucene.net sitecore6

Is it possible to use Lucene Search in Sitecore and have the results returned as JSON by the Sitecore Item Web API?

Run Rspec test block conditionaly based on gem config

ruby-on-rails ruby rspec config

I'm trying to add write a rspec test that is dependent on what the gem user has set as a configuration. So i want to run the test with a certain configuration.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.