pub fn extract_mbr(blob: &[u8]) -> Result<Option<Rect<f64>>>Expand description
Compute the planar minimum bounding rectangle of an EWKB blob without
allocating a Geometry enum.
Walks the EWKB byte payload, reads only the X/Y coordinates, and tracks
running min/max. For the “many points vs one window” filter shape this
is roughly 10-100x cheaper per call than parse_ewkb(...).bounding_rect()
because it skips the heap-allocating decode entirely.
Returns Ok(None) when the geometry is empty (empty Point with NaN
coordinates, empty LineString, empty Polygon, or any container whose
elements are all empty). Returns Err only for malformed blobs.
§Example
use sqlitegis::core::ewkb::extract_mbr;
use sqlitegis::core::functions::io::geom_from_text;
let blob = geom_from_text("POLYGON((0 0, 10 0, 10 5, 0 5, 0 0))", None).unwrap();
let mbr = extract_mbr(&blob).unwrap().unwrap();
assert_eq!(mbr.min().x, 0.0);
assert_eq!(mbr.min().y, 0.0);
assert_eq!(mbr.max().x, 10.0);
assert_eq!(mbr.max().y, 5.0);
let empty = geom_from_text("POINT EMPTY", None).unwrap();
assert!(extract_mbr(&empty).unwrap().is_none());