Skip to content

Commit e73f380

Browse files
committed
fix constructor for empty interiors
1 parent 5774d0b commit e73f380

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/basic_types.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,12 @@ function Polygon(exterior::AbstractVector{P}, faces::AbstractVector{<: LineFace}
287287
end
288288

289289
function Polygon(exterior::AbstractVector{P}, interior::AbstractVector{<:AbstractVector{P}}) where P <: AbstractPoint{Dim, T} where {Dim, T}
290-
return Polygon(LineString(exterior), LineString.(interior))
290+
ext = LineString(exterior)
291+
# We need to take extra care for empty interiors, since
292+
# if we just map over it, it won't infer the element type correctly!
293+
int = typeof(ext)[]
294+
foreach(x-> push!(int, LineString(x)), interior)
295+
return Polygon(LineString(exterior), int)
291296
end
292297

293298
function coordinates(polygon::Polygon{N, T, PointType}) where {N, T, PointType}

0 commit comments

Comments
 (0)