-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from pyturf/boolean_intersects
Add boolean-intersects module
- Loading branch information
Showing
49 changed files
with
1,394 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from turf.boolean_intersects._boolean_intersects import boolean_intersects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from typing import Any | ||
|
||
from turf.boolean_disjoint import boolean_disjoint | ||
|
||
|
||
def boolean_intersects(feature_1: Any, feature_2: Any) -> bool: | ||
""" | ||
Returns true if the two geometries intersect. | ||
:param feature_1: {GeoJSON} feature_1 any Feature or Geometry | ||
:param feature_2: {GeoJSON} feature_2 any Feature or Geometry | ||
:return: boolean True/False if features intersect | ||
""" | ||
return not boolean_disjoint(feature_1, feature_2) |
21 changes: 21 additions & 0 deletions
21
turf/boolean_intersects/tests/false/LineString-LineString.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [[0, 0], [12, 2], [12, 3], [12, 4]] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [[1, 1], [1, 2], [1, 3], [1, 4]] | ||
} | ||
} | ||
] | ||
} |
21 changes: 21 additions & 0 deletions
21
turf/boolean_intersects/tests/false/LineString-Point.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [[1, 1], [1, 2], [1, 3], [1, 4]] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [0, 0] | ||
} | ||
} | ||
] | ||
} |
21 changes: 21 additions & 0 deletions
21
turf/boolean_intersects/tests/false/LineString-Polygon.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [[0, 0], [12, 2], [12, 3], [12, 4]] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "Polygon", | ||
"coordinates": [[[-1, 2], [3, 2], [3, 3], [-1, 3], [-1, 2]]] | ||
} | ||
} | ||
] | ||
} |
21 changes: 21 additions & 0 deletions
21
turf/boolean_intersects/tests/false/MultiPoint-LineString.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "MultiPoint", | ||
"coordinates": [[2, 2], [0, 0]] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [[1, 1], [1, 2], [1, 3], [1, 4]] | ||
} | ||
} | ||
] | ||
} |
21 changes: 21 additions & 0 deletions
21
turf/boolean_intersects/tests/false/MultiPoint-MultiPoint.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "MultiPoint", | ||
"coordinates": [[0, 0], [13, 13]] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "MultiPoint", | ||
"coordinates": [[1, 1], [12, 12]] | ||
} | ||
} | ||
] | ||
} |
21 changes: 21 additions & 0 deletions
21
turf/boolean_intersects/tests/false/MultiPoint-Point.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "MultiPoint", | ||
"coordinates": [[1, 1], [12, 12]] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [0, 0] | ||
} | ||
} | ||
] | ||
} |
21 changes: 21 additions & 0 deletions
21
turf/boolean_intersects/tests/false/MultiPoint-Polygon.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "MultiPoint", | ||
"coordinates": [[-3, -3], [-2, -2]] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "Polygon", | ||
"coordinates": [[[-1, 2], [3, 2], [3, 3], [-1, 3], [-1, 2]]] | ||
} | ||
} | ||
] | ||
} |
97 changes: 97 additions & 0 deletions
97
turf/boolean_intersects/tests/false/MultiPolygon-Polygon.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"fill": "#ff0000" | ||
}, | ||
"geometry": { | ||
"type": "MultiPolygon", | ||
"coordinates": [ | ||
[ | ||
[ | ||
[ | ||
122.6953125, | ||
-19.186677697957833 | ||
], | ||
[ | ||
128.759765625, | ||
-19.186677697957833 | ||
], | ||
[ | ||
128.759765625, | ||
-15.28418511407642 | ||
], | ||
[ | ||
122.6953125, | ||
-15.28418511407642 | ||
], | ||
[ | ||
122.6953125, | ||
-19.186677697957833 | ||
] | ||
] | ||
], | ||
[ | ||
[ | ||
[ | ||
123.74999999999999, | ||
-25.918526162075153 | ||
], | ||
[ | ||
130.25390625, | ||
-25.918526162075153 | ||
], | ||
[ | ||
130.25390625, | ||
-20.715015145512087 | ||
], | ||
[ | ||
123.74999999999999, | ||
-20.715015145512087 | ||
], | ||
[ | ||
123.74999999999999, | ||
-25.918526162075153 | ||
] | ||
] | ||
] | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"fill": "#0000ff" | ||
}, | ||
"geometry": { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[ | ||
116.98242187499999, | ||
-24.647017162630352 | ||
], | ||
[ | ||
122.87109375, | ||
-24.647017162630352 | ||
], | ||
[ | ||
122.87109375, | ||
-20.34462694382967 | ||
], | ||
[ | ||
116.98242187499999, | ||
-20.34462694382967 | ||
], | ||
[ | ||
116.98242187499999, | ||
-24.647017162630352 | ||
] | ||
] | ||
] | ||
} | ||
} | ||
] | ||
} |
21 changes: 21 additions & 0 deletions
21
turf/boolean_intersects/tests/false/Point-LineString.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [0, 0] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [[1, 1], [1, 2], [1, 3], [1, 4]] | ||
} | ||
} | ||
] | ||
} |
21 changes: 21 additions & 0 deletions
21
turf/boolean_intersects/tests/false/Point-Multipoint.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [0, 0] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "MultiPoint", | ||
"coordinates": [[1, 1], [12, 12]] | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.