-1

I have to make an app that has the recomended route to some location, but if the car moves 100 meters (a street length) i don't know how to verfy if the car is on the route or not

Now i just only call google-maps-direcctions-api if the last location in the map and the actual have 100 meters of difference

//THIS IS SOME CODE THAT I USE TO VERIFY IF THE CAR IS 100 METERS AWAY FROM THE LAST POINT
 public void verificaMapa(){
        double distancia_ultimo_dibujo = Utilidad.calcularDistancia(WebService.lat_actual,WebService.long_actual,ultimaLocalizacionDibujada.latitude,ultimaLocalizacionDibujada.longitude);
        double distancia_destino = Utilidad.calcularDistancia(WebService.lat_actual,WebService.long_actual,cordenadasDestino.latitude,cordenadasDestino.longitude);
        WebService.distancia_a_recorrer = distancia_destino;
        if(AppPrendida){
            if(distancia_ultimo_dibujo > 100 && distancia_destino > 100){
                Location localizacion_actual = new Location("");
                localizacion_actual.setLatitude(WebService.lat_actual);
                localizacion_actual.setLongitude(WebService.long_actual);
                DrawRoute(localizacion_actual);
            }
        }
        if(distancia_destino <= 100 && !guardadollegaDestino){
            WebService.distancia_a_recorrer = distancia_destino;
            WebService.EstadoActual = 4;
            guardadollegaDestino = true;
        }
    }
  • Possible duplicate of [java.net.SocketException: sendto failed: ECONNRESET (Connection reset by peer)](https://stackoverflow.com/questions/36871636/java-net-socketexception-sendto-failed-econnreset-connection-reset-by-peer) – hc0re Sep 26 '19 at 18:44

1 Answers1

0

I finaly found the solution:

Just using trigonometry to do it. The formula is

  • distanceFromActualToEndPoint + distanceFromActualToBeginPoint - distanceFromBeginPointToEndPoint

If the difference is bigger than 15 meeters the car is out of the direcction.