@@ -19,7 +19,7 @@ import '../polygon_to_line.dart';
1919/// booleanDisjoint(line, point);
2020/// //=true
2121/// ```
22- bool booleanDisjoint (GeoJSONObject feature1, GeoJSONObject feature2) {
22+ bool booleanDisjoint (GeoJSONObject feature1, GeoJSONObject feature2, { bool ignoreSelfIntersections = false } ) {
2323 var bool = true ;
2424 flattenEach (
2525 feature1,
@@ -30,7 +30,7 @@ bool booleanDisjoint(GeoJSONObject feature1, GeoJSONObject feature2) {
3030 if (! bool ) {
3131 return bool ;
3232 }
33- bool = _disjoint (flatten1.geometry! , flatten2.geometry! );
33+ bool = _disjoint (flatten1.geometry! , flatten2.geometry! , ignoreSelfIntersections );
3434 },
3535 );
3636 },
@@ -39,7 +39,7 @@ bool booleanDisjoint(GeoJSONObject feature1, GeoJSONObject feature2) {
3939}
4040
4141/// Disjoint operation for simple Geometries ([Point] /[LineString] /[Polygon] )
42- bool _disjoint (GeometryType geom1, GeometryType geom2) {
42+ bool _disjoint (GeometryType geom1, GeometryType geom2, bool ignoreSelfIntersections ) {
4343 if (geom1 is Point ) {
4444 if (geom2 is Point ) {
4545 return geom1.coordinates != geom2.coordinates;
@@ -52,17 +52,17 @@ bool _disjoint(GeometryType geom1, GeometryType geom2) {
5252 if (geom2 is Point ) {
5353 return ! _isPointOnLine (geom1, geom2);
5454 } else if (geom2 is LineString ) {
55- return ! _isLineOnLine (geom1, geom2);
55+ return ! _isLineOnLine (geom1, geom2, ignoreSelfIntersections );
5656 } else if (geom2 is Polygon ) {
57- return ! _isLineInPoly (geom2, geom1);
57+ return ! _isLineInPoly (geom2, geom1, ignoreSelfIntersections );
5858 }
5959 } else if (geom1 is Polygon ) {
6060 if (geom2 is Point ) {
6161 return ! booleanPointInPolygon ((geom2).coordinates, geom1);
6262 } else if (geom2 is LineString ) {
63- return ! _isLineInPoly (geom1, geom2);
63+ return ! _isLineInPoly (geom1, geom2, ignoreSelfIntersections );
6464 } else if (geom2 is Polygon ) {
65- return ! _isPolyInPoly (geom2, geom1);
65+ return ! _isPolyInPoly (geom2, geom1, ignoreSelfIntersections );
6666 }
6767 }
6868 return false ;
@@ -79,21 +79,21 @@ bool _isPointOnLine(LineString lineString, Point pt) {
7979 return false ;
8080}
8181
82- bool _isLineOnLine (LineString lineString1, LineString lineString2) {
83- var doLinesIntersect = lineIntersect (lineString1, lineString2);
82+ bool _isLineOnLine (LineString lineString1, LineString lineString2, bool ignoreSelfIntersections ) {
83+ var doLinesIntersect = lineIntersect (lineString1, lineString2, ignoreSelfIntersections : ignoreSelfIntersections );
8484 if (doLinesIntersect.features.isNotEmpty) {
8585 return true ;
8686 }
8787 return false ;
8888}
8989
90- bool _isLineInPoly (Polygon polygon, LineString lineString) {
90+ bool _isLineInPoly (Polygon polygon, LineString lineString, bool ignoreSelfIntersections ) {
9191 for (var coord in lineString.coordinates) {
9292 if (booleanPointInPolygon (coord, polygon)) {
9393 return true ;
9494 }
9595 }
96- var doLinesIntersect = lineIntersect (lineString, polygonToLine (polygon));
96+ var doLinesIntersect = lineIntersect (lineString, polygonToLine (polygon), ignoreSelfIntersections : ignoreSelfIntersections );
9797 if (doLinesIntersect.features.isNotEmpty) {
9898 return true ;
9999 }
@@ -103,7 +103,7 @@ bool _isLineInPoly(Polygon polygon, LineString lineString) {
103103/// Is [Polygon] (geom1) in [Polygon] (geom2)
104104/// Only takes into account outer rings
105105/// See http://stackoverflow.com/a/4833823/1979085
106- bool _isPolyInPoly (Polygon feature1, Polygon feature2) {
106+ bool _isPolyInPoly (Polygon feature1, Polygon feature2, bool ignoreSelfIntersections ) {
107107 for (var coord1 in feature1.coordinates[0 ]) {
108108 if (booleanPointInPolygon (coord1, feature2)) {
109109 return true ;
@@ -115,7 +115,7 @@ bool _isPolyInPoly(Polygon feature1, Polygon feature2) {
115115 }
116116 }
117117 var doLinesIntersect =
118- lineIntersect (polygonToLine (feature1), polygonToLine (feature2));
118+ lineIntersect (polygonToLine (feature1), polygonToLine (feature2), ignoreSelfIntersections : ignoreSelfIntersections );
119119 if (doLinesIntersect.features.isNotEmpty) {
120120 return true ;
121121 }
0 commit comments