@@ -75,3 +75,32 @@ test('Longest side angle', () => {
7575 expect ( rightTriangle . extractPoints ( ) . shape . length ) . toBe ( 3 ) ;
7676 expect ( BuildingShapeUtils . longestSideAngle ( rightTriangle ) ) . toBe ( - Math . PI / 4 ) ;
7777} ) ;
78+
79+ // Combine these next 4 into a test runner.
80+ test ( 'non-intersecting open way' , ( ) => {
81+ const way = '<way id="1"><nd ref="1"/><nd ref="2"/></way>' ;
82+ let parser = new window . DOMParser ( ) ;
83+ let xml = parser . parseFromString ( way , 'text/xml' ) . getElementsByTagName ( 'way' ) [ 0 ] ;
84+ expect ( BuildingShapeUtils . isSelfIntersecting ( xml ) ) . toBe ( false ) ;
85+ } ) ;
86+
87+ test ( 'non-intersecting closed way' , ( ) => {
88+ const way = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="1"/></way>' ;
89+ let parser = new window . DOMParser ( ) ;
90+ let xml = parser . parseFromString ( way , 'text/xml' ) . getElementsByTagName ( 'way' ) [ 0 ] ;
91+ expect ( BuildingShapeUtils . isSelfIntersecting ( xml ) ) . toBe ( false ) ;
92+ } ) ;
93+
94+ test ( 'intersecting open way' , ( ) => {
95+ const way = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="2"/></way>' ;
96+ let parser = new window . DOMParser ( ) ;
97+ let xml = parser . parseFromString ( way , 'text/xml' ) . getElementsByTagName ( 'way' ) [ 0 ] ;
98+ expect ( BuildingShapeUtils . isSelfIntersecting ( xml ) ) . toBe ( true ) ;
99+ } ) ;
100+
101+ test ( 'intersecting closed way' , ( ) => {
102+ const way = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="4"/><nd ref="3"/><nd ref="1"/></way>' ;
103+ let parser = new window . DOMParser ( ) ;
104+ let xml = parser . parseFromString ( way , 'text/xml' ) . getElementsByTagName ( 'way' ) [ 0 ] ;
105+ expect ( BuildingShapeUtils . isSelfIntersecting ( xml ) ) . toBe ( true ) ;
106+ } ) ;
0 commit comments