Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dart-pub-publish-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dart-pub-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dart-unit-tests-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dart-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-code-coverage-reporting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@v1
with:
Expand Down
26 changes: 13 additions & 13 deletions lib/src/booleans/boolean_disjoint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import '../polygon_to_line.dart';
/// booleanDisjoint(line, point);
/// //=true
/// ```
bool booleanDisjoint(GeoJSONObject feature1, GeoJSONObject feature2) {
bool booleanDisjoint(GeoJSONObject feature1, GeoJSONObject feature2, {bool ignoreSelfIntersections = false}) {
var bool = true;
flattenEach(
feature1,
Expand All @@ -30,7 +30,7 @@ bool booleanDisjoint(GeoJSONObject feature1, GeoJSONObject feature2) {
if (!bool) {
return bool;
}
bool = _disjoint(flatten1.geometry!, flatten2.geometry!);
bool = _disjoint(flatten1.geometry!, flatten2.geometry!, ignoreSelfIntersections);
},
);
},
Expand All @@ -39,7 +39,7 @@ bool booleanDisjoint(GeoJSONObject feature1, GeoJSONObject feature2) {
}

/// Disjoint operation for simple Geometries ([Point]/[LineString]/[Polygon])
bool _disjoint(GeometryType geom1, GeometryType geom2) {
bool _disjoint(GeometryType geom1, GeometryType geom2, bool ignoreSelfIntersections) {
if (geom1 is Point) {
if (geom2 is Point) {
return geom1.coordinates != geom2.coordinates;
Expand All @@ -52,17 +52,17 @@ bool _disjoint(GeometryType geom1, GeometryType geom2) {
if (geom2 is Point) {
return !_isPointOnLine(geom1, geom2);
} else if (geom2 is LineString) {
return !_isLineOnLine(geom1, geom2);
return !_isLineOnLine(geom1, geom2, ignoreSelfIntersections);
} else if (geom2 is Polygon) {
return !_isLineInPoly(geom2, geom1);
return !_isLineInPoly(geom2, geom1, ignoreSelfIntersections);
}
} else if (geom1 is Polygon) {
if (geom2 is Point) {
return !booleanPointInPolygon((geom2).coordinates, geom1);
} else if (geom2 is LineString) {
return !_isLineInPoly(geom1, geom2);
return !_isLineInPoly(geom1, geom2, ignoreSelfIntersections);
} else if (geom2 is Polygon) {
return !_isPolyInPoly(geom2, geom1);
return !_isPolyInPoly(geom2, geom1, ignoreSelfIntersections);
}
}
return false;
Expand All @@ -79,21 +79,21 @@ bool _isPointOnLine(LineString lineString, Point pt) {
return false;
}

bool _isLineOnLine(LineString lineString1, LineString lineString2) {
var doLinesIntersect = lineIntersect(lineString1, lineString2);
bool _isLineOnLine(LineString lineString1, LineString lineString2, bool ignoreSelfIntersections) {
var doLinesIntersect = lineIntersect(lineString1, lineString2, ignoreSelfIntersections: ignoreSelfIntersections);
if (doLinesIntersect.features.isNotEmpty) {
return true;
}
return false;
}

bool _isLineInPoly(Polygon polygon, LineString lineString) {
bool _isLineInPoly(Polygon polygon, LineString lineString, bool ignoreSelfIntersections) {
for (var coord in lineString.coordinates) {
if (booleanPointInPolygon(coord, polygon)) {
return true;
}
}
var doLinesIntersect = lineIntersect(lineString, polygonToLine(polygon));
var doLinesIntersect = lineIntersect(lineString, polygonToLine(polygon), ignoreSelfIntersections: ignoreSelfIntersections);
if (doLinesIntersect.features.isNotEmpty) {
return true;
}
Expand All @@ -103,7 +103,7 @@ bool _isLineInPoly(Polygon polygon, LineString lineString) {
/// Is [Polygon] (geom1) in [Polygon] (geom2)
/// Only takes into account outer rings
/// See http://stackoverflow.com/a/4833823/1979085
bool _isPolyInPoly(Polygon feature1, Polygon feature2) {
bool _isPolyInPoly(Polygon feature1, Polygon feature2, bool ignoreSelfIntersections) {
for (var coord1 in feature1.coordinates[0]) {
if (booleanPointInPolygon(coord1, feature2)) {
return true;
Expand All @@ -115,7 +115,7 @@ bool _isPolyInPoly(Polygon feature1, Polygon feature2) {
}
}
var doLinesIntersect =
lineIntersect(polygonToLine(feature1), polygonToLine(feature2));
lineIntersect(polygonToLine(feature1), polygonToLine(feature2), ignoreSelfIntersections: ignoreSelfIntersections);
if (doLinesIntersect.features.isNotEmpty) {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/booleans/boolean_intersects.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'boolean_disjoint.dart';
/// booleanIntersects(line, point);
/// //=true
/// ```
bool booleanIntersects(GeoJSONObject feature1, GeoJSONObject feature2) {
bool booleanIntersects(GeoJSONObject feature1, GeoJSONObject feature2, {bool ignoreSelfIntersections = true}) {
var result = false;
flattenEach(
feature1,
Expand All @@ -22,7 +22,7 @@ bool booleanIntersects(GeoJSONObject feature1, GeoJSONObject feature2) {
if (result) {
return true;
}
result = !booleanDisjoint(flatten1, flatten2);
result = !booleanDisjoint(flatten1, flatten2, ignoreSelfIntersections: ignoreSelfIntersections);
},
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-11, -12],
[-13, -12],
[-13, -13],
[-11, -13],
[-11, -12]
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[0, 0],
[2, 2],
[0, 2],
[2, 0],
[0, 0]
]
]
}
}
]
}
Loading