@@ -14,7 +14,7 @@ test("turf-boolean-disjoint", (t) => {
1414 . sync ( path . join ( __dirname , "test" , "true" , "**" , "*.geojson" ) )
1515 . forEach ( ( filepath ) => {
1616 const name = path . parse ( filepath ) . name ;
17- const geojson = loadJsonFileSync ( filepath ) ;
17+ const geojson : GeoJSON . FeatureCollection = loadJsonFileSync ( filepath ) ;
1818 const feature1 = geojson . features [ 0 ] ;
1919 const feature2 = geojson . features [ 1 ] ;
2020 const result = disjoint ( feature1 , feature2 ) ;
@@ -30,7 +30,7 @@ test("turf-boolean-disjoint", (t) => {
3030 . sync ( path . join ( __dirname , "test" , "false" , "**" , "*.geojson" ) )
3131 . forEach ( ( filepath ) => {
3232 const name = path . parse ( filepath ) . name ;
33- const geojson = loadJsonFileSync ( filepath ) ;
33+ const geojson : GeoJSON . FeatureCollection = loadJsonFileSync ( filepath ) ;
3434 const feature1 = geojson . features [ 0 ] ;
3535 const feature2 = geojson . features [ 1 ] ;
3636 const result = disjoint ( feature1 , feature2 ) ;
@@ -117,64 +117,95 @@ test("turf-boolean-disjoin with ignoreSelfIntersections option", (t) => {
117117 } ,
118118 } ;
119119
120- // Test without ignoringSelfIntersections option (default behavior)
120+ const selfIntersectingPolygon : GeoJSON . Feature < GeoJSON . Polygon > = {
121+ type : "Feature" ,
122+ properties : { } ,
123+ geometry : {
124+ type : "Polygon" ,
125+ coordinates : [
126+ [
127+ [ 1.5 , 1 ] ,
128+ [ 2 , 1.5 ] ,
129+
130+ [ 3 , 0.5 ] ,
131+ [ - 1 , 3 ] ,
132+ [ 1.5 , 1 ] ,
133+ ] ,
134+ ] ,
135+ } ,
136+ } ;
137+
138+ // Test with ignoringSelfIntersections = true (default behavior)
121139 let result = disjoint ( selfIntersectingLineString , nonIntersectingLineString ) ;
122- t . false (
140+ t . true (
123141 result ,
124- "[false ] " +
125- "selfIntersectingLineString-LineString (ignoreSelfIntersections=false )"
142+ "[true ] " +
143+ "selfIntersectingLineString-LineString (ignoreSelfIntersections=true )"
126144 ) ;
127145 result = disjoint ( selfIntersectingLineString , intersectingLineString ) ;
128146 t . false (
129147 result ,
130148 "[false] " +
131- "selfIntersectingLineString-LineString (ignoreSelfIntersections=false )"
149+ "selfIntersectingLineString-LineString (ignoreSelfIntersections=true )"
132150 ) ;
133151 result = disjoint ( selfIntersectingLineString , intersectingPolygon ) ;
134152 t . false (
135153 result ,
136154 "[false] " +
137- "selfIntersectingLineString-Polygon (ignoreSelfIntersections=false )"
155+ "selfIntersectingLineString-Polygon (ignoreSelfIntersections=true )"
138156 ) ;
139157 result = disjoint ( selfIntersectingLineString , nonIntersectingPolygon ) ;
140- t . false (
158+ t . true (
141159 result ,
142- "[false] " +
143- "selfIntersectingLineString-Polygon (ignoreSelfIntersections=false)"
160+ "[true] " +
161+ "selfIntersectingLineString-Polygon (ignoreSelfIntersections=true)"
162+ ) ;
163+ result = disjoint ( selfIntersectingPolygon , nonIntersectingPolygon ) ;
164+ t . true (
165+ result ,
166+ "[true] " + "selfIntersectingPolygon-Polygon (ignoreSelfIntersections=true)"
144167 ) ;
145168
146- // Test with ignoringSelfIntersections option
169+ // Test with ignoringSelfIntersections option set to false
147170 result = disjoint ( selfIntersectingLineString , nonIntersectingLineString , {
148- ignoreSelfIntersections : true ,
171+ ignoreSelfIntersections : false ,
149172 } ) ;
150- t . true (
173+ t . false (
151174 result ,
152- "[true ] " +
153- "selfIntersectingLineString-LineString (ignoreSelfIntersections=true )"
175+ "[false ] " +
176+ "selfIntersectingLineString-LineString (ignoreSelfIntersections=false )"
154177 ) ;
155178 result = disjoint ( selfIntersectingLineString , intersectingLineString , {
156- ignoreSelfIntersections : true ,
179+ ignoreSelfIntersections : false ,
157180 } ) ;
158181 t . false (
159182 result ,
160183 "[false] " +
161- "selfIntersectingLineString-LineString (ignoreSelfIntersections=true )"
184+ "selfIntersectingLineString-LineString (ignoreSelfIntersections=false )"
162185 ) ;
163186 result = disjoint ( selfIntersectingLineString , intersectingPolygon , {
164- ignoreSelfIntersections : true ,
187+ ignoreSelfIntersections : false ,
165188 } ) ;
166189 t . false (
167190 result ,
168191 "[false] " +
169- "selfIntersectingLineString-Polygon (ignoreSelfIntersections=true )"
192+ "selfIntersectingLineString-Polygon (ignoreSelfIntersections=false )"
170193 ) ;
171194 result = disjoint ( selfIntersectingLineString , nonIntersectingPolygon , {
172- ignoreSelfIntersections : true ,
195+ ignoreSelfIntersections : false ,
173196 } ) ;
174- t . true (
197+ t . false (
175198 result ,
176- "[true] " +
177- "selfIntersectingLineString-Polygon (ignoreSelfIntersections=true)"
199+ "[false] " +
200+ "selfIntersectingLineString-Polygon (ignoreSelfIntersections=false)"
201+ ) ;
202+ result = disjoint ( selfIntersectingPolygon , nonIntersectingPolygon , {
203+ ignoreSelfIntersections : false ,
204+ } ) ;
205+ t . false (
206+ result ,
207+ "[false] " +
208+ "selfIntersectingPolygon-Polygon (ignoreSelfIntersections=false)"
178209 ) ;
179210
180211 t . end ( ) ;
0 commit comments