1- var polygon = require ( '@src/lib/polygon' ) ;
1+ var polygon = require ( '@src/lib/polygon' ) ,
2+ polygonTester = polygon . tester ;
23
3- describe ( 'polygon' , function ( ) {
4+ describe ( 'polygon.tester ' , function ( ) {
45 'use strict' ;
56
67 var squareCW = [ [ 0 , 0 ] , [ 0 , 1 ] , [ 1 , 1 ] , [ 1 , 0 ] ] ,
@@ -51,7 +52,7 @@ describe('polygon', function() {
5152 notInDonut = [ [ 1.5 , - 0.5 ] , [ 1.5 , 1.5 ] , [ 1.5 , 3.5 ] , [ - 0.5 , 1.5 ] , [ 3.5 , 1.5 ] ] ;
5253
5354 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 ] ] ) ;
5556 var pts = [ [ 0 , 3 ] , [ 4 , 3 ] , [ 2 , 1 ] , [ 2 , 5 ] ] ;
5657 pts . forEach ( function ( pt ) {
5758 expect ( poly . contains ( pt ) ) . toBe ( false ) ;
@@ -67,7 +68,7 @@ describe('polygon', function() {
6768 ] ;
6869
6970 polyPts . forEach ( function ( polyPt ) {
70- var poly = polygon ( polyPt ) ,
71+ var poly = polygonTester ( polyPt ) ,
7172 xArray = polyPt . map ( function ( pt ) { return pt [ 0 ] ; } ) ,
7273 yArray = polyPt . map ( function ( pt ) { return pt [ 1 ] ; } ) ;
7374
@@ -89,7 +90,7 @@ describe('polygon', function() {
8990 var np = 6 ; // number of intermediate points on each edge to test
9091
9192 polyPts . forEach ( function ( polyPt ) {
92- var poly = polygon ( polyPt ) ;
93+ var poly = polygonTester ( polyPt ) ;
9394 poly . pts . forEach ( function ( pt1 , i ) {
9495 if ( ! i ) return ;
9596 var pt0 = poly . pts [ i - 1 ] ,
@@ -123,16 +124,16 @@ describe('polygon', function() {
123124 } ) ;
124125
125126 it ( 'should find only the right interior points' , function ( ) {
126- var zzpoly = polygon ( zigzag ) ;
127+ var zzpoly = polygonTester ( zigzag ) ;
127128 inZigzag . forEach ( function ( pt ) {
128129 expect ( zzpoly . contains ( pt ) ) . toBe ( true ) ;
129130 } ) ;
130131 notInZigzag . forEach ( function ( pt ) {
131132 expect ( zzpoly . contains ( pt ) ) . toBe ( false ) ;
132133 } ) ;
133134
134- var donutpoly = polygon ( donut ) ,
135- donut2poly = polygon ( donut2 ) ;
135+ var donutpoly = polygonTester ( donut ) ,
136+ donut2poly = polygonTester ( donut2 ) ;
136137 inDonut . forEach ( function ( pt ) {
137138 expect ( donutpoly . contains ( pt ) ) . toBe ( true ) ;
138139 expect ( donut2poly . contains ( pt ) ) . toBe ( true ) ;
0 commit comments