This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Sun Oct 26 07:29:23 -0700 2008 | |
| |
MIGRATION | Sun Oct 26 07:29:23 -0700 2008 | |
| |
README.markdown | ||
| |
Rakefile | ||
| |
init.rb | Sun Oct 26 07:29:23 -0700 2008 | |
| |
lib/ | Sun Nov 16 07:01:45 -0800 2008 | |
| |
spec/ |
README.markdown
GOALS
- add a location to your models (latitude/longitude)
- find other models in a certain radius
- find other models on the same map (giving map size in pixels and zoom level)
- prevent assignment of a default location (value your map script uses as default/starting point)
- complete test coverage
INSTALL
script/plugin install git://github.com/ptb/geokit.git
script/plugin install git://github.com/grosser/has_a_location.git
Table with (see: MIGRATION):
lat
lng
Model:
User < ActiveRecord::Base
has_a_location :default_location_lat=>10.10,:default_location_lng=>20.20
end
USAGE
user.location = [12.2332,323.2323][latitude,longitude]show_map if user.locationuser.in_radius(500)=> users in 500 miles distanceUser.on_map([11.12343,34,183323],[640,480],5)=> all users visible on a 640x480 map zoom-level 5, with center 11.12343,34,183323user.surrounding_on_map([640,480],5)=> other users visible on this map
OPTIONS
Legend: options key => default [recommended]
:default_location_lng => 0 [your default map longitude]
:default_location_lat => 0 [your default map latitude]
:default_units => :miles [:kms]
:default_formula => :sphere [:flat]
:lat_column_name=>:lat [:location_latitude]
:lng_column_name=>:lng [:location_longitude]
:distance_column_name=>:distance [:distance]
TODO
- latitude calculation is theoretically (wrong theory?) wrong put works practically...
AUTHOR
Michael Grosser
grosser dot michael ät gmail dot com








