MCPcopy Create free account
hub / github.com/Notgnoshi/generative / bounding_box

Function bounding_box

tools/transform.rs:156–179  ·  view source on GitHub ↗
(geometries: &[Geometry])

Source from the content-addressed store, hash-verified

154}
155
156fn bounding_box(geometries: &[Geometry]) -> Rect {
157 // Calculate the center of the bounding box; needed to build the AffineTransform
158 let mut min_x = f64::MAX;
159 let mut min_y = f64::MAX;
160 let mut max_x = f64::MIN;
161 let mut max_y = f64::MIN;
162 for geom in geometries.iter() {
163 let temp = geom.bounding_rect().unwrap_or_else(|| {
164 panic!(
165 "Geometry '{}' didn't have a bounding rectangle",
166 geom.to_wkt()
167 )
168 });
169
170 let min = temp.min();
171 let max = temp.max();
172
173 min_x = min_x.min(min.x);
174 min_y = min_y.min(min.y);
175 max_x = max_x.max(max.x);
176 max_y = max_y.max(max.y);
177 }
178 Rect::new(coord! {x:min_x, y:min_y}, coord! {x:max_x, y:max_y})
179}
180
181fn affine_transform(
182 geometries: impl Iterator<Item = Geometry> + 'static,

Callers 2

affine_transformFunction · 0.70
mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected