Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[weakdeps]
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"

[extensions]
GeometryBasicsGeoInterfaceExt = "GeoInterface"
IntervalSetsExt = "IntervalSets"

[compat]
Aqua = "0.8"
EarCut_jll = "2"
Extents = "0.1"
GeoInterface = "1.0.1"
GeoJSON = "0.7, 0.8"
IntervalSets = "0.7"
IterTools = "1.3.0"
LinearAlgebra = "<0.0.1,1"
OffsetArrays = "1"
Expand All @@ -35,11 +38,12 @@ julia = "1.10"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
GeoJSON = "61d90e0f-e114-555e-ac52-39dfb47a3ef9"
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
GeoJSON = "61d90e0f-e114-555e-ac52-39dfb47a3ef9"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "GeoInterface", "GeoJSON", "OffsetArrays", "Random", "Test"]
test = ["Aqua", "GeoInterface", "GeoJSON", "IntervalSets", "OffsetArrays", "Random", "Test"]
16 changes: 16 additions & 0 deletions ext/IntervalSetsExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module IntervalSetsExt

using IntervalSets
using GeometryBasics

GeometryBasics.HyperRectangle(ints::Vararg{ClosedInterval, N}) where {N} = HyperRectangle{N}(ints...)
GeometryBasics.HyperRectangle{N}(ints::Vararg{ClosedInterval, N}) where {N} = HyperRectangle{N}(
Vec(leftendpoint.(ints)),
Vec(rightendpoint.(ints) .- leftendpoint.(ints))
)
GeometryBasics.HyperRectangle{N,T}(ints::Vararg{ClosedInterval, N}) where {N,T} = HyperRectangle{N,T}(
Vec(leftendpoint.(ints)),
Vec(rightendpoint.(ints) .- leftendpoint.(ints))
)

end
15 changes: 15 additions & 0 deletions test/geometrytypes.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Test, GeometryBasics
using IntervalSets: (..)

@testset "Cylinder" begin
@testset "constructors" begin
Expand Down Expand Up @@ -180,6 +181,20 @@ end
@test constructor(m) ≈ Rect3f(-1, -1, -1, 2, 2, 2)
end
end

@testset "From intervals" begin
# 1D interval
@test HyperRectangle(1..3) == Rect{1, Float64}(Point(1.0), Vec(2.0))
# 2D intervals
@test HyperRectangle(0..2, -1..1) == Rect{2, Float64}(Point(0.0, -1.0), Vec(2.0, 2.0))
# different interval eltypes
@test HyperRectangle(0.0..2.0, -1..1) == Rect{2, Float64}(Point(0.0, -1.0), Vec(2.0, 2.0))
# N-typed constructor
@test HyperRectangle{2}(0..2, -1..1) == HyperRectangle(0..2, -1..1)
# Rect constructor:
@test Rect(1..3, 4..5) == Rect{2, Float64}(Point(1.0, 4.0), Vec(2.0, 1.0))
@test Rect{2, Float64}(1..3, 4..5) == Rect{2, Float64}(Point(1.0, 4.0), Vec(2.0, 1.0))
end
end

# TODO: consider deprecating this
Expand Down
Loading