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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rdp/polyline.rb +6 -8
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5300d2c476518807f870391bdfc22a13de2efb52
4
- data.tar.gz: 78b9afef7a9c8b104c77c6e81d83e9dbd1e901aa
3
+ metadata.gz: 35a9e5ef630b8853a12ace61b746bc76335f8b59
4
+ data.tar.gz: 25bd40cf902ff0a2209121f1eeb08b85ca91a603
5
5
  SHA512:
6
- metadata.gz: 88e26c998dafc78f724f43d003a3192a7f37a3329f3aaa790e9a79e84e9b0513f443a2ab6c71b06a71f5fa4c0f5c9d47cc411f7e0f0614e4c47e72882a2f1d4e
7
- data.tar.gz: 7d3d9056b1dbaf65d4801861e0bbaecd80240e7239402d6a08f4e79aa157b801fdf62940f5afa27117748fde834174a1f3615f4ed6ef392cbae932ce67a464f9
6
+ metadata.gz: 92c8b6d51e02feb59dc9cbe30600237109b8d8ae2fbaa638a04e4ed43baea068efb87b716febf6a65b9b69bd87b18067f665da48054bc8ab053ae19f2a2a7943
7
+ data.tar.gz: 0e40d016e8b0957ee501b66d0bd17c2f4216a0cded645bca5b27acb4935e00c1c40cb52edd5bcd1a169d4146fcc14ce5084bcd9dd9224440ef9f8db85d1d1c49
@@ -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=normalized_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.0
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: Changed default value
45
+ summary: Relative tolerance
46
46
  test_files: []