A theoretical framework and numerical techniques to solve optimal control problems with a spatial trace term in the terminal cost and governed by regularized nonlinear hyperbolic conservation laws are provided. Depending on the spatial dimension, the set at which the optimum of the trace term is reached under the action of the control function can be a point, a curve or a hypersurface. The set is determined by geometric parameters. Theoretically the lack of a convenient functional framework in the context of optimal control for hyperbolic systems leads us to consider a parabolic regularization for the state equation, in order to derive optimality conditions. For deriving these conditions, we use a change of variables encoding the sensitivity with respect to the geometric parameters. As illustration, we consider the shallow-water equations with the objective of maximizing the height of the wave at the final time, a wave whose location and shape are optimized via the geometric parameters. Numerical results are obtained in 1D and 2D, using finite difference schemes, combined with an immersed boundary method for iterating the geometric parameters.Notation. Most of the variables introduced in this paper are multi-dimensional. The functional spaces in which they lie is denoted in bold, as for example L p (Ω) = [L p (Ω)] m , W s,p = [W s,p (Ω)] m , H s = [H s (Ω)] m , for some integer m ∈ N, and for p ≥ 1, s ≥ 0.