Precisión de la distancia entre pares de latitud y longitud

I need to sort a set of addresses based on the distance from a specifc point. I have latitude and longitude for all these addressses,I am finding the distance with the below Java code.

Double theDistance = (Math.sin(Math.toRadians(latA)) *
                Math.sin(Math.toRadians(latB)) +
                Math.cos(Math.toRadians(latA)) *
                Math.cos(Math.toRadians(latB)) *
                Math.cos(Math.toRadians(longA - longB)));       
            theDistance = (Math.toDegrees(Math.acos(theDistance))) * 69.09;\

But when I compare the results(I mean the sort order (not the actual distance)) with the actual Google map, they don't match. Is it the case always? or Am I not doing it correct?

We found that for Google/Yahoo map web service has some restrictions as a result we can't use in our application.

What is the best way to find the distance between two addresses given that you have the latitude and longitude.

preguntado el 08 de noviembre de 11 a las 15:11

Are you comparing straight (well, curved) line distance? Or when you look it up are you looking at the driving distance? :) -

I am comparing the distance obtained from the formula I mentioned, I believe it gives straight line distance but I am not sure. -

There's always a loss of precision when you convert to Radians, and that multiplication by 69.09 doesn't help accuracy either. There are several Stack Overflow questions that are exactly the same and most of them show sample code. You'll be best served looking at those, in my humble opinion. -

alright I will look into, but my question is Is it right to compare a set of addresses based on the latitude and longitude distances vs the actual driving distance given by google maps. -

Doesn't driving distance have to take into account what roads actually exist? -

2 Respuestas

Creo que podrías estar buscando el Distancia del gran círculo.

respondido 08 nov., 11:19

Vincenty's formula will give you the maximum accuracy.

Haversine's one might be "good enough".

respondido 08 nov., 11:20

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.