Skip to content

Commit f78d91f

Browse files
committed
Add decompose for polygon
1 parent e2ba76c commit f78d91f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/interfaces.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ function decompose(::Type{T}, primitive) where {T}
112112
return collect_with_eltype(T, primitive)
113113
end
114114

115+
function decompose(::Type{P}, pol::Polygon) where {P<:AbstractPoint}
116+
if isempty(pol.interiors)
117+
return decompose(P, pol.exterior)
118+
else
119+
points = Array{Union{Point, Array}}[]
120+
push!(points, decompose(P, pol.exterior), [decompose(P, pol.interiors[1]) for i in pol.interiors])
121+
return points
122+
end
123+
end
115124
decompose(::Type{P}, ls::LineString) where {P<:AbstractPoint} = ls.points.parent.data
116125
decompose_uv(primitive) = decompose(UV(), primitive)
117126
decompose_uvw(primitive) = decompose(UVW(), primitive)

0 commit comments

Comments
 (0)