4

There are several algorithms to calculate distance between two latitude/longitude points.

  1. Haversine
  2. Hubeny
  3. Lambert-Andoyer
  4. Vincenty's formulae for inverse problem

But there are not so many algorithms (actually I can't finally find it) which can calculate latitude/longitude of point B from another latitude/longitude point A with bearing and distance.

  1. Vincenty's formulae for direct problem

I'm glad to know if there are any algorithms which is lesser accurate, but faster than Vincenty's formulae.

1
  • 1
    The haversine formula is for the sphere. The analogous solution is based on spherical geometry; one set of formulas appears in the Wikipedia article on solving triangles.
    – whuber
    Nov 26, 2013 at 17:20

2 Answers 2

4

How about a method which is both more accurate and faster? This is provided by GeographicLib. Comparative timings (C++ implementations on a 2.66GHz Intel processor, using g++) are:

Vincenty direct:                          1.11 us
GeographicLib::Geodesic::Direct:          0.88 us
GeographicLib::GeodesicLine::Position:    0.37 us
GeographicLib::GeodesicLine::ArcPosition: 0.31 us

The accuracy of Vincenty's formulas is about 0.1 mm, while the accuracy of the GeographicLib algorithms about 0.01 um. Geodesic::Direct does a straight solution of the direct problem. It's somewhat faster than Vincenty because it's non-iterative and because it uses Clenshaw summation to evaluate the trigonometric series. GeodesicLine::Position allows you to calculate many points along a single geodesic about 2.4 times faster. If you merely want some points on a geodesic which are approximately equally spaced (e.g., for plotting it), you can use GeodesicLine::ArcPosition and shave a little extra time off the computation. You can reduce the time still further by reducing the order of the series used by GeographicLib from 6 to 3 by compiling with

-DGEOGRAPHICLIB_GEODESIC_ORDER=3

The accuracy is then 0.04 mm, i.e., comparable to, but slightly better than, Vincenty.

A cookbook recipe for solving the equivalent problem on a sphere is given by the Wikipedia entry on great-circle navigation.

0

Here is a link to some code that will do what you are looking for, but will require a bit of work to use:

Inverse and Forward Azimuth Algorithms

The source code is in Fortran so you will have to convert it to the format of your choice. I have used these algorithms in the past without any problems but you will need to test them to determine if they are accurate enough for your needs.

1
  • These, according to the documentation, are the Vincenty algorithms cited in the question.
    – whuber
    Nov 27, 2013 at 2:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.