Created
August 17, 2012 13:32
-
-
Save pezholio/3378718 to your computer and use it in GitHub Desktop.
More Mongomapper Geo problems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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