Inhomogeneous linear transport equation Cauchy problem I am working through the first chapter of "Finite Difference Schemes and Partial Differential Equations" by Strikwerda and I am confused by this inhomogeneous problem (1.1.2):

Show that
$$
u_t +au_x = f(t,x)
$$
with $u(0,x) = 0$, $a>0$ a positive constant, and
$$
f(t,x) = \begin{cases}
        1, & \text{for } -1\leq x\leq 1\\
       0, & \text{otherwise.}
        \end{cases}
$$
has solution
$$
u(t,x) = \begin{cases}
\frac{1+x}{a}, & \text{if} & -1 \leq x \leq 1 &\text{and} & x-at\leq -1; \\
t, & \text{if} & -1 \leq x \leq 1 &\text{and} & -1 \leq x-at; \\
\frac{2}{a}, & \text{if} &  x \geq 1 &\text{and} & x-at\leq -1; \\
\frac{1-x+at}{a}, & \text{if} & x \geq 1 &\text{and} & -1 \leq x-at\leq1; \\
0, & \text{otherwise}
\end{cases}
$$

My initial approach was to use the formula derived for a general problem with $u(x,0) = u_0(x)$ given by $ u(t,x) = u_0(x-at) + \int_0^t f(s, x-a(s-t))\,ds$. For this particular problem, the formula would be $u(t,x) = \int_0^t f(s, x-a(s-t))\,ds$, but I am struggling on how to treat the integral given the source $f$ is limited to a region.
Is it possible to use this general formula by carefully considering the region in $u$-$t$ space to integrate? If so, any guidance on how? If not, any guidance as how to proceed? I have always had a difficult time with method of characteristics, so any help is appreciated.
 A: The characteristic curves are the lines $x = x_0 + at$ along which $u = \int_0^t f(s, x_0 + a s) \, ds$, i.e.
$$
u(x,t) = \int_0^t f(s, x - a (t-s)) \, ds ,
$$
where we have used the initial condition $u(0,x)=0$. The change of variables $\xi = x - a (t-s)$ gives
\begin{aligned}
u(x,t) &= \frac1{a} \int_{x-at}^{x} f(t+(\xi-x)/a, \xi) \, d\xi \\
&= \frac1{a} \int_{\alpha}^{\beta} d\xi = \frac{\beta-\alpha}{a} ,
\end{aligned}
where we have restricted the domain of integration to its intersection $[\alpha,\beta]$ with the support of $f$ (i.e., the domain $\xi\in [-1,1]$ where $f$ is nonzero). Now, the restricted integration bounds $\alpha \geq x-at$ and $\beta \leq x$ have to be determined. This can be done simply by using set theory techniques, i.e. by writing the intersection as $$[\alpha,\beta] = [x-at,x] \cap [-1,1] .$$ Heuristically, we note that the integrand will be nonzero only for $-1\leq \alpha < \beta \leq 1$. Therefore, we find
\begin{aligned}
\alpha &= \min(\max(x-at,-1),1) ,\\
\beta &= \max(\min(x,1),-1) .
\end{aligned}
Now, if there is no mistake above, the correct result should have been obtained.
