OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
vincenty.c File Reference
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
Include dependency graph for vincenty.c:

Go to the source code of this file.

Macros

#define VINCENTY_TOLERANCE   1e-12
 
#define VINCENTY_MAX_LOOP   1e3
 
#define USE_HELMERTS   1
 
#define pi   3.14159265358979323846264338327950288419716939937510582097494459230781640628620899L
 
#define flattening   (1 / 298.257223563)
 
#define semimajor   6378137.0
 
#define semiminor   ((1 - flattening) * semimajor)
 

Functions

double vincenty_distance (double lat1, double lon1, double lat2, double lon2)
 

Macro Definition Documentation

◆ flattening

#define flattening   (1 / 298.257223563)

Definition at line 24 of file vincenty.c.

◆ pi

#define pi   3.14159265358979323846264338327950288419716939937510582097494459230781640628620899L

Definition at line 23 of file vincenty.c.

◆ semimajor

#define semimajor   6378137.0

Definition at line 25 of file vincenty.c.

◆ semiminor

#define semiminor   ((1 - flattening) * semimajor)

Definition at line 26 of file vincenty.c.

◆ USE_HELMERTS

#define USE_HELMERTS   1

Use Helmert's expansion something-or-other.

https://en.wikipedia.org/wiki/Vincenty's_formulae#Vincenty.27s_modification

Definition at line 20 of file vincenty.c.

◆ VINCENTY_MAX_LOOP

#define VINCENTY_MAX_LOOP   1e3

Used to prevent infinite loops caused by non-convergence.

Definition at line 12 of file vincenty.c.

◆ VINCENTY_TOLERANCE

#define VINCENTY_TOLERANCE   1e-12

Used to control the accuracy requirement. 1e−12 corresponds to approximately 0.06mm.

Definition at line 7 of file vincenty.c.

Function Documentation

◆ vincenty_distance()

double vincenty_distance ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)

Calculate geographical distances using Vincenty's algorithm.

Parameters
[in]lat1Latitude, in degrees, of first point.
[in]lon1Longitude, in degrees, of first point.
[in]lat2Latitude, in degrees, of second point.
[in]lon2Longitude, in degrees, of second point.
[out]metersDistance between the two points, in meters.
Returns
0 on success.

Definition at line 47 of file vincenty.c.