/// <summary>
        /// calcula el tiempo de demora de un determinado viaje
        /// </summary>
        /// <param name="viaje"></param>
        /// <returns>tiempo en minutos</returns>
        public async Task <TimeSpan> tiempoDemoraTotal(Viaje viaje)
        {
            try
            {
                HttpClient cliente = new HttpClient();
                int        tiempo  = int.MaxValue;
                string     path    = null;
                if (!string.IsNullOrEmpty(viaje.DireccionDestino))
                {
                    path = "https://maps.googleapis.com/maps/api/directions/json?origin=" + viaje.Origen.Latitud + ", " + viaje.Origen.Longitud + "&destination=" + viaje.Destino.Latitud + "," + viaje.Destino.Longitud;
                }
                else
                {
                    path = "https://maps.googleapis.com/maps/api/directions/json?origin=" + viaje.Origen.Latitud + ", " + viaje.Origen.Longitud + "&destination=" + viaje.Origen.Latitud + "," + viaje.Origen.Longitud;
                }
                if (viaje.Items.Count > 10)
                {
                    throw new MensajeException("Debe ingresar como máximo 10 items");
                }
                else
                {
                    if (viaje.Items.Count != 0)
                    {
                        path += "&waypoints = optimize:true";
                        foreach (Item i in viaje.Items)
                        {
                            path += "|via:" + i.Origen.Latitud + ", " + i.Origen.Longitud + "|via:" + i.Destino.Latitud + ", " + i.Destino.Longitud;
                        }
                    }

                    path += "&key=AIzaSyB08YiU7GpCk0RCQozZWxiIj3Ud3se0_Ec";
                }

                HttpResponseMessage response = await cliente.GetAsync(path);

                if (response.IsSuccessStatusCode)
                {
                    DemoraWaypoints obj   = JsonConvert.DeserializeObject <DemoraWaypoints>(await response.Content.ReadAsStringAsync());
                    Route           route = obj.routes[0];
                    Leg             leg   = route.legs[0];
                    tiempo = int.Parse(leg.duration.text.Split(" ")[0]);
                }
                TimeSpan minutes = TimeSpan.FromMinutes(tiempo);
                return(minutes);
            }
            catch (TimeoutException)
            {
                throw new MensajeException("Se agoto el tiempo de espera, vuelva a intentarlo en unos minutos");
            }
            catch (MensajeException msg)
            {
                throw msg;
            }
            catch (Exception)
            {
                throw new MensajeException("Compruebe el formato de las direcciones ingresadas");
            }
        }
        /// <summary>
        /// basandose en la api de google se calculan aprox los km del viaje
        /// </summary>
        /// <param name="viaje"></param>
        /// <returns>double con la cantidad de km del viaje</returns>
        public async Task <double> cantidadKmAproximado(Viaje viaje)
        {
            try
            {
                HttpClient cliente = new HttpClient();
                double     salida  = 0;
                string     path    = null;
                if (!string.IsNullOrEmpty(viaje.DireccionDestino))
                {
                    path = "https://maps.googleapis.com/maps/api/directions/json?origin=" + viaje.Origen.Latitud + ", " + viaje.Origen.Longitud + "&destination=" + viaje.Destino.Latitud + "," + viaje.Destino.Longitud;
                }
                else
                {
                    path = "https://maps.googleapis.com/maps/api/directions/json?origin=" + viaje.Origen.Latitud + ", " + viaje.Origen.Longitud + "&destination=" + viaje.Vehiculo.PosicionSatelital.Latitud + "," + viaje.Vehiculo.PosicionSatelital.Longitud;
                }
                if (viaje.Items.Count > 10)
                {
                    throw new MensajeException("Debe ingresar como máximo 10 items");
                }
                else
                {
                    if (viaje.Items.Count != 0)
                    {
                        path += "&waypoints = optimize:true";
                        foreach (Item i in viaje.Items)
                        {
                            path += "|via:" + i.Origen.Latitud + ", " + i.Origen.Longitud + "|via:" + i.Destino.Latitud + ", " + i.Destino.Longitud;
                        }
                    }

                    path += "&key=AIzaSyB08YiU7GpCk0RCQozZWxiIj3Ud3se0_Ec";
                }

                HttpResponseMessage response = await cliente.GetAsync(path);

                if (response.IsSuccessStatusCode)
                {
                    DemoraWaypoints obj   = JsonConvert.DeserializeObject <DemoraWaypoints>(await response.Content.ReadAsStringAsync());
                    Route           route = obj.routes[0];
                    Leg             leg   = route.legs[0];
                    if (leg.distance.text.Split(" ")[1].Equals("km"))
                    {
                        double km = leg.distance.value;
                        salida = km / 1000;
                    }
                }

                return(salida);
            }
            catch (TimeoutException)
            {
                throw new MensajeException("Se agoto el tiempo de espera, vuelva a intentarlo en unos minutos");
            }
            catch (MensajeException msg)
            {
                throw msg;
            }catch (Exception)
            {
                throw new MensajeException("Compruebe el formato de las direcciones ingresadas");
            }
        }