I just looked at the plugin... it's not very good.  It calculates
distance after it pulls the results from the DB.  The DB is gonna be
allot better at doing those calculations and sorting the results.
Ofcourse this means you're gonna need to write some custom SQL that is
most likely specific to the DB engine, but it's well worth the
performance increase.  I've done this with mysql, there are plenty of
ways to do it but this is what I've used in the past:

ROUND( degrees( acos( sin( radians( latitude ) ) * sin( radians(
[EMAIL PROTECTED] ) ) + cos( radians( latitude ) ) * cos( radians(
[EMAIL PROTECTED] ) ) * cos( radians( longitude - [EMAIL PROTECTED] ) ) ) ) *69,
1 ) AS distance

This gives you a pretty accurate distance (accounting for the earth's
curvature).  But if pin-point accuracy isn't a big issue, you could
just calculate the distance between two points and simplify the
equation quite a bit.

There's my two cents

Chris

On 10/31/06, Patrick Crowley <[EMAIL PROTECTED]> wrote:
This just popped up on the Rails plugin site....

> ZipCodeSearch is a Rails plugin that makes implementing location-
> based searches a cinch. If you've ever wondered how to do location-
> based radius searches in your snazzy new Web 2.0 application, then
> this plugin might save you some time.
>
> http://zipcodesearch.rubyforge.org/

Groovy!

Patrick




_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

Reply via email to