Bump. Do I just need to learn more about Ruby? :p On Sep 29, 2:47 pm, Mike Ackerman <[email protected]> wrote: > I have a model which belongs_to a "Location" model which contains a > latitude, longitude, and radius. This effectively forms a circular > area that this item covers on the map. > > I'm attempting to filter my results by determining if the point passed > into my geo-search scope lies within my Model's 'Location' area that > it covers. > > I attempted using: > :with => {"@geodist" => 0.0..loc.radius} before I realized that the > location that I'm passing in is a single point and has no radius. > > Instead I need to do some math and figure out if say: > (myPoint.lat - locationModelInstance.lat)^2 + (myPoint.long - > locationModelInstance.long)^2 < locationModelInstance.radius > > Am I able to do math somewhere inside of the sphinx scope? I see in > the documentation that :conditions expects a hash with key/value > pairs... > > I want something like this (but obviously not using conditions b/c i > can't): > sphinx_scope(:falls_within_area) { |loc| > { :geo => [loc.lat.to_radians, loc.lng.to_radians], > :conditions => { (loc.lat - location.lat)^2 + (loc.lng - > location.lng)^2 <= location.radius^2 }, > :order => "@geodist ASC" > } > }
-- You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
