1
- var polygon = require ( '@src/lib/polygon' ) ;
1
+ var polygon = require ( '@src/lib/polygon' ) ,
2
+ polygonTester = polygon . tester ;
2
3
3
- describe ( 'polygon' , function ( ) {
4
+ describe ( 'polygon.tester ' , function ( ) {
4
5
'use strict' ;
5
6
6
7
var squareCW = [ [ 0 , 0 ] , [ 0 , 1 ] , [ 1 , 1 ] , [ 1 , 0 ] ] ,
@@ -51,7 +52,7 @@ describe('polygon', function() {
51
52
notInDonut = [ [ 1.5 , - 0.5 ] , [ 1.5 , 1.5 ] , [ 1.5 , 3.5 ] , [ - 0.5 , 1.5 ] , [ 3.5 , 1.5 ] ] ;
52
53
53
54
it ( 'should exclude points outside the bounding box' , function ( ) {
54
- var poly = polygon ( [ [ 1 , 2 ] , [ 3 , 4 ] ] ) ;
55
+ var poly = polygonTester ( [ [ 1 , 2 ] , [ 3 , 4 ] ] ) ;
55
56
var pts = [ [ 0 , 3 ] , [ 4 , 3 ] , [ 2 , 1 ] , [ 2 , 5 ] ] ;
56
57
pts . forEach ( function ( pt ) {
57
58
expect ( poly . contains ( pt ) ) . toBe ( false ) ;
@@ -67,7 +68,7 @@ describe('polygon', function() {
67
68
] ;
68
69
69
70
polyPts . forEach ( function ( polyPt ) {
70
- var poly = polygon ( polyPt ) ,
71
+ var poly = polygonTester ( polyPt ) ,
71
72
xArray = polyPt . map ( function ( pt ) { return pt [ 0 ] ; } ) ,
72
73
yArray = polyPt . map ( function ( pt ) { return pt [ 1 ] ; } ) ;
73
74
@@ -89,7 +90,7 @@ describe('polygon', function() {
89
90
var np = 6 ; // number of intermediate points on each edge to test
90
91
91
92
polyPts . forEach ( function ( polyPt ) {
92
- var poly = polygon ( polyPt ) ;
93
+ var poly = polygonTester ( polyPt ) ;
93
94
poly . pts . forEach ( function ( pt1 , i ) {
94
95
if ( ! i ) return ;
95
96
var pt0 = poly . pts [ i - 1 ] ,
@@ -123,16 +124,16 @@ describe('polygon', function() {
123
124
} ) ;
124
125
125
126
it ( 'should find only the right interior points' , function ( ) {
126
- var zzpoly = polygon ( zigzag ) ;
127
+ var zzpoly = polygonTester ( zigzag ) ;
127
128
inZigzag . forEach ( function ( pt ) {
128
129
expect ( zzpoly . contains ( pt ) ) . toBe ( true ) ;
129
130
} ) ;
130
131
notInZigzag . forEach ( function ( pt ) {
131
132
expect ( zzpoly . contains ( pt ) ) . toBe ( false ) ;
132
133
} ) ;
133
134
134
- var donutpoly = polygon ( donut ) ,
135
- donut2poly = polygon ( donut2 ) ;
135
+ var donutpoly = polygonTester ( donut ) ,
136
+ donut2poly = polygonTester ( donut2 ) ;
136
137
inDonut . forEach ( function ( pt ) {
137
138
expect ( donutpoly . contains ( pt ) ) . toBe ( true ) ;
138
139
expect ( donut2poly . contains ( pt ) ) . toBe ( true ) ;
0 commit comments