Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into as/deltri
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 committed Jul 20, 2024
2 parents bb4a266 + 2da44be commit 289e588
Show file tree
Hide file tree
Showing 35 changed files with 108 additions and 107 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
install-package: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
- run: |
julia --project=docs -e '
using Documenter: DocMeta, doctest
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<img width="400" alt="GeometryOps.jl" src="https://github.com/JuliaGeo/GeometryOps.jl/assets/32143268/92c5526d-23a9-4e01-aee0-2fcea99c5001">

![Lifecycle:Experimental](https://img.shields.io/badge/Lifecycle-Experimental-339999)
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaGeo.github.io/GeometryOps.jl/v0.1.10/)
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaGeo.github.io/GeometryOps.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaGeo.github.io/GeometryOps.jl/dev/)
[![Build Status](https://github.com/JuliaGeo/GeometryOps.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/JuliaGeo/GeometryOps.jl/actions/workflows/CI.yml?query=branch%3Amain)

Expand Down
4 changes: 2 additions & 2 deletions docs/src/tutorials/creating_geometry.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Read the land `MultiPolygon`s as a `GeoJSON.FeatureCollection`.
land_geo = GeoJSON.read(land_path)
````

We then need to create a figure with a `GeoAxis` that can handle the projection between `source` and `destinaton` CRS. For GeoMakie, `source` is the CRS of the input and `dest` is the CRS you want to visualize in.
We then need to create a figure with a `GeoAxis` that can handle the projection between `source` and `destination` CRS. For GeoMakie, `source` is the CRS of the input and `dest` is the CRS you want to visualize in.

````@example creating_geometry
fig = Figure(size=(1000, 500));
Expand Down Expand Up @@ -267,7 +267,7 @@ y = r .* (k + 1) .* sin.(ϴ) .- r .* sin.((k + 1) .* ϴ);
ring4 = GI.LinearRing(Point.(zip(x, y)))
````

But this time when we create the `Polygon` we beed to specify the `CRS` at the time of creation, making it a geospatial polygon
But this time when we create the `Polygon` we need to specify the `CRS` at the time of creation, making it a geospatial polygon

````@example creating_geometry
geopoly1 = GI.Polygon([ring4], crs = source_crs1)
Expand Down
2 changes: 1 addition & 1 deletion ext/GeometryOpsProjExt/reproject.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function reproject(geom;
end

# If its still nothing, error
isnothing(source_crs) && throw(ArgumentError("geom has no crs attatched. Pass a `source_crs` keyword"))
isnothing(source_crs) && throw(ArgumentError("geom has no crs attached. Pass a `source_crs` keyword"))

# Otherwise reproject
reproject(geom, source_crs, target_crs; kw...)
Expand Down
4 changes: 2 additions & 2 deletions src/methods/angles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ This is computed differently for different geometries:
- The angles of a point is an empty vector.
- The angles of a single line segment is an empty vector.
- The angles of a linestring or linearring is a vector of angles formed by the curve.
- The angles of a polygin is a vector of vectors of angles formed by each ring.
- The angles of a polygon is a vector of vectors of angles formed by each ring.
- The angles of a multi-geometry collection is a vector of the angles of each of the
sub-geometries as defined above.
Expand Down Expand Up @@ -83,7 +83,7 @@ function _angles(::Type{T}, ::GI.LinearRingTrait, geom; interior = true) where T
end

#= The angles of a polygon is a vector of polygon angles. Note that if there are holes
within the polyogn, the angles will be listed after the exterior ring angles in order of the
within the polygon, the angles will be listed after the exterior ring angles in order of the
holes. All angles, including the hole angles, are interior angles of the polygon.=#
function _angles(::Type{T}, ::GI.PolygonTrait, geom) where T
angles = _angles(T, GI.LinearRingTrait(), GI.getexterior(geom); interior = true)
Expand Down
4 changes: 2 additions & 2 deletions src/methods/area.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ lines!(
f
```
The points are ordered in a counterclockwise fashion, which means that the signed area
is negative. If we reverse the order of the points, we get a postive area.
is negative. If we reverse the order of the points, we get a positive area.
```@example rect
GO.signed_area(rect) # -1.0
```
Expand Down Expand Up @@ -76,7 +76,7 @@ end
signed_area(geom, [T = Float64])::T
Returns the signed area of a single geometry, based on winding order.
This is computed slighly differently for different geometries:
This is computed slightly differently for different geometries:
- The signed area of a point is always zero.
- The signed area of a curve is always zero.
Expand Down
2 changes: 1 addition & 1 deletion src/methods/centroid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ LineString or LinearRing when they are closed, for example as the interior hole
of a polygon.
The helper functions centroid_and_length and centroid_and_area are made
availible just in case the user also needs the area or length to decrease
available just in case the user also needs the area or length to decrease
repeat computation.
=#
"""
Expand Down
18 changes: 9 additions & 9 deletions src/methods/clipping/clipping_processor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ poly_a, including its intersection points with poly_b. The information stored in
PolyNode is needed for clipping using the Greiner-Hormann clipping algorithm.
Note: After calling this function, a_list is not fully formed because the neighboring
indicies of the intersection points in b_list still need to be updated. Also we still have
indices of the intersection points in b_list still need to be updated. Also we still have
not update the entry and exit flags for a_list.
The a_idx_list is a list of the indicies of intersection points in a_list. The value at
The a_idx_list is a list of the indices of intersection points in a_list. The value at
index i of a_idx_list is the location in a_list where the ith intersection point lies.
=#
function _build_a_list(::Type{T}, poly_a, poly_b; exact) where T
Expand Down Expand Up @@ -179,7 +179,7 @@ creates a vector of PolyNodes to represent poly_b. The information stored in eac
is needed for clipping using the Greiner-Hormann clipping algorithm.
Note: after calling this function, b_list is not fully updated. The entry/exit flags still
need to be updated. However, the neightbor value in a_list is now updated.
need to be updated. However, the neighbor value in a_list is now updated.
=#
function _build_b_list(::Type{T}, a_idx_list, a_list, n_b_intrs, poly_b) where T
# Sort intersection points by insertion order in b_list
Expand Down Expand Up @@ -609,8 +609,8 @@ _get_poly_type(::Type{T}) where T =
#=
_find_non_cross_orientation(a_list, b_list, a_poly, b_poly; exact)
For polygns with no crossing intersection points, either one polygon is inside of another,
or they are seperate polygons with no intersection (other than an edge or point).
For polygons with no crossing intersection points, either one polygon is inside of another,
or they are separate polygons with no intersection (other than an edge or point).
Return two booleans that represent if a is inside b (potentially with shared edges / points)
and visa versa if b is inside of a.
Expand Down Expand Up @@ -655,7 +655,7 @@ function _add_holes_to_polys!(::Type{T}, return_polys, hole_iterator, remove_pol
append!(remove_poly_idx, falses(n_new_pieces))
n_new_per_poly += n_new_pieces
end
if !on_ext && !out_ext # hole is completly within exterior
if !on_ext && !out_ext # hole is completely within exterior
push!(curr_poly.geom, new_hole)
else # hole is partially within and outside of polygon's exterior
new_polys = difference(curr_poly_ext, new_hole_poly, T; target=GI.PolygonTrait())
Expand All @@ -669,7 +669,7 @@ function _add_holes_to_polys!(::Type{T}, return_polys, hole_iterator, remove_pol
n_new_per_poly += n_new_polys
end
end
# polygon is completly within hole
# polygon is completely within hole
elseif coveredby(curr_poly_ext, GI.Polygon(StaticArrays.SVector(curr_hole)))
remove_poly_idx[j] = true
end
Expand All @@ -687,7 +687,7 @@ end
The new hole is combined with any existing holes in curr_poly. The holes can be combined
into a larger hole if they are intersecting. If this happens, then the new, combined hole is
returned with the orignal holes making up the new hole removed from curr_poly. Additionally,
returned with the original holes making up the new hole removed from curr_poly. Additionally,
if the combined holes form a ring, the interior is added to the return_polys as a new
polygon piece. Additionally, holes leftover after combination will be checked for it they
are in the "main" polygon or in one of these new pieces and moved accordingly.
Expand Down Expand Up @@ -750,7 +750,7 @@ function _remove_collinear_points!(polys, remove_idx, poly_a, poly_b)
continue
else
p3 = p
# check if p2 is approximatly on the edge formed by p1 and p3 - remove if so
# check if p2 is approximately on the edge formed by p1 and p3 - remove if so
if Predicates.orient(p1, p2, p3; exact = _False()) == 0
remove_idx[i - 1] = true
end
Expand Down
2 changes: 1 addition & 1 deletion src/methods/clipping/coverage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export coverage
## What is coverage?
Coverage is the amount of geometry area within a bounding box defined by the minimum and
maximum x and y-coordiantes of that bounding box, or an Extent containing that information.
maximum x and y-coordinates of that bounding box, or an Extent containing that information.
To provide an example, consider this rectangle:
```@example rect
Expand Down
2 changes: 1 addition & 1 deletion src/methods/clipping/cut.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ of cut geometry in Vector{Vector{Tuple}} format.
Note: degenerate cases where intersection points are vertices do not work right now. =#
function _cut(::Type{T}, geom, line, geom_list, intr_list, n_intr_pts; exact) where T
# Sort and catagorize the intersection points
# Sort and categorize the intersection points
sort!(intr_list, by = x -> geom_list[x].fracs[2])
_flag_ent_exit!(GI.LineTrait(), line, geom_list; exact)
# Add first point to output list
Expand Down
6 changes: 3 additions & 3 deletions src/methods/clipping/difference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function _difference(
end
end
end
# Remove uneeded collinear points on same edge
# Remove unneeded collinear points on same edge
_remove_collinear_points!(polys, remove_idx, poly_a, poly_b)
return polys
end
Expand Down Expand Up @@ -147,7 +147,7 @@ end
#= Multipolygon with multipolygon difference - note that all intersection regions between
sub-polygons of `multipoly_a` and sub-polygons of `multipoly_b` will be removed from the
corresponding sub-polygon of `multipoly_a`. Unless specified with `fix_multipoly = nothing`,
`multipolygon_a` will be validated using the given (defauly is `UnionIntersectingPolygons()`)
`multipolygon_a` will be validated using the given (default is `UnionIntersectingPolygons()`)
correction. =#
function _difference(
target::TraitTarget{GI.PolygonTrait}, ::Type{T},
Expand All @@ -169,7 +169,7 @@ function _difference(
else
difference(GI.MultiPolygon(polys), poly_b; target, fix_multipoly)
end
#= One multipoly_a has been completly covered (and thus removed) there is no need to
#= One multipoly_a has been completely covered (and thus removed) there is no need to
continue taking the difference =#
isempty(polys) && break
end
Expand Down
14 changes: 7 additions & 7 deletions src/methods/clipping/intersection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export intersection, intersection_points
Enum LineOrientation
Enum for the orientation of a line with respect to a curve. A line can be
`line_cross` (crossing over the curve), `line_hinge` (crossing the endpoint of the curve),
`line_over` (colinear with the curve), or `line_out` (not interacting with the curve).
`line_over` (collinear with the curve), or `line_out` (not interacting with the curve).
"""
@enum LineOrientation line_cross=1 line_hinge=2 line_over=3 line_out=4

Expand Down Expand Up @@ -86,7 +86,7 @@ function _intersection(
hole_iterator = Iterators.flatten((GI.gethole(poly_a), GI.gethole(poly_b)))
_add_holes_to_polys!(T, polys, hole_iterator, remove_idx; exact)
end
# Remove uneeded collinear points on same edge
# Remove unneeded collinear points on same edge
_remove_collinear_points!(polys, remove_idx, poly_a, poly_b)
return polys
end
Expand Down Expand Up @@ -128,7 +128,7 @@ function _intersection(
end

#= Multipolygon with polygon intersection is equivalent to taking the intersection of the
poylgon with the multipolygon and thus simply switches the order of operations and calls the
polygon with the multipolygon and thus simply switches the order of operations and calls the
above method. =#
_intersection(
target::TraitTarget{GI.PolygonTrait}, ::Type{T},
Expand Down Expand Up @@ -197,7 +197,7 @@ intersection_points(geom_a, geom_b, ::Type{T} = Float64) where T <: AbstractFloa
_intersection_points(T, GI.trait(geom_a), geom_a, GI.trait(geom_b), geom_b)


#= Calculates the list of intersection points between two geometries, inlcuding line
#= Calculates the list of intersection points between two geometries, including line
segments, line strings, linear rings, polygons, and multipolygons. =#
function _intersection_points(::Type{T}, ::GI.AbstractTrait, a, ::GI.AbstractTrait, b; exact = _True()) where T
# Initialize an empty list of points
Expand Down Expand Up @@ -384,7 +384,7 @@ end

#= If lines defined by (a1, a2) and (b1, b2) meet at one point that is not an endpoint of
either segment, they form a crossing intersection with a singular intersection point. That
point is caculated by finding the fractional distance along each segment the point occurs
point is calculated by finding the fractional distance along each segment the point occurs
at (α, β). If the point is too close to an endpoint to be distinct, the point shares a value
with the endpoint, but with a non-zero and non-one fractional value. If the intersection
point calculated is outside of the envelope of the two segments due to floating point error,
Expand All @@ -407,9 +407,9 @@ function _find_cross_intersection(::Type{T}, a1, a2, b1, b2, a_ext, b_ext) where
β = _clamped_frac(Δbax * Δay - Δbay * Δax, a_cross_b, eps(T))

#= Intersection will be where a1 + α * Δa = b1 + β * Δb. However, due to floating point
innacurracies, α and β calculations may yeild different intersection points. Average
inaccuracies, α and β calculations may yield different intersection points. Average
both points together to minimize difference from real value, as long as segment isn't
vertical or horizontal as this will almost certianly lead to the point being outside the
vertical or horizontal as this will almost certainly lead to the point being outside the
envelope due to floating point error. Also note that floating point limitations could
make intersection be endpoint if α≈0 or α≈1.=#
x = if Δax == 0
Expand Down
6 changes: 3 additions & 3 deletions src/methods/clipping/union.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function _union(
if GI.nhole(poly_a) != 0 || GI.nhole(poly_b) != 0
_add_union_holes!(polys, a_in_b, b_in_a, poly_a, poly_b; exact)
end
# Remove uneeded collinear points on same edge
# Remove unneeded collinear points on same edge
_remove_collinear_points!(polys, [false], poly_a, poly_b)
return polys
end
Expand Down Expand Up @@ -160,7 +160,7 @@ function _add_union_holes_contained_polys!(polys, interior_poly, exterior_poly;
in_ih, on_ih, out_ih = _line_polygon_interactions(ext_int_ring, poly_ih; exact, closed_line = true)
if in_ih # at least part of interior polygon exterior is within the ith hole
if !on_ih && !out_ih
#= interior polygon is completly within the ith hole - polygons aren't
#= interior polygon is completely within the ith hole - polygons aren't
touching and do not actually form a union =#
polys[1] = tuples(interior_poly)
push!(polys, tuples(exterior_poly))
Expand Down Expand Up @@ -235,7 +235,7 @@ function _union(
return polys
end

#= Multipolygon with polygon union is equivalent to taking the union of the poylgon with the
#= Multipolygon with polygon union is equivalent to taking the union of the polygon with the
multipolygon and thus simply switches the order of operations and calls the above method. =#
_union(
target::TraitTarget{GI.PolygonTrait}, ::Type{T},
Expand Down
2 changes: 1 addition & 1 deletion src/methods/distance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ and multipolygons. If a point is outside of a geometry, signed distance has the
same value as distance. However, points within the geometry have a negative
distance representing the distance of a point to the closest boundary.
Therefore, for all "non-filled" geometries, like curves, the distance will
either be postitive or 0.
either be positive or 0.
To provide an example, consider this rectangle:
```@example rect
Expand Down
10 changes: 5 additions & 5 deletions src/methods/equals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ lines!(GI.getpoint(l2), color = :orange)
scatter!(GI.getpoint(l2), color = :orange)
f
```
We can see that the two lines do not share a commen set of points and edges in
We can see that the two lines do not share a common set of points and edges in
the plot, so they are not equal:
```@example equals
GO.equals(l1, l2) # returns false
Expand All @@ -44,7 +44,7 @@ same order. The winding order also doesn't have to be the same to represent the
same geometry. This requires checking every point against every other point in
the two geometries we are comparing. Also, some geometries must be "closed" like
polygons and linear rings. These will be assumed to be closed, even if they
don't have a repeated last point explicity written in the coordinates.
don't have a repeated last point explicitly written in the coordinates.
Additionally, geometries and multi-geometries can be equal if the multi-geometry
only includes that single geometry.
=#
Expand Down Expand Up @@ -210,7 +210,7 @@ end
)::Bool
Two lines/linestrings are equal if they share the same set of points going
along the curve. Note that lines/linestrings aren't closed by defintion.
along the curve. Note that lines/linestrings aren't closed by definition.
"""
equals(
::Union{GI.LineTrait, GI.LineStringTrait}, l1,
Expand All @@ -224,7 +224,7 @@ equals(
)::Bool
A line/linestring and a linear ring are equal if they share the same set of
points going along the curve. Note that lines aren't closed by defintion, but
points going along the curve. Note that lines aren't closed by definition, but
rings are, so the line must have a repeated last point to be equal
"""
equals(
Expand All @@ -239,7 +239,7 @@ equals(
)::Bool
A linear ring and a line/linestring are equal if they share the same set of
points going along the curve. Note that lines aren't closed by defintion, but
points going along the curve. Note that lines aren't closed by definition, but
rings are, so the line must have a repeated last point to be equal
"""
equals(
Expand Down
4 changes: 2 additions & 2 deletions src/methods/geom_relations/contains.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ 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
The contains function checks if a given geometry completely contains another
geometry, or in other words, that the second geometry is completely 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.
Expand Down
4 changes: 2 additions & 2 deletions src/methods/geom_relations/coveredby.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ _coveredby(
)

#= Linestring is coveredby a polygon if all interior and boundary points of the
line are in the polygon interior or on its edges, inlcuding hole edges. =#
line are in the polygon interior or on its edges, including hole edges. =#
_coveredby(
::Union{GI.LineTrait, GI.LineStringTrait}, g1,
::GI.PolygonTrait, g2,
Expand Down Expand Up @@ -203,7 +203,7 @@ _coveredby(
)

#= Linearring is coveredby a polygon if all vertices and edges of the ring are
in the polygon interior or on the polygon edges, inlcuding hole edges. =#
in the polygon interior or on the polygon edges, including hole edges. =#
_coveredby(
::GI.LinearRingTrait, g1,
::GI.PolygonTrait, g2,
Expand Down
2 changes: 1 addition & 1 deletion src/methods/geom_relations/covers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export covers
#=
## What is covers?
The covers function checks if a given geometry completly covers another
The covers function checks if a given geometry completely covers another
geometry. For this to be true, the "contained" geometry's interior and
boundaries must be covered by the "covering" geometry's interior and boundaries.
The interiors do not need to overlap.
Expand Down
Loading

0 comments on commit 289e588

Please sign in to comment.