@@ -24,13 +24,13 @@ RegularGrid((10, 20, 30), Point(Cylindrical(0.0, 0.0, 0.0)), (3.0, 2.0, 1.0))
2424
2525See also [`CartesianGrid`](@ref).
2626"""
27- struct RegularGrid{M<: Manifold ,C<: CRS ,S<: Tuple ,N } <: Grid{M,C,N}
27+ struct RegularGrid{M<: Manifold ,C<: CRS ,N, S<: NTuple{N,Quantity} } <: Grid{M,C,N}
2828 origin:: Point{M,C}
2929 spacing:: S
3030 offset:: Dims{N}
3131 topology:: GridTopology{N}
3232
33- function RegularGrid {M,C,S,N } (origin, spacing, offset, topology) where {M<: Manifold ,C<: CRS ,S<: Tuple ,N }
33+ function RegularGrid {M,C,N,S } (origin, spacing, offset, topology) where {M<: Manifold ,C<: CRS ,N, S<: NTuple{N,Quantity} }
3434 if ! all (s -> s > zero (s), spacing)
3535 throw (ArgumentError (" spacing must be positive" ))
3636 end
4040
4141function RegularGrid (
4242 origin:: Point{M,C} ,
43- spacing:: Tuple ,
43+ spacing:: NTuple{N,Number} ,
4444 offset:: Dims{N} ,
4545 topology:: GridTopology{N}
4646) where {M<: Manifold ,C<: CRS ,N}
47- if manifold (origin) < : 🌐 && ! (crs (origin) <: LatLon )
47+ if M < : 🌐 && ! (C <: LatLon )
4848 throw (ArgumentError (" regular spacing on `🌐` requires `LatLon` coordinates" ))
4949 end
5050
5151 T = CoordRefSystems. mactype (C)
5252 nc = CoordRefSystems. ncoords (C)
5353 us = CoordRefSystems. units (C)
54- ns = length (spacing)
5554
5655 if N ≠ nc
5756 throw (ArgumentError ("""
@@ -60,19 +59,17 @@ function RegularGrid(
6059 """ ))
6160 end
6261
63- if ns ≠ nc
64- throw (ArgumentError ("""
65- A $N -dimensional regular grid requires $N spacing values.
66- The provided spacing has $ns values.
67- """ ))
68- end
69-
7062 sp = ntuple (i -> numconvert (T, withunit (spacing[i], us[i])), nc)
7163
72- RegularGrid {M,C,typeof(sp),N } (origin, sp, offset, topology)
64+ RegularGrid {M,C,N, typeof(sp)} (origin, sp, offset, topology)
7365end
7466
75- function RegularGrid (dims:: Dims{N} , origin:: Point , spacing:: Tuple , offset:: Dims{N} = ntuple (i -> 1 , N)) where {N}
67+ function RegularGrid (
68+ dims:: Dims{N} ,
69+ origin:: Point ,
70+ spacing:: NTuple{N,Number} ,
71+ offset:: Dims{N} = ntuple (i -> 1 , N)
72+ ) where {N}
7673 if ! all (> (0 ), dims)
7774 throw (ArgumentError (" dimensions must be positive" ))
7875 end
@@ -90,7 +87,7 @@ function vertex(g::RegularGrid, ijk::Dims)
9087 Point (ctor (vals... ))
9188end
9289
93- @generated function xyz (g:: RegularGrid{M,C,S, N} ) where {M,C,S ,N}
90+ @generated function xyz (g:: RegularGrid{M,C,N} ) where {M,C,N}
9491 exprs = ntuple (N) do i
9592 :(range (start= orig[$ i], step= spac[$ i], length= (dims[$ i] + 1 )))
9693 end
0 commit comments