| 243 | } |
| 244 | |
| 245 | fn scale_coord_range( |
| 246 | bounds: &Rect, |
| 247 | x_dst: Option<&[f64; 2]>, |
| 248 | y_dst: Option<&[f64; 2]>, |
| 249 | coord: Coord, |
| 250 | ) -> Coord { |
| 251 | let min = bounds.min(); |
| 252 | let max = bounds.max(); |
| 253 | let mut x = coord.x; |
| 254 | let mut y = coord.y; |
| 255 | |
| 256 | if let Some(dst) = x_dst { |
| 257 | let src = [min.x, max.x]; |
| 258 | x = scale_range(&src, dst, coord.x); |
| 259 | } |
| 260 | if let Some(dst) = y_dst { |
| 261 | let src = [min.y, max.y]; |
| 262 | y = scale_range(&src, dst, coord.y); |
| 263 | } |
| 264 | coord! {x: x, y: y} |
| 265 | } |
| 266 | |
| 267 | fn geoms_coordwise( |
| 268 | geometries: impl Iterator<Item = Geometry>, |