Module: SdbDal::Geo::Locatable
- Defined in:
- lib/sdb_dal/geo.rb
Overview
mixin locatable object must have latitude, longitude and address attributes
Instance Method Summary collapse
- #find_near(loc, zoom_level = 7, order_by = nil, order = :ascending) ⇒ Object
- #get_nearby(zoom_level = 7, order = nil) ⇒ Object
- #location ⇒ Object
Instance Method Details
#find_near(loc, zoom_level = 7, order_by = nil, order = :ascending) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/sdb_dal/geo.rb', line 169 def find_near(loc,zoom_level=7,order_by=nil,order=:ascending) nearby= loc.get_nearby_addresses(zoom_level) address_params=[] for address in nearby address_params<<StartsWithCondition.new(self.AttributeDescription(:address),address) end orCondition=OrCondition.new(address_params) return find(:all,:limit => 24,:order_by => order_by,:order => order,:conditions=>[orCondition]) end |
#get_nearby(zoom_level = 7, order = nil) ⇒ Object
160 161 162 163 164 165 166 167 |
# File 'lib/sdb_dal/geo.rb', line 160 def get_nearby(zoom_level=7,order=nil) if latitude==nil or longitude==nil return [] end result= self.class.find_near(self.location,zoom_level,order) result.delete_if{|item|item.id==id} return result end |