@@ -85,16 +85,51 @@ boundingbox(m::Mesh) = _pboxes(vertices(m))
8585
8686_bboxes (boxes) = _pboxes (point for box in boxes for point in extrema (box))
8787
88- function _pboxes (points)
88+ _pboxes (points) = _pboxes (manifold (first (points)), points)
89+
90+ function _pboxes (:: Type{𝔼{2}} , points)
91+ p = first (points)
92+ ℒ = lentype (p)
93+ xmin, ymin = typemax (ℒ), typemax (ℒ)
94+ xmax, ymax = typemin (ℒ), typemin (ℒ)
95+ for p in points
96+ c = convert (Cartesian, coords (p))
97+ xmin = min (c. x, xmin)
98+ ymin = min (c. y, ymin)
99+ xmax = max (c. x, xmax)
100+ ymax = max (c. y, ymax)
101+ end
102+ Box (withcrs (p, (xmin, ymin)), withcrs (p, (xmax, ymax)))
103+ end
104+
105+ function _pboxes (:: Type{𝔼{3}} , points)
89106 p = first (points)
90107 ℒ = lentype (p)
91- Dim = embeddim (p)
92- xmin = MVector (ntuple (i -> typemax (ℒ), Dim))
93- xmax = MVector (ntuple (i -> typemin (ℒ), Dim))
108+ xmin, ymin, zmin = typemax (ℒ), typemax (ℒ), typemax (ℒ)
109+ xmax, ymax, zmax = typemin (ℒ), typemin (ℒ), typemin (ℒ)
110+ for p in points
111+ c = convert (Cartesian, coords (p))
112+ xmin = min (c. x, xmin)
113+ ymin = min (c. y, ymin)
114+ zmin = min (c. z, zmin)
115+ xmax = max (c. x, xmax)
116+ ymax = max (c. y, ymax)
117+ zmax = max (c. z, zmax)
118+ end
119+ Box (withcrs (p, (xmin, ymin, zmin)), withcrs (p, (xmax, ymax, zmax)))
120+ end
121+
122+ function _pboxes (:: Type{🌐} , points)
123+ p = first (points)
124+ T = numtype (lentype (p))
125+ lonmin, latmin = T (180 ) * u " °" , T (90 ) * u " °"
126+ lonmax, latmax = T (- 180 ) * u " °" , T (- 90 ) * u " °"
94127 for p in points
95- x = to (p)
96- @. xmin = min (x, xmin)
97- @. xmax = max (x, xmax)
128+ c = convert (LatLon, coords (p))
129+ lonmin = min (c. lon, lonmin)
130+ latmin = min (c. lat, latmin)
131+ lonmax = max (c. lon, lonmax)
132+ latmax = max (c. lat, latmax)
98133 end
99- Box (withcrs (p, xmin ), withcrs (p, xmax ))
134+ Box (withcrs (p, (latmin, lonmin ), LatLon), withcrs (p, (latmax, lonmax), LatLon ))
100135end
0 commit comments