Class: Geoptima::ClosestLocatorAlgorithm
- Inherits:
-
LocatorAlgorithm
- Object
- LocatorAlgorithm
- Geoptima::ClosestLocatorAlgorithm
- Defined in:
- lib/geoptima/locator.rb
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#locate(locatable) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/geoptima/locator.rb', line 40 def locate(locatable) results = [ [locatable.next_point_gap,locatable.next_point], [locatable.previous_point_gap,locatable.previous_point] ].reject do |x| x[0].nil? && x[1].nil? end.sort do |a,b| a[0] <=> b[0] end[0] locatable.location = results && results[1] end |