Module: GPSTool::Filters::Distance

Defined in:
lib/gpstool/filters/distance.rb

Class Method Summary collapse

Class Method Details

.filter_points(points, options) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gpstool/filters/distance.rb', line 8

def self.filter_points(points, options)
	filtered_points = []
	i = 0
	
	while i < points.size
		current = points[i]
		
		filtered_points << current
		
		j = i + 1
		
		while j < points.size
			step = points[j]
			distance = current.distanceTo(step)
			
			break if distance < options[:distance]
			
			j += 1
		end
		
		i = j
	end
	
	return filtered_points
end