Skip to content

Commit 9974a79

Browse files
authored
Fix Polygon constructor type signature (#237)
* Fix Polygon constructor type signature * Add test for issue #236 fix
1 parent d4d96ec commit 9974a79

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/basic_types.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ end
288288

289289
function Polygon(
290290
exterior::AbstractVector{Point{Dim,T}},
291-
interiors::AbstractVector{AbstractVector{Point{Dim,T}}}) where {Dim, T}
291+
interiors::AbstractVector{<:AbstractVector{Point{Dim,T}}}) where {Dim, T}
292292
tov(v) = convert(Vector{Point{Dim, T}}, v)
293293
return Polygon{Dim,T}(tov(exterior), map(tov, interiors))
294294
end
@@ -770,4 +770,4 @@ vertex_attributes(mesh::MetaMesh) = vertex_attributes(Mesh(mesh))
770770
meta(@nospecialize(m)) = NamedTuple()
771771
meta(mesh::MetaMesh) = getfield(mesh, :meta)
772772
Mesh(mesh::MetaMesh) = getfield(mesh, :mesh)
773-
Mesh(mesh::Mesh) = mesh
773+
Mesh(mesh::Mesh) = mesh

test/polygons.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,9 @@
2828
]
2929
fs = GLTriangleFace[(4, 8, 7), (5, 8, 4), (3, 4, 7), (5, 4, 1), (2, 3, 7), (6, 5, 1), (2, 7, 6), (6, 1, 2)]
3030
@test fs == GeometryBasics.earcut_triangulate(poly1)
31+
32+
# issue #236
33+
let p = SA[Point(0.0, 0.0), Point(1.0, 0.0), Point(0.0, 1.0)]
34+
@test Polygon(p) == Polygon(Array(p))
35+
end
3136
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ using GeometryBasics: MetaMesh
55
using GeoInterface
66
using GeoJSON
77
using Extents
8+
using StaticArrays
89

910
@testset "GeometryBasics" begin
1011
@testset "algorithms" begin

0 commit comments

Comments
 (0)