From b3d86556f7355a7515ec3c9e83f8aad8ad3ba59c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20A=2E=20V=2E=20de=20Bragan=C3=A7a=20Alves?= Date: Fri, 17 Jan 2025 17:50:37 -0300 Subject: [PATCH 1/2] Fix Polygon constructor type signature --- src/basic_types.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/basic_types.jl b/src/basic_types.jl index d2623940..11e72d47 100644 --- a/src/basic_types.jl +++ b/src/basic_types.jl @@ -288,7 +288,7 @@ end function Polygon( exterior::AbstractVector{Point{Dim,T}}, - interiors::AbstractVector{AbstractVector{Point{Dim,T}}}) where {Dim, T} + interiors::AbstractVector{<:AbstractVector{Point{Dim,T}}}) where {Dim, T} tov(v) = convert(Vector{Point{Dim, T}}, v) return Polygon{Dim,T}(tov(exterior), map(tov, interiors)) end @@ -770,4 +770,4 @@ vertex_attributes(mesh::MetaMesh) = vertex_attributes(Mesh(mesh)) meta(@nospecialize(m)) = NamedTuple() meta(mesh::MetaMesh) = getfield(mesh, :meta) Mesh(mesh::MetaMesh) = getfield(mesh, :mesh) -Mesh(mesh::Mesh) = mesh \ No newline at end of file +Mesh(mesh::Mesh) = mesh From fcc4832cde008448705bcc2b0a0afd6c44452db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20A=2E=20V=2E=20de=20Bragan=C3=A7a=20Alves?= Date: Sat, 18 Jan 2025 11:24:51 -0300 Subject: [PATCH 2/2] Add test for issue #236 fix --- test/polygons.jl | 5 +++++ test/runtests.jl | 1 + 2 files changed, 6 insertions(+) diff --git a/test/polygons.jl b/test/polygons.jl index 3c83c291..de15805d 100644 --- a/test/polygons.jl +++ b/test/polygons.jl @@ -28,4 +28,9 @@ ] 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)] @test fs == GeometryBasics.earcut_triangulate(poly1) + + # issue #236 + let p = SA[Point(0.0, 0.0), Point(1.0, 0.0), Point(0.0, 1.0)] + @test Polygon(p) == Polygon(Array(p)) + end end diff --git a/test/runtests.jl b/test/runtests.jl index a12aba7c..19d19b15 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,6 +5,7 @@ using GeometryBasics: MetaMesh using GeoInterface using GeoJSON using Extents +using StaticArrays @testset "GeometryBasics" begin @testset "algorithms" begin