summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..487171b
--- /dev/null
+++ b/main.c
@@ -0,0 +1,41 @@
+#include <u.h>
+#include <libc.h>
+#include "geodesic.h"
+
+typedef struct Geomodel Geomodel;
+
+struct Geomodel
+{
+ double a; /* equatorial radius */
+ double f; /* flattening */
+};
+
+Geomodel WGS84 = { 6378137, 1/298.257223563 };
+
+void
+usage(void)
+{
+ fprint(2, "usage: %s lat0 lon0 lat1 lon1\n", argv0);
+ exits("usage");
+}
+
+void
+main(int argc, char *argv[])
+{
+ Geodesic g;
+ double lat0, lon0, lat1, lon1;
+ double s12;
+
+ ARGBEGIN{
+ default: usage();
+ }ARGEND;
+ if(argc != 4)
+ usage();
+ lat0 = strtod(argv[0], nil);
+ lon0 = strtod(argv[1], nil);
+ lat1 = strtod(argv[2], nil);
+ lon1 = strtod(argv[3], nil);
+ initgeod(&g, WGS84.a, WGS84.f);
+ inversegeod(&g, lat0, lon0, lat1, lon1, &s12, nil, nil);
+ print("%gm\n", s12);
+}