winding-polygon 0.0.9 → 0.0.10
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/winding-polygon.rb +5 -1
- data/lib/winding-polygon/avltree.rb +15 -0
- data/lib/winding-polygon/segment.rb +3 -3
- data/lib/winding-polygon/sweep_line.rb +6 -1
- data/lib/winding-polygon/version.rb +1 -1
- data/spec/winding-polygon_spec.rb +6 -144
- 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: b36a8be34afbf124b0371fcb15ce5c0e05d37387
|
4
|
+
data.tar.gz: 1ffe4470523f84aa005c23d1fc633bb5e0899fc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1379490d9c6631b5f06c719825e443bcc081fd14e3a5aeb983d6909d71e344a065ba8816480199d89b7a6e565cc8e7fd89fbc9a4e593b0bc369c3c66f49d08b
|
7
|
+
data.tar.gz: 279b62ea3536dc3703b34cb5a401b073af50c98f81e105c9aa45db42254b8b152fdc4b8a8d5f3edbe98e2da85eede08ef1760e2d4a92daab59217ecebd307489
|
data/lib/winding-polygon.rb
CHANGED
@@ -11,7 +11,8 @@ module WindingPolygon
|
|
11
11
|
input_polygon.simple_segments.sort_by!{|seg| [seg.left_point] }
|
12
12
|
simple_polygons = Array.new
|
13
13
|
while !input_polygon.simple_segments.nil? && input_polygon.simple_segments.size>=3
|
14
|
-
|
14
|
+
simple_polygon = get_one_simple_polygon(get_first_segment(input_polygon), input_polygon)
|
15
|
+
simple_polygons << simple_polygon if !simple_polygon.nil?
|
15
16
|
end
|
16
17
|
simple_polygons
|
17
18
|
|
@@ -28,6 +29,8 @@ module WindingPolygon
|
|
28
29
|
previous_edge = current_simple_polygon.last.edge
|
29
30
|
next_segment_candidates = input_polygon.simple_segments.select { |seg| seg.edge!=previous_edge && (seg.left_point == current_point ||seg.right_point == current_point) }.dup
|
30
31
|
|
32
|
+
return nil if next_segment_candidates.empty?
|
33
|
+
|
31
34
|
if !next_segment_candidates.nil? && next_segment_candidates.size>=2
|
32
35
|
#determine previous segment vector
|
33
36
|
if current_point == current_simple_polygon.last.left_point
|
@@ -71,6 +74,7 @@ module WindingPolygon
|
|
71
74
|
def self.get_first_segment(input_polygon)
|
72
75
|
start_point = input_polygon.simple_segments[0].left_point
|
73
76
|
first_segment_candidates = input_polygon.simple_segments.select { |seg| seg.left_point == start_point }.dup
|
77
|
+
#puts "edg1:#{first_segment_candidates[0].edge}, edg2:#{first_segment_candidates[1].edge}"
|
74
78
|
first_segment_candidates.sort!
|
75
79
|
input_polygon.simple_segments.delete_if { |seg| seg.left_point==first_segment_candidates[0].left_point && seg.right_point==first_segment_candidates[0].right_point }
|
76
80
|
first_segment_candidates[0]
|
@@ -42,6 +42,21 @@ module WindingPolygon
|
|
42
42
|
search_node(@root, v)
|
43
43
|
end
|
44
44
|
|
45
|
+
def scan(v)
|
46
|
+
current_node = @root
|
47
|
+
while !current_node.nil?
|
48
|
+
return current_node if current_node.value == v
|
49
|
+
current_node = current_node.next
|
50
|
+
end
|
51
|
+
|
52
|
+
current_node = @root.prev
|
53
|
+
while !current_node.nil?
|
54
|
+
return current_node if current_node.value == v
|
55
|
+
current_node = current_node.prev
|
56
|
+
end
|
57
|
+
current_node
|
58
|
+
end
|
59
|
+
|
45
60
|
def delete(v)
|
46
61
|
d = search(v)
|
47
62
|
return nil if d.nil?
|
@@ -34,16 +34,16 @@ module WindingPolygon
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def == (other_segment)
|
37
|
-
return true if @left_point == other_segment.left_point && @right_point == other_segment.right_point
|
37
|
+
return true if @left_point == other_segment.left_point && @right_point == other_segment.right_point
|
38
38
|
return false
|
39
39
|
end
|
40
40
|
|
41
41
|
def <=> other_segment
|
42
42
|
raise Exception.new("Self is edge=#{@edge}, the other_segment is nil") if other_segment.nil?
|
43
43
|
|
44
|
-
return 1 if self > other_segment
|
45
|
-
return -1 if self < other_segment
|
46
44
|
return 0 if self == other_segment
|
45
|
+
return -1 if self < other_segment
|
46
|
+
return 1
|
47
47
|
end
|
48
48
|
|
49
49
|
def to_s
|
@@ -6,159 +6,21 @@ describe WindingPolygon do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
polygon = WindingPolygon::Polygon.new(points.map{|item| WindingPolygon::Point.new(item[0],item[1])})
|
9
|
+
it 'should decompose a production complex polygon 20 into n simple polygons' do
|
10
|
+
puts 'should decompose a production complex polygon 2 into n simple polygons'
|
11
|
+
points = JSON.parse("[["+"34.09522 -82.77396,34.09522 -82.76984,34.0901 -82.76022,34.08555 -82.75542,34.081 -82.74512,34.081 -82.74031,34.08157 -82.72933,34.08442 -82.7204,34.0992 -82.70667,34.11285 -82.70186,34.11 -82.69774,34.10148 -82.68607,34.10091 -82.68126,34.10148 -82.67096,34.10546 -82.66478,34.10887 -82.65997,34.11853 -82.65173,34.15661 -82.66409,34.16002 -82.67165,34.16627 -82.69293,34.17138 -82.70667,34.1782 -82.7204,34.19297 -82.73963,34.19751 -82.73413,34.19751 -82.72246,34.19694 -82.71422,34.19524 -82.69431,34.19297 -82.68263,34.18558 -82.66066,34.18047 -82.65311,34.17024 -82.6483,34.1549 -82.65929,34.15093 -82.66478,34.14183 -82.68057,34.13672 -82.69225,34.12876 -82.71697,34.12933 -82.73757,34.16002 -82.76022,34.1674 -82.75199,34.1674 -82.74718,34.1674 -82.74306,34.16627 -82.73276,34.164 -82.72795,34.15831 -82.71971,34.14695 -82.71353,34.12422 -82.72246,34.12422 -82.72727,34.12422 -82.73345,34.12706 -82.74855,34.13104 -82.75542,34.14127 -82.76572,34.14979 -82.7719,34.15831 -82.77808,34.18899 -82.77121,34.18899 -82.76709,34.18842 -82.7561,34.18729 -82.74993,34.18558 -82.74375,34.17933 -82.7307,34.17479 -82.72452,34.1674 -82.71628,34.15093 -82.70873,34.13445 -82.71491,34.12876 -82.72452,34.12592 -82.7307,34.12365 -82.73757,34.12024 -82.75473,34.11853 -82.76503,34.12024 -82.77327,34.12422 -82.78426,34.12933 -82.78906,34.13786 -82.79456,34.15263 -82.80348,34.16172 -82.8076,34.18217 -82.8028,34.18104 -82.79662,34.17479 -82.79181,34.16968 -82.787,34.16343 -82.78151,34.15718 -82.77533,34.15206 -82.77052,34.1532 -82.7664,34.18274 -82.7719,34.18274 -82.77808,34.17877 -82.78838,34.17365 -82.79318,34.14297 -82.78838,34.1424 -82.78014,34.14354 -82.77396,34.14979 -82.76503,34.15661 -82.75885,34.16627 -82.74924,34.17252 -82.74169,34.17536 -82.73688,34.1782 -82.72589,34.1782 -82.71903,34.17763 -82.71285,34.17649 -82.70667,34.17479 -82.70049,34.16797 -82.69087,34.16286 -82.68675,34.13104 -82.69431,34.13047 -82.6998,34.13047 -82.70529,34.1316 -82.71147,34.13331 -82.71628,34.13729 -82.72109,34.14183 -82.72589,34.14865 -82.73139,34.15547 -82.73551,34.17081 -82.73139,34.17081 -82.72727,34.17081 -82.71765,34.16968 -82.71216,34.16797 -82.70598,34.1657 -82.70186,34.15945 -82.69568,34.14297 -82.70117,34.14183 -82.70598,34.14183 -82.71147,34.14183 -82.71765,34.14297 -82.72177,34.14865 -82.73139,34.15263 -82.73551,34.15775 -82.741,34.1657 -82.74718,34.17252 -82.75199,34.18274 -82.75679,34.19183 -82.76366,34.19126 -82.76778,34.18899 -82.77258,34.1657 -82.76778,34.1657 -82.76366,34.16627 -82.75885,34.16968 -82.75405,34.17365 -82.74993,34.18047 -82.74443,34.18445 -82.73825,34.18672 -82.73413,34.18842 -82.73001,34.18842 -82.72521,34.18842 -82.71971,34.18842 -82.71559,34.18785 -82.71147,34.18615 -82.70667,34.18047 -82.69843,34.17593 -82.69293,34.17024 -82.68744,34.16456 -82.68263,34.14865 -82.67577,34.13501 -82.68057,34.1316 -82.68744,34.12933 -82.69293,34.12592 -82.69843,34.12365 -82.70323,34.12024 -82.71147,34.11683 -82.71971,34.11341 -82.72795,34.11285 -82.73688,34.11285 -82.74443,34.11341 -82.74993,34.11569 -82.75542,34.12365 -82.76366,34.13104 -82.76846,34.14127 -82.77327,34.14695 -82.76915,34.14411 -82.76434,34.13956 -82.76022,34.13445 -82.7561,34.12308 -82.7513,34.10943 -82.74649,34.09806 -82.741,34.0884 -82.73345,34.08555 -82.72795,34.08442 -82.72246,34.08442 -82.71765,34.08669 -82.71147,34.09295 -82.70529,34.10091 -82.70049,34.11171 -82.69568,34.1191 -82.70049,34.11796 -82.70667,34.11796 -82.71285,34.11796 -82.71903,34.11853 -82.72383,34.11967 -82.73001,34.12194 -82.73688,34.12422 -82.74169,34.13104 -82.74787,34.14922 -82.74169,34.15149 -82.73757,34.15206 -82.73276,34.15206 -82.72658,34.15206 -82.7204,34.15206 -82.71422,34.15093 -82.70941,34.14809 -82.70392,34.14013 -82.6998,34.12024 -82.70804,34.11626 -82.71285,34.11398 -82.71903,34.11398 -82.72383,34.11455 -82.73001,34.11512 -82.73482,34.11796 -82.74031,34.12024 -82.74649,34.12365 -82.75267,34.12706 -82.76022,34.13047 -82.76778,34.13388 -82.77602,34.13672 -82.78426,34.13729 -82.79044,34.13729 -82.79593,34.13729 -82.80005,34.13445 -82.80554,34.12024 -82.80005,34.12592 -82.79456,34.13786 -82.78975,34.22193 -82.79387,34.09522 -82.77396".gsub(',','],[').gsub(' ',',')+"]]")
|
12
|
+
polygon = WindingPolygon::Polygon.new(points.map{|item| WindingPolygon::Point.new(item[1].to_f,item[0].to_f)})
|
14
13
|
|
15
|
-
multi_polygons = []
|
16
14
|
t1 = Time.now
|
17
|
-
WindingPolygon.decompose(polygon
|
18
|
-
t2 = Time.now
|
19
|
-
puts "elapsed time: #{(t2-t1)*1000.to_i} ms"
|
20
|
-
multi_polygons.should_not be_nil
|
21
|
-
|
22
|
-
points1 = JSON.parse("[[-98.4609375000036,40.3051841980949],[-98.4609375000036,38.057277897745],[-97.39951856124108,38.97265129300353],[-98.4609375000036,40.3051841980949]]")
|
23
|
-
polygon1 = WindingPolygon::Polygon.new(points1.map{|item| WindingPolygon::Point.new(item[0],item[1])})
|
24
|
-
multi_polygons[0].should ==polygon1
|
25
|
-
|
26
|
-
points2 = JSON.parse("[[-97.39951856124108,38.97265129300353],[-96.0878906250017,40.1038062719331],[-96.6152343750031,37.9880405545487],[-97.39951856124108,38.97265129300353]]")
|
27
|
-
polygon2 = WindingPolygon::Polygon.new(points2.map{|item| WindingPolygon::Point.new(item[0],item[1])})
|
28
|
-
multi_polygons[1].should ==polygon2
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
it 'should decompose a practical complex polygon into four simple polygons' do
|
34
|
-
puts 'should decompose a practical complex polygon into four simple polygons'
|
35
|
-
points = JSON.parse("[[-98.4609375000036,40.3051841980949],[-98.4609375000036,38.057277897745],[-96.0878906250017,40.1038062719331],[-96.6152343750031,37.9880405545487],[-97.6152343750031,40.9880405545487],[-98.0152343750031,37.9880405545487],[-98.4609375000036,40.3051841980949]]")
|
36
|
-
polygon = WindingPolygon::Polygon.new(points.map{|item| WindingPolygon::Point.new(item[0],item[1])})
|
37
|
-
|
38
|
-
multi_polygons = []
|
39
|
-
t1 = Time.now
|
40
|
-
WindingPolygon.decompose(polygon,multi_polygons)
|
41
|
-
t2 = Time.now
|
42
|
-
puts "elapsed time: #{(t2-t1)*1000.to_i} ms"
|
43
|
-
multi_polygons.should_not be_nil
|
44
|
-
|
45
|
-
multi_polygons.size.should == 4
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should decompose a production complex polygon 2 into two simple polygons' do
|
50
|
-
puts 'should decompose a production complex polygon 2 into two simple polygons'
|
51
|
-
points = JSON.parse("[[-95.6968,29.93101],[-95.6992,29.93101],[-95.7016,29.9319],[-95.70401,29.93309],[-95.7071,29.93428],[-95.7095,29.93488],[-95.7119,29.93547],[-95.71431,29.93607],[-95.7174,29.93666],[-95.72014,29.93726],[-95.72255,29.93785],[-95.72564,29.93875],[-95.72804,29.93994],[-95.72598,29.95094],[-95.72358,29.95303],[-95.72152,29.95481],[-95.71877,29.95659],[-95.71637,29.95778],[-95.71362,29.95838],[-95.71122,29.95838],[-95.70847,29.95838],[-95.70538,29.95808],[-95.70195,29.95778],[-95.69851,29.95719],[-95.69405,29.956],[-95.69165,29.9554],[-95.6889,29.95451],[-95.68615,29.95332],[-95.68307,29.95184],[-95.68066,29.95124],[-95.67723,29.94856],[-95.67483,29.94648],[-95.67242,29.9438],[-95.67448,29.93607],[-95.67689,29.93339],[-95.67895,29.93161],[-95.68101,29.93131],[-95.68341,29.93131],[-95.68615,29.93131],[-95.6889,29.93101],[-95.69165,29.93101],[-95.69439,29.93101],[-95.69748,29.93161],[-95.70023,29.9322],[-95.70435,29.93339],[-95.70641,29.93428],[-95.70984,29.93458],[-95.6968,29.93101]]")
|
52
|
-
polygon = WindingPolygon::Polygon.new(points.map{|item| WindingPolygon::Point.new(item[0].to_f,item[1].to_f)})
|
53
|
-
|
54
|
-
multi_polygons = []
|
55
|
-
t1 = Time.now
|
56
|
-
WindingPolygon.decompose(polygon,multi_polygons)
|
57
|
-
t2 = Time.now
|
58
|
-
puts "elapsed time: #{(t2-t1)*1000.to_i} ms"
|
59
|
-
multi_polygons.should_not be_nil
|
60
|
-
|
61
|
-
multi_polygons.size.should == 3
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'should decompose a production complex polygon 3 into two simple polygons' do
|
66
|
-
|
67
|
-
puts 'should decompose a production complex polygon 3 into two simple polygons'
|
68
|
-
points = JSON.parse("[[-95.6968,29.93101],[-95.6992,29.93101],[-95.7016,29.9319],[-95.70401,29.93309],[-95.7071,29.93428],[-95.70747130044843,29.934372825112106],[-95.70984,29.93458],[-95.6968,29.93101]]")
|
69
|
-
polygon = WindingPolygon::Polygon.new(points.map{|item| WindingPolygon::Point.new(item[0].to_f,item[1].to_f)})
|
70
|
-
|
71
|
-
multi_polygons = []
|
72
|
-
t1 = Time.now
|
73
|
-
WindingPolygon.decompose(polygon,multi_polygons)
|
74
|
-
t2 = Time.now
|
75
|
-
puts "elapsed time: #{(t2-t1)*1000.to_i} ms"
|
76
|
-
multi_polygons.should_not be_nil
|
77
|
-
|
78
|
-
multi_polygons.size.should == 2
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'should decompose a production complex polygon 4 into two simple polygons' do
|
83
|
-
puts 'should decompose a production complex polygon 4 into two simple polygons'
|
84
|
-
points = JSON.parse("[[-87.80356,41.96514],[-87.80115,41.96182],[-87.79909,41.96156],[-87.79635,41.96131],[-87.79394,41.96105],[-87.79188,41.9608],[-87.78914,41.95978],[-87.78708,41.95876],[-87.78467,41.95722],[-87.78193,41.95544],[-87.77987,41.95339],[-87.77781,41.9511],[-87.77541,41.94803],[-87.773,41.94446],[-87.7706,41.94063],[-87.76785,41.9368],[-87.76545,41.93271],[-87.76339,41.92658],[-87.76133,41.91687],[-87.76373,41.87522],[-87.76579,41.87445],[-87.76854,41.87394],[-87.7706,41.87368],[-87.77335,41.87343],[-87.77575,41.87266],[-87.77815,41.8724],[-87.78021,41.87215],[-87.78296,41.87164],[-87.78536,41.87113],[-87.78776,41.87113],[-87.78982,41.87113],[-87.79223,41.87113],[-87.79463,41.87113],[-87.79703,41.87113],[-87.79978,41.87138],[-87.80184,41.87189],[-87.8039,41.8724],[-87.8063,41.87317],[-87.80871,41.87419],[-87.81077,41.87471],[-87.81283,41.87547],[-87.81523,41.87649],[-87.81729,41.87726],[-87.81935,41.87752],[-87.82141,41.87777],[-87.82347,41.87803],[-87.82622,41.87828],[-87.82862,41.87854],[-87.83171,41.87854],[-87.83377,41.8788],[-87.83652,41.87931],[-87.83926,41.88007],[-87.84132,41.88058],[-87.84373,41.88135],[-87.84613,41.88237],[-87.84888,41.88365],[-87.85094,41.88493],[-87.85334,41.88697],[-87.8554,41.89055],[-87.85746,41.89515],[-87.85952,41.90026],[-87.86158,41.90435],[-87.85952,41.92913],[-87.85746,41.93373],[-87.8554,41.94139],[-87.85334,41.94573],[-87.85094,41.94778],[-87.84888,41.94905],[-87.84647,41.95059],[-87.84304,41.95263],[-87.84098,41.95365],[-87.83892,41.95442],[-87.83514,41.95671],[-87.83308,41.95773],[-87.83102,41.95901],[-87.82862,41.96003],[-87.82484,41.96207],[-87.82107,41.9631],[-87.81901,41.9631],[-87.81695,41.9631],[-87.81351,41.9631],[-87.81042,41.96284],[-87.80699,41.96233],[-87.80424,41.96207],[-87.80184,41.96156],[-87.79978,41.96105],[-87.79703,41.95901],[-87.80356,41.96514]]")
|
85
|
-
polygon = WindingPolygon::Polygon.new(points.map{|item| WindingPolygon::Point.new(item[0].to_f,item[1].to_f)})
|
86
|
-
|
87
|
-
multi_polygons = []
|
88
|
-
t1 = Time.now
|
89
|
-
WindingPolygon.decompose(polygon,multi_polygons)
|
90
|
-
t2 = Time.now
|
91
|
-
puts "elapsed time: #{(t2-t1)*1000.to_i} ms"
|
92
|
-
multi_polygons.should_not be_nil
|
93
|
-
|
94
|
-
multi_polygons.size.should == 2
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'should decompose a production complex polygon 5 into two simple polygons' do
|
99
|
-
puts 'should decompose a production complex polygon 5 into two simple polygons'
|
100
|
-
points = JSON.parse("[[153.4229,-28.0902],[153.42346,-28.09104],[153.42395,-28.09178],[153.42435,-28.09254],[153.42487,-28.09328],[153.4229,-28.0902]]")
|
101
|
-
polygon = WindingPolygon::Polygon.new(points.map{|item| WindingPolygon::Point.new(item[0].to_f,item[1].to_f)})
|
102
|
-
|
103
|
-
multi_polygons = []
|
104
|
-
t1 = Time.now
|
105
|
-
WindingPolygon.decompose(polygon,multi_polygons)
|
106
|
-
t2 = Time.now
|
107
|
-
puts "elapsed time: #{(t2-t1)*1000.to_i} ms"
|
108
|
-
multi_polygons.should_not be_nil
|
109
|
-
|
110
|
-
multi_polygons.size.should == 2
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'should decompose a production complex polygon 6 into three simple polygons' do
|
115
|
-
puts 'should decompose a production complex polygon 6 into three simple polygons'
|
116
|
-
points = JSON.parse("[["+"-78.17273 38.94346,-78.17685 38.93652,-78.18097 38.93171,-78.18578 38.92637,-78.1899 38.91836,-78.19196 38.91622,-78.17273 38.94346".gsub(',','],[').gsub(' ',',')+"]]")
|
117
|
-
polygon = WindingPolygon::Polygon.new(points.map{|item| WindingPolygon::Point.new(item[0].to_f,item[1].to_f)})
|
118
|
-
|
119
|
-
multi_polygons = []
|
120
|
-
t1 = Time.now
|
121
|
-
WindingPolygon.decompose(polygon,multi_polygons)
|
122
|
-
t2 = Time.now
|
123
|
-
puts "elapsed time: #{(t2-t1)*1000.to_i} ms"
|
124
|
-
multi_polygons.should_not be_nil
|
125
|
-
|
126
|
-
multi_polygons.size.should == 3
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
it 'should decompose a production complex polygon 7 into two simple polygons' do
|
131
|
-
puts 'should decompose a production complex polygon 7 into two simple polygons'
|
132
|
-
points = JSON.parse("[["+"-71.77812 41.42488,-71.774 41.42024,-71.76782 41.41818,-71.76301 41.41818,-71.75546 41.41818,-71.74859 41.41818,-71.74172 41.41818,-71.73486 41.41818,-71.7273 41.41818,-71.71906 41.41818,-71.71288 41.41818,-71.70739 41.41818,-71.70327 41.41818,-71.69778 41.41818,-71.69366 41.41612,-71.77812 41.42488".gsub(',','],[').gsub(' ',',')+"]]")
|
133
|
-
polygon = WindingPolygon::Polygon.new(points.map{|item| WindingPolygon::Point.new(item[0].to_f,item[1].to_f)})
|
134
|
-
|
135
|
-
multi_polygons = []
|
136
|
-
t1 = Time.now
|
137
|
-
WindingPolygon.decompose(polygon,multi_polygons)
|
15
|
+
multi_polygons = WindingPolygon.decompose(polygon)
|
138
16
|
t2 = Time.now
|
139
17
|
puts "elapsed time: #{(t2-t1)*1000.to_i} ms"
|
140
18
|
multi_polygons.should_not be_nil
|
141
19
|
|
142
|
-
multi_polygons.size.should ==
|
20
|
+
multi_polygons.size.should == 20
|
143
21
|
|
144
22
|
end
|
145
23
|
|
146
|
-
it 'should decompose a production complex polygon 8 into four simple polygons' do
|
147
|
-
puts 'should decompose a production complex polygon 8 into four simple polygons'
|
148
|
-
points = JSON.parse("[["+"-88.69626 32.36626,-88.69697 32.36713,-88.69706 32.36722,-88.69713 32.3673,-88.69719 32.36738,-88.69729 32.36747,-88.69743 32.36758,-88.69749 32.36765,-88.69759 32.36777,-88.69767 32.36791,-88.69769 32.36798,-88.69626 32.36626".gsub(',','],[').gsub(' ',',')+"]]")
|
149
|
-
polygon = WindingPolygon::Polygon.new(points.map{|item| WindingPolygon::Point.new(item[0].to_f,item[1].to_f)})
|
150
|
-
|
151
|
-
multi_polygons = []
|
152
|
-
t1 = Time.now
|
153
|
-
WindingPolygon.decompose(polygon,multi_polygons)
|
154
|
-
t2 = Time.now
|
155
|
-
puts "elapsed time: #{(t2-t1)*1000.to_i} ms"
|
156
|
-
multi_polygons.should_not be_nil
|
157
|
-
|
158
|
-
multi_polygons.size.should == 4
|
159
|
-
|
160
|
-
end
|
161
|
-
=end
|
162
24
|
|
163
25
|
|
164
26
|
it 'should decompose Andy complex polygon into 7 simple polygons' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: winding-polygon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Xu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|