lib/geoptima/locator.rb in geoptima-0.1.20 vs lib/geoptima/locator.rb in geoptima-0.1.21
- old
+ new
@@ -59,11 +59,11 @@
puts "No correlation possible for point: "+point
end
end
end
module Locatable
- attr_accessor :previous_gps, :previous_point, :next_point, :previous_point_gap, :next_point_gap, :location
+ attr_accessor :previous_gps, :next_gps, :previous_point, :next_point, :previous_point_gap, :next_point_gap, :location
def closer_than(gps,window=0.0)
if $debug && gps && window > 0
puts "Comparing times:"
puts "\tGPS: #{gps.time}"
puts "\tEvent: #{self.time}"
@@ -71,12 +71,15 @@
puts "\tWindow: #{window}"
end
gps && (window <= 0.0 || (self - gps).abs < window)
end
def set_next_if(gps,time_window=0.0)
- if closer_than(gps,time_window)
- self.next_point = gps.location
- self.next_point_gap = (self - gps).abs
+ if gps
+ self.next_gps = gps
+ if closer_than(gps,time_window)
+ self.next_point = gps.location
+ self.next_point_gap = (self - gps).abs
+ end
end
end
def set_previous_if(gps,time_window=0.0)
if gps
self.previous_gps = gps