@@ -76,13 +76,13 @@ test('Longest side angle', () => {
7676 expect ( BuildingShapeUtils . longestSideAngle ( rightTriangle ) ) . toBe ( - Math . PI / 4 ) ;
7777} ) ;
7878
79- describe ( 'isSelfIntersecting' , ( ) => {
80- test . each ( [
81- [ '<way id="1"><nd ref="1"/><nd ref="2"/></ way>' , false , 'open non-intersecting' ] ,
82- [ '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="1 "/></way>' , false , 'closed non- intersecting' ] ,
83- [ '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="2 "/></ way>' , true , 'open intersecting' ] ,
84- [ '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="4"/><nd ref="3"/><nd ref="1"/></ way>' , true , 'closed intersecting' ] ,
85- ] ) ( ' ${description}' , ( way , expected , description ) => {
79+ describe . each ( [
80+ [ '<way id="1"><nd ref="1"/><nd ref="2"/></way>' , false , 'open non-intersecting' ] ,
81+ [ '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="1"/></ way>' , false , 'closed non-intersecting' ] ,
82+ [ '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="2 "/></way>' , true , 'open intersecting' ] ,
83+ [ '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="4 "/><nd ref="3"/><nd ref="1"/></ way>' , true , 'closed intersecting' ] ,
84+ ] ) ( 'isSelfIntersecting' , ( way , expected , description ) => {
85+ test ( ` ${ description } ` , ( ) => {
8686 let parser = new window . DOMParser ( ) ;
8787 let xml = parser . parseFromString ( way , 'text/xml' ) . getElementsByTagName ( 'way' ) [ 0 ] ;
8888 expect ( BuildingShapeUtils . isSelfIntersecting ( xml ) ) . toBe ( expected ) ;
@@ -108,6 +108,16 @@ rightTriangle2.lineTo(1, -1);
108108test ( 'Vertex Angles counterclockwise' , ( ) => {
109109 expect ( BuildingShapeUtils . vertexAngle ( rightTriangle2 ) ) . toStrictEqual ( [ - Math . PI / 2 , - Math . PI / 4 , - Math . PI / 4 ] ) ;
110110} ) ;
111- // test surrounds
111+
112+ describe . each ( [
113+ [ [ - 1 , - 1 ] , false , 'Outside' ] ,
114+ [ [ 1 , 1 ] , true , 'Share Node' ] ,
115+ [ [ .5 , .5 ] , true , 'Inside' ] ,
116+ [ [ 0 , 0 ] , true , 'Border' ] ,
117+ ] ) ( 'Surrounds' , ( point , expected , description ) => {
118+ test ( `${ description } ` , ( ) => {
119+ expect ( BuildingShapeUtils . surrounds ( rightTriangle , point ) ) . toBe ( expected ) ;
120+ } ) ;
121+ } ) ;
112122
113123// test calcRadius
0 commit comments