Skip to content

Commit

Permalink
reject Point construction with more than 3 dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
markmbaum committed Dec 30, 2024
1 parent 975b238 commit 4353408
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Meshes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ using Random

using Bessels: gamma
using Unitful: AbstractQuantity, numtype
using CoordRefSystems: Basic, Geographic, Projected
using CoordRefSystems: Basic, Geographic, Projected, ncoords
using Distances: PreMetric, Euclidean, Mahalanobis
using Distances: Haversine, SphericalAngle
using Distances: evaluate, result_type
Expand Down
6 changes: 6 additions & 0 deletions src/geometries/primitives/point.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ Point(1m, 2m, 3m) # integer is converted to float by design
"""
struct Point{M<:Manifold,C<:CRS} <: Primitive{M,C}
coords::C
# here the inner constuctor ensures the point does not have more than 3 dimensions
function Point{M,C}(coords::C) where {M<:Manifold,C<:CRS}
ndim = ncoords(coords)
ndim > 3 && error("Points can only be constructed with up to 3 dimensions, but got $ndim.")
new{M,C}(coords)
end
end

Point{M}(coords::C) where {M<:Manifold,C<:CRS} = Point{M,C}(coords)
Expand Down

0 comments on commit 4353408

Please sign in to comment.