Approximate solution of the generalized Riemann problem and applications