GeoRSS aggregator and Layar augmented reality server
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

27 lines
511 B

  1. class Post
  2. include MongoMapper::Document
  3. key :title, String
  4. key :url, String
  5. key :author, String
  6. key :summary, String
  7. key :content, String
  8. key :published, Time
  9. key :loc, Hash # { lng, lat }
  10. timestamps!
  11. ensure_index [[:loc, '2d']]
  12. belongs_to :feed
  13. EARTH_RADIUS_M = 6378000
  14. def self.near(lat, lng, radius_m)
  15. all(
  16. :loc => {
  17. '$nearSphere' => [ lng, lat ],
  18. '$maxDistance' => radius_m / EARTH_RADIUS_M
  19. })
  20. end
  21. end