aboutsummaryrefslogtreecommitdiff
path: root/src/geod_interface.c
diff options
context:
space:
mode:
authorFrank Warmerdam <warmerdam@pobox.com>2012-12-07 21:52:03 +0000
committerFrank Warmerdam <warmerdam@pobox.com>2012-12-07 21:52:03 +0000
commitf1f1f9f2aea725663499f449961027df2b38e296 (patch)
treec79e7af878791bd20b845f8340caeea3cc57ea66 /src/geod_interface.c
parent927b539faa5686624d2681ffeadad827e583365c (diff)
downloadPROJ-f1f1f9f2aea725663499f449961027df2b38e296.tar.gz
PROJ-f1f1f9f2aea725663499f449961027df2b38e296.zip
replacement of geodesic engine with one from Charles Karney (#197)
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@2297 4e78687f-474d-0410-85f9-8d5e500ac6b2
Diffstat (limited to 'src/geod_interface.c')
-rw-r--r--src/geod_interface.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/geod_interface.c b/src/geod_interface.c
new file mode 100644
index 00000000..c144a35d
--- /dev/null
+++ b/src/geod_interface.c
@@ -0,0 +1,34 @@
+#include "projects.h"
+#include "geod_interface.h"
+
+void geod_ini(void) {
+ GeodesicInit(&GlobalGeodesic, geod_a, geod_f);
+}
+
+void geod_pre(void) {
+ double
+ degree = PI/180,
+ lat1 = phi1 / degree, lon1 = lam1 /degree, azi1 = al12 / degree;
+ GeodesicLineInit(&GlobalGeodesicLine, &GlobalGeodesic,
+ lat1, lon1, azi1, 0U);
+}
+
+void geod_for(void) {
+ double degree = PI/180, s12 = geod_S, lat2, lon2, azi2;
+ Position(&GlobalGeodesicLine, s12, &lat2, &lon2, &azi2);
+ azi2 += azi2 >= 0 ? -180 : 180; /* Compute back azimuth */
+ phi2 = lat2 * degree;
+ lam2 = lon2 * degree;
+ al21 = azi2 * degree;
+}
+
+void geod_inv(void) {
+ double
+ degree = PI / 180,
+ lat1 = phi1 / degree, lon1 = lam1 / degree,
+ lat2 = phi2 / degree, lon2 = lam2 / degree,
+ azi1, azi2, s12;
+ Inverse(&GlobalGeodesic, lat1, lon1, lat2, lon2, &s12, &azi1, &azi2);
+ azi2 += azi2 >= 0 ? -180 : 180; /* Compute back azimuth */
+ al12 = azi1 * degree; al21 = azi2 * degree; geod_S = s12;
+}