Skip to content

Instantly share code, notes, and snippets.

@pezholio
Created August 17, 2012 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pezholio/3378718 to your computer and use it in GitHub Desktop.
Save pezholio/3378718 to your computer and use it in GitHub Desktop.
More Mongomapper Geo problems
mapit = Mapit.GetPostcode(params[:postcode])
EARTH_RADIUS_M = 3959
query[:latlng] = {'$nearSphere' => [mapit["lat"], mapit["lng"]], '$maxDistance' => Float(params[:within].to_i) / EARTH_RADIUS_M }
applications = Application.where(query)
@applications = applications.paginate({:order => :receiveddate.desc, :per_page=> 10, :page => params[:page]})
class Application
include MongoMapper::Document
ensure_index [[:latlng, '2d']]
key :refval, String
key :keyval, String
key :applicantname, String
key :latlng, Array
key :address, String
key :occupier, String
key :type, String
key :casetype, String
key :tradingname, String
key :closingdate, Date
key :recieveddate, Date
key :details, String
key :usetype, String
key :status, String
key :validfrom, Date
timestamps!
many :activities
many :notices
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment