Module: GeoMagic::MapPoints
- Defined in:
- lib/geo_magic/util.rb
Constant Summary collapse
- RAD_PER_DEG =
0.017453293
Instance Method Summary collapse
- #get_closest(number, options = {}) ⇒ Object
- #get_within(dist_obj, options = {:precision => :lowest}) ⇒ Object
- #rad ⇒ Object
Instance Method Details
#get_closest(number, options = {}) ⇒ Object
59 60 61 62 63 |
# File 'lib/geo_magic/util.rb', line 59 def get_closest number, = {} calc_method = get_proc([:precision] || :normal) from_loc = get_location [:from] populate_distance(calc_method, from_loc).sort_by_distance[0..number] end |
#get_within(dist_obj, options = {:precision => :lowest}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/geo_magic/util.rb', line 40 def get_within dist_obj, = {:precision => :lowest} calc_method = get_proc([:precision] || :normal) from_loc = get_location [:from] dist = dist_obj.distance / (RAD_PER_DEG * rad[dist_obj.unit]) res = [] spots = populate_distance(calc_method, from_loc) spots.sort_by_distance.select do |item| it = get_dist_obj(item) if it.dist <= dist res << item else break end end res end |
#rad ⇒ Object
36 37 38 |
# File 'lib/geo_magic/util.rb', line 36 def rad {:km => 6371, :miles => 3956, :feet => 20895592, :meters => 6371000} end |