-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added generalized code * Update contains * Add coveredby * Add covers * Update disjoint * Update intersects * Add touches * Update within * Update test file * Add _isparallel * Fix overlaps and crosses tests * clean up bools * Add more info to test printouts * Update touches doc fail * Actually fix touches docs * Add double geom feature function * Update test output text * Split while loop into helper functions
- Loading branch information
Showing
15 changed files
with
2,135 additions
and
607 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,64 @@ | ||
# # Containment | ||
# # Contains | ||
|
||
export contains | ||
|
||
#= | ||
## What is contains? | ||
The contains function checks if a given geometry completly contains another | ||
geometry, or in other words, that the second geometry is completly within the | ||
first. This requires that the two interiors intersect and that the interior and | ||
boundary of the second geometry is not in the exterior of the first geometry. | ||
To provide an example, consider these two lines: | ||
```@example contains | ||
using GeometryOps | ||
using GeometryOps.GeometryBasics | ||
using Makie | ||
using CairoMakie | ||
l1 = GI.LineString([(0.0, 0.0), (1.0, 0.0), (0.0, 0.1)]) | ||
l2 = GI.LineString([(0.25, 0.0), (0.75, 0.0)]) | ||
f, a, p = lines(GI.getpoint(l1), color = :blue) | ||
scatter!(GI.getpoint(l1), color = :blue) | ||
lines!(GI.getpoint(l2), color = :orange) | ||
scatter!(GI.getpoint(l2), color = :orange) | ||
``` | ||
We can see that all of the points and edges of l2 are within l1, so l1 contains | ||
l2. However, l2 does not contain l1. | ||
```@example contains | ||
contains(l1, l2) # returns true | ||
contains(l2, l1) # returns false | ||
``` | ||
## Implementation | ||
This is the GeoInterface-compatible implementation. | ||
Given that contains is the exact opposite of within, we simply pass the two | ||
inputs variables, swapped in order, to within. | ||
=# | ||
|
||
""" | ||
contains(ft1::AbstractGeometry, ft2::AbstractGeometry)::Bool | ||
contains(g1::AbstractGeometry, g2::AbstractGeometry)::Bool | ||
Return true if the second geometry is completely contained by the first | ||
geometry. The interiors of both geometries must intersect and the interior and | ||
boundary of the secondary (g2) must not intersect the exterior of the first | ||
(g1). | ||
Return true if the second geometry is completely contained by the first geometry. | ||
The interiors of both geometries must intersect and, the interior and boundary of the secondary (geometry b) | ||
must not intersect the exterior of the primary (geometry a). | ||
`contains` returns the exact opposite result of `within`. | ||
## Examples | ||
```jldoctest | ||
import GeometryOps as GO, GeoInterface as GI | ||
line = GI.LineString([(1, 1), (1, 2), (1, 3), (1, 4)]) | ||
point = (1, 2) | ||
point = GI.Point((1, 2)) | ||
GO.contains(line, point) | ||
# output | ||
true | ||
``` | ||
""" | ||
contains(g1, g2)::Bool = within(g2, g1) | ||
contains(g1, g2) = GeometryOps.within(g2, g1) |
Oops, something went wrong.