lib/geoptima/locator.rb in geoptima-0.1.19 vs lib/geoptima/locator.rb in geoptima-0.1.20

- old
+ new

@@ -59,11 +59,11 @@ puts "No correlation possible for point: "+point end end end module Locatable - attr_accessor :previous_point, :next_point, :previous_point_gap, :next_point_gap, :location + attr_accessor :previous_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}" @@ -77,12 +77,15 @@ self.next_point = gps.location self.next_point_gap = (self - gps).abs end end def set_previous_if(gps,time_window=0.0) - if closer_than(gps,time_window) - self.previous_point = gps.location - self.previous_point_gap = (self - gps).abs + if gps + self.previous_gps = gps + if closer_than(gps,time_window) + self.previous_point = gps.location + self.previous_point_gap = (self - gps).abs + end end end end class LocatableImpl attr_reader :name, :attributes