winding-polygon 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 118bf8a6840db9007b4fbaddff4d46c075cd380d
4
- data.tar.gz: ee96fdb6aa4fd201cee0373f9a13f7c7a104ae78
3
+ metadata.gz: b93c5a04c574168789c5f535cfe5b7bd6b3022b9
4
+ data.tar.gz: f786a135b79fae01532ff79e204723e8729d4095
5
5
  SHA512:
6
- metadata.gz: c3fc02a540b3ec3c74993e8085f1cfeaf7e7d0c3b81d971e2a5457322fec5aa04c7fc650c23f52226ecda71eeec63d0b54c28864a83bfe53f7c035ee823051e4
7
- data.tar.gz: 82d0a4390bcd171a95989ab913b7a5087c5697dc75a030f7f7c85a365776e9f9d0f1eceac681b219a53b068b04a7d02e5db842f6a286e24ac01ef030749e1d50
6
+ metadata.gz: 0e4b819bec68773342dae6efb09835cc1a1f99ebb28c67b0f26c0b940baeef3867519372ad6f1c8cbf0a08b32ccd7e5f2f6c0adb086acee69cdfd7c061b01bc1
7
+ data.tar.gz: 052bc7ac5b866fc70a3a44fb4220300ff36eab2b493c8e1e4415b137553489621d4ddc70b9206c681d798b13710532f370349c276176247f1d83794d1118ce31
@@ -12,7 +12,7 @@ module WindingPolygon
12
12
  def self.decompose(input_polygon)
13
13
 
14
14
  intersection_points = input_polygon.get_intersection_points
15
- return input_polygon if intersection_points.nil? || intersection_points.size==0
15
+ return [input_polygon] if intersection_points.nil? || intersection_points.size==0
16
16
 
17
17
  input_polygon.simple_segments.sort_by!{|seg| [seg.left_point] }
18
18
  simple_polygons = Array.new
@@ -1,3 +1,3 @@
1
1
  module WindingPolygon
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
@@ -6,8 +6,8 @@ describe WindingPolygon do
6
6
  end
7
7
 
8
8
 
9
- it 'should decompose a production complex polygon into 2 simple polygons' do
10
- puts 'should decompose a production complex polygon into 2 simple polygons'
9
+ it 'should decompose a production complex polygon1 into 2 simple polygons' do
10
+ puts 'should decompose a production complex polygon1 into 2 simple polygons'
11
11
  points = JSON.parse("[["+"-87.78842 41.85362,-87.78739 41.85208,-87.78619 41.85029,-87.78722 41.8352,-87.78894 41.83354,-87.79014 41.83264,-87.79168 41.83175,-87.7934 41.83098,-87.79546 41.83021,-87.79752 41.82957,-87.79992 41.82893,-87.80198 41.82842,-87.80387 41.82804,-87.8061 41.82778,-87.80833 41.82778,-87.81022 41.82778,-87.81245 41.82778,-87.81417 41.82804,-87.81537 41.82855,-87.81657 41.82906,-87.81812 41.83021,-87.81932 41.83175,-87.82052 41.83341,-87.82189 41.83763,-87.82086 41.85605,-87.81949 41.85771,-87.81795 41.85911,-87.81589 41.86078,-87.81365 41.86231,-87.81159 41.86333,-87.80953 41.86423,-87.80713 41.86487,-87.80524 41.86487,-87.80301 41.86487,-87.8013 41.86474,-87.79958 41.86461,-87.79803 41.86436,-87.79666 41.86397,-87.79546 41.86359,-87.79409 41.86321,-87.79288 41.86269,-87.79185 41.86205,-87.79031 41.86103,-87.78928 41.86014,-87.79048 41.85886,-87.79151 41.85796,-87.79288 41.85668,-87.7946 41.85528,-87.79615 41.854,-87.79752 41.85272,-87.79906 41.85131,-87.80078 41.84952,-87.80198 41.84837,-87.80301 41.84748,-87.80473 41.84722,-87.78842 41.85362".gsub(',','],[').gsub(' ',',')+"]]")
12
12
  polygon = WindingPolygon::Polygon.new(points.map{|item| WindingPolygon::Point.new(item[0].to_f,item[1].to_f)})
13
13
 
@@ -21,8 +21,8 @@ describe WindingPolygon do
21
21
 
22
22
  end
23
23
 
24
- it 'should decompose a production complex polygon into 20 simple polygons' do
25
- puts 'should decompose a production complex polygon into 20 simple polygons'
24
+ it 'should decompose a production complex polygon2 into 20 simple polygons' do
25
+ puts 'should decompose a production complex polygon2 into 20 simple polygons'
26
26
  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(' ',',')+"]]")
27
27
  polygon = WindingPolygon::Polygon.new(points.map{|item| WindingPolygon::Point.new(item[1].to_f,item[0].to_f)})
28
28
 
@@ -36,6 +36,21 @@ describe WindingPolygon do
36
36
 
37
37
  end
38
38
 
39
+ it 'should decompose a production complex polygon3 into 2 simple polygons' do
40
+ puts 'should decompose a production complex polygon3 into 2 simple polygons'
41
+ points = JSON.parse("[["+"-117.24925876095165 33.91178188651025,-117.23665 33.92297,-117.23454 33.88265,-117.2329768082223 33.876156994994965,-117.22880432048471 33.858825798560716,-117.21764 33.82916,-117.19441 33.78354,-117.18500627102398 33.76125512143704,-117.17963 33.75808,-117.1822623691137 33.75475264555591,-117.17329 33.73349,-117.1469 33.68342,-117.15323 33.72559,-117.16379 33.7651,-117.17963 33.81249,-117.19969 33.86073,-117.21209151500123 33.88704,-117.21342 33.88704,-117.22240964169768 33.89151566678272,-117.22187 33.8923,-117.24357401835415 33.907738274960245,-117.2451 33.90719,-117.24429633564073 33.90241238017341,-117.25423918087715 33.90736261775205,-117.24925876095165 33.91178188651025".gsub(',','],[').gsub(' ',',')+"]]")
42
+ polygon = WindingPolygon::Polygon.new(points.map{|item| WindingPolygon::Point.new(item[0].to_f,item[1].to_f)})
43
+
44
+ t1 = Time.now
45
+ multi_polygons = WindingPolygon.decompose(polygon)
46
+ t2 = Time.now
47
+ puts "elapsed time: #{(t2-t1)*1000.to_i} ms"
48
+ multi_polygons.should_not be_nil
49
+
50
+ multi_polygons.size.should == 2
51
+
52
+ end
53
+
39
54
 
40
55
 
41
56
  it 'should decompose Andy complex polygon into 7 simple polygons' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winding-polygon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Xu