Skip to content

Commit

Permalink
faster area
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Jan 1, 2024
1 parent 4544514 commit 4cfe14f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
7 changes: 2 additions & 5 deletions src/methods/area.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,12 @@ function _signed_area(::Type{T}, geom) where T
# Close curve, even if last point isn't explicitly repeated
np = GI.npoint(geom)
np == 0 && return area
first_last_equal = equals(GI.getpoint(geom, 1), GI.getpoint(geom, np))
np -= first_last_equal ? 1 : 0
# Integrate the area under the curve
p1 = GI.getpoint(geom, np)
for i in 1:np
p2 = GI.getpoint(geom, i)
for p2 in GI.getpoint(geom)
# Accumulate the area into `area`
area += GI.x(p1) * GI.y(p2) - GI.y(p1) * GI.x(p2)
p1 = p2
end
return T(area / 2)
end
end
9 changes: 0 additions & 9 deletions src/transformations/simplify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,6 @@ function _simplify(::PolygonTrait, alg, geom)
end
## For curves and rings we simplify
_simplify(::AbstractCurveTrait, alg, geom) = rebuild(geom, simplify(alg, tuple_points(geom)))
function _simplify(::LinearRingTrait, alg, geom)
## Make a vector of points
points = tuple_points(geom)

## Simplify it once
simple = _simplify(alg, points)

return rebuild(geom, simple)
end

"""
RadialDistance <: SimplifyAlg
Expand Down

0 comments on commit 4cfe14f

Please sign in to comment.