Module: Geoptima::Locatable
- Included in:
- Event, LocatableImpl
- Defined in:
- lib/geoptima/locator.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
Returns the value of attribute location.
-
#next_gps ⇒ Object
Returns the value of attribute next_gps.
-
#next_point ⇒ Object
Returns the value of attribute next_point.
-
#next_point_gap ⇒ Object
Returns the value of attribute next_point_gap.
-
#previous_gps ⇒ Object
Returns the value of attribute previous_gps.
-
#previous_point ⇒ Object
Returns the value of attribute previous_point.
-
#previous_point_gap ⇒ Object
Returns the value of attribute previous_point_gap.
Instance Method Summary collapse
- #closer_than(gps, window = 0.0) ⇒ Object
- #set_next_if(gps, time_window = 0.0) ⇒ Object
- #set_previous_if(gps, time_window = 0.0) ⇒ Object
Instance Attribute Details
#location ⇒ Object
Returns the value of attribute location.
64 65 66 |
# File 'lib/geoptima/locator.rb', line 64 def location @location end |
#next_gps ⇒ Object
Returns the value of attribute next_gps.
64 65 66 |
# File 'lib/geoptima/locator.rb', line 64 def next_gps @next_gps end |
#next_point ⇒ Object
Returns the value of attribute next_point.
64 65 66 |
# File 'lib/geoptima/locator.rb', line 64 def next_point @next_point end |
#next_point_gap ⇒ Object
Returns the value of attribute next_point_gap.
64 65 66 |
# File 'lib/geoptima/locator.rb', line 64 def next_point_gap @next_point_gap end |
#previous_gps ⇒ Object
Returns the value of attribute previous_gps.
64 65 66 |
# File 'lib/geoptima/locator.rb', line 64 def previous_gps @previous_gps end |
#previous_point ⇒ Object
Returns the value of attribute previous_point.
64 65 66 |
# File 'lib/geoptima/locator.rb', line 64 def previous_point @previous_point end |
#previous_point_gap ⇒ Object
Returns the value of attribute previous_point_gap.
64 65 66 |
# File 'lib/geoptima/locator.rb', line 64 def previous_point_gap @previous_point_gap end |
Instance Method Details
#closer_than(gps, window = 0.0) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/geoptima/locator.rb', line 65 def closer_than(gps,window=0.0) if $debug && gps && window > 0 puts "Comparing times:" puts "\tGPS: #{gps.time}" puts "\tEvent: #{self.time}" puts "\tTDiff: #{(self - gps).abs.to_f}" puts "\tWindow: #{window}" end gps && (window <= 0.0 || (self - gps).abs < window) end |
#set_next_if(gps, time_window = 0.0) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/geoptima/locator.rb', line 75 def set_next_if(gps,time_window=0.0) 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 |
#set_previous_if(gps, time_window = 0.0) ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/geoptima/locator.rb', line 84 def set_previous_if(gps,time_window=0.0) 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 |