Google maps Ruby Geocoder几乎无法正常工作
使用Alex Reisner的,我有一个模型“Spot”,它是用这个gem进行地理编码的 如果我将第一个点选择到和对象中:Google maps Ruby Geocoder几乎无法正常工作,google-maps,ruby-on-rails-4,ruby-2.0,rails-geocoder,Google Maps,Ruby On Rails 4,Ruby 2.0,Rails Geocoder,使用Alex Reisner的,我有一个模型“Spot”,它是用这个gem进行地理编码的 如果我将第一个点选择到和对象中: s = Spot.first 然后尝试查找10英里半径内的所有点(假设应该有12个),然后我希望Spot.near(s,10)返回一个包含12个点的活动记录对象。相反,每次它都会返回类似的内容: Spot.near(s1,10) => {:select=>"spots.*, AS distance, CAST(DEGREES(ATAN2( RADIANS(
s = Spot.first
然后尝试查找10英里半径内的所有点(假设应该有12个),然后我希望Spot.near(s,10)返回一个包含12个点的活动记录对象。相反,每次它都会返回类似的内容:
Spot.near(s1,10)
=> {:select=>"spots.*, AS distance, CAST(DEGREES(ATAN2( RADIANS(spots.longitude - -6.88671972656243), RADIANS(spots.latitude - 55.1729431175342))) + 360 AS decimal) % 360 AS bearing", :conditions=>["spots.latitude BETWEEN 55.028211334423354 AND 55.31767490064505 AND spots.longitude BETWEEN -7.140145500612388 AND -6.633293952512472 AND <= ?", 10], :order=>"distance ASC"}
我基本上还是没有结果
编辑
我可以使用这个(不漂亮的)添加来执行查询
q = Spot.near(s1,10)
spots = Spot.select(q[:select]).where(q[:conditions]).order(q[:order])
q = Spot.near(s1,10)
spots = Spot.select(q[:select]).where(q[:conditions]).order(q[:order])