Geodata SQL statements with multiple results in the controller

Hi Everyone-

In my project I need to take a zip code and get all the schools within the selected mile radius of that zip code. In addition I will need to check to see if the user selected any other items to add to the search.

My problem is the geo code will return multiple results and I need to get that result into the final sql string.

The flow is this:

Get the zip code and mile radius the user submitted - then run a query and get all schools within that mile radius of the user's zip code.

Take the results of that query and create a new query with the other options.

The problem is the geo query returns multiple results and I need to access that array in the controller - is this possible by creating a class in the model? How would I access that array in the controller to prepare it for the second sql statement?

Thank you!

Have you looked at any of the geo-location plugins that are kicking around? There’s a (slightly out of date) comparison chart at:

http://foss4r.dyndns.org/trac/wiki/ComparingRailsGeoPlugins

In particular, you might like to check out acts_as_locatable which will allow you to build queries of the form:

School.find_within_radius(1, zip_code)

I wrote some notes on extending that to accept other conditions. You can find my blog entry about it at:

http://jystewart.net/process/2007/02/extending-acts_as_locateable/

James.