Mathematical treatment of optimal ocean ship routeing