from geo.errors import FilterError


def parse_bbox(bbox_str: str) -> tuple[float, float, float, float]:
    """Parse a 'west,south,east,north' string into a bbox tuple."""
    parts = bbox_str.split(",")
    if len(parts) != 4:
        raise FilterError(f"Bounding box must have 4 values (w,s,e,n), got {len(parts)}")
    try:
        return tuple(float(p.strip()) for p in parts)
    except ValueError as e:
        raise FilterError(f"Invalid bbox value: {e}")

