I am trying to solve a paper and have a basic question which I am unable to understand.
Given a line segment $[0,a]$, two points $x,y$ are randomly selected such that $\mathcal{D} = |x-y| \leq l$. So the CDF would be
$$P(L \leq l) = \iint_{\mathcal D}\mathcal{D}f_{XY}(x,y)dxdy,$$
where $f_{XY}(x,y) = \frac{1}{a^2}$ when $0 \leq x,y \leq a$, else $f_{XY}(x,y) = 0$
Now I dont understand how the author says, taking into account the bounds of both $\mathcal{D}$ and $f_{XY}(x,y)$, the CDF for distance distribution is as follows:
$$P(L\leq l) = \frac{1}{a^2}\Big(\int_0^l\int_0^{x+l}dydx + \int_l^{a-l}\int_{x-l}^{x+l}dydx + \int_{a-l}^a\int_{x-l}^{a}dydx\Big)$$
Can someone explain 'geometrically' how this expression appears?
The actual problem is attached as the figure below.

The text is cutting a corner here by not saying why this works for $l\gt\frac a2$. I'll first explain it for $l\le\frac a2$.
The outer integration is over $x$, the inner integration is over $y$. We need to distinguish three cases for the outer integration because the bounds for $y$ are different in each case.
Now comes the tricky part: If $l\gt\frac a2$, the second double integral has the limit for $x$ reversed, so it's negative. This is exactly what we need to cancel the overcounting due to the fact that for $x\in[a-l,l]$, in the first and third double integrals the limits $x+l$ and $x-l$, respectively, went beyond $[0,a]$.