C library for Geodesics
1.43
|
This is a C implementation of the geodesic algorithms from GeographicLib. This is a self-contained library (requiring only the standard C math library) which makes it easy to do geodesic computations for an ellipsoid of revolution in a C program. It uses ANSI C as described in B. W. Kernigan and D. M. Ritchie, The C Programming Language, 2nd Ed. (Prentice Hall, 1988), and so should compile correctly with just about any C compiler.
The C library is part of GeographicLib which available for download at
as either a compressed tar file (tar.gz) or a zip file. After unpacking the source, the C library can be found in GeographicLib-1.43/legacy/C. The library consists of two files geodesic.c and geodesic.h.
The library is also included as part of proj.4 starting with version 4.9.0, where is used as the computational backend for geod(1). Instructions for how to use the library via proj.4 are given below.
The interface to the library is documented via doxygen in the header file. To access this, see geodesic.h.
Also included are 3 small test programs:
Here, for example, is inverse.c
To compile, link, and run this, you would typically use
cc -o inverse inverse.c geodesic.c -lm echo 30 0 29.5 179.5 | ./inverse
These sample programs can also be built with the supplied cmake file, CMakeLists.txt, as follows
mkdir BUILD cd BUILD cmake .. make echo 30 0 29.5 179.5 | ./inverse
Alternatively, if you have proj.4 installed, you can compile and link with
cc -c inverse.c cc -o inverse inverse.o -lproj echo 30 0 29.5 179.5 | ./inverse
If proj.4 is installed, e.g., in /usr/local, you might have to use
cc -c -I/usr/local/include inverse.c cc -o inverse inverse.o -lproj -L/usr/local/lib -Wl,-rpath=/usr/local/lib echo 30 0 29.5 179.5 | ./inverse
#include "geodesic.h"in your source code. If you are using the library via proj.4, change this to
#include <geodesic.h>