rdp 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rdp/polyline.rb +6 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35a9e5ef630b8853a12ace61b746bc76335f8b59
|
4
|
+
data.tar.gz: 25bd40cf902ff0a2209121f1eeb08b85ca91a603
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92c8b6d51e02feb59dc9cbe30600237109b8d8ae2fbaa638a04e4ed43baea068efb87b716febf6a65b9b69bd87b18067f665da48054bc8ab053ae19f2a2a7943
|
7
|
+
data.tar.gz: 0e40d016e8b0957ee501b66d0bd17c2f4216a0cded645bca5b27acb4935e00c1c40cb52edd5bcd1a169d4146fcc14ce5084bcd9dd9224440ef9f8db85d1d1c49
|
data/lib/rdp/polyline.rb
CHANGED
@@ -9,14 +9,12 @@ class RDP::Polyline < Array
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
#Automatically compute a tolerance level for the vertix decimation algorithm
|
13
|
-
def normalized_epsilon
|
14
|
-
ys = self.map{|point| point.y}
|
15
|
-
(ys.max - ys.min)*(0.02)
|
16
|
-
end
|
17
|
-
|
18
12
|
#vertix decimation using Ramer Douglas Peucker algorithm
|
19
|
-
def simplify(epsilon=
|
13
|
+
def simplify(epsilon=0.01,hard_limit=nil)
|
14
|
+
|
15
|
+
# 1% default tolerance. the tolerance should not be recomputed recursively, hence the hard_limit
|
16
|
+
tol = hard_limit || (self.map{|p| p.y}.max - self.map{|p| p.y}.min)*epsilon
|
17
|
+
|
20
18
|
l = RDP::Line.new.define_from_points(self.first, self.last)
|
21
19
|
dmax = 0.0
|
22
20
|
pmax = nil
|
@@ -35,7 +33,7 @@ class RDP::Polyline < Array
|
|
35
33
|
if pmax # at least a point has to be taken into account
|
36
34
|
sub1 = RDP::Polyline.new(self[0..imax])
|
37
35
|
sub2 = RDP::Polyline.new(self[imax..-1])
|
38
|
-
return RDP::Polyline.new((sub1.simplify(epsilon) + sub2.simplify(epsilon)).uniq)
|
36
|
+
return RDP::Polyline.new((sub1.simplify(epsilon,tol) + sub2.simplify(epsilon,tol)).uniq)
|
39
37
|
else
|
40
38
|
#no point is found
|
41
39
|
return RDP::Polyline.new([self.first, self.last])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aurélien Hervé
|
@@ -42,5 +42,5 @@ rubyforge_project:
|
|
42
42
|
rubygems_version: 2.0.0.rc.2
|
43
43
|
signing_key:
|
44
44
|
specification_version: 4
|
45
|
-
summary:
|
45
|
+
summary: Relative tolerance
|
46
46
|
test_files: []
|