diff --git a/src/primitives/rectangles.jl b/src/primitives/rectangles.jl index 912161a4..621dc769 100644 --- a/src/primitives/rectangles.jl +++ b/src/primitives/rectangles.jl @@ -524,6 +524,14 @@ function Base.isapprox(r1::Rect, r2::Rect; kwargs...) return isapprox(origin(r1), origin(r2); kwargs...) && isapprox(widths(r1), widths(r2); kwargs...) end +## +# Rect1 decomposition +function coordinates(rect::Rect{1, T}) where {T} + w = widths(rect) + o = origin(rect) + return [Point{1,T}(o[1]), Point{1,T}(o[1]+w[1])] +end + ## # Rect2 decomposition diff --git a/test/geometrytypes.jl b/test/geometrytypes.jl index cb68c9e2..49740d21 100644 --- a/test/geometrytypes.jl +++ b/test/geometrytypes.jl @@ -683,6 +683,14 @@ end r = Rect2i(2, 4, 2, 4) @test M[r] == [53 63 73 83; 54 64 74 84] + # Rect1 coordinates/texturecoordinates + r = Rect{1,Float32}(0.2, 0.5) + @test eltype(coordinates(r)) == Point{1,Float32} + @test coordinates(r) == [Point{1,Float32}(0.2), Point{1,Float32}(0.7)] + + r64 = Rect{1,Float64}(-0.2, 1.3) + @test eltype(coordinates(r64)) == Point{1,Float64} + @test coordinates(r64) == [Point{1,Float64}(-0.2), Point{1,Float64}(1.1)] end @testset "LineStrings" begin