Optimal Thermal Management and Charging of Battery Electric Vehicles over Long Trips