summaryrefslogtreecommitdiff
path: root/gpslib.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-01-08 03:43:56 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-01-08 03:43:56 +0000
commit75db070a2d69276a6f6dcfeecf62869b3fbd8c36 (patch)
tree87ef0db72c11f4a926d9bb2652f4223d0fb3d46b /gpslib.c
parentd189b1b4bcd710aee63e288598aba431386e867e (diff)
downloadgpsd-75db070a2d69276a6f6dcfeecf62869b3fbd8c36.tar.gz
Start on a second Python extension module...
...to wrap utility functions from libgps.a. The first entry point implemented is the geoidal separation calculator, because gssim needs it.
Diffstat (limited to 'gpslib.c')
-rw-r--r--gpslib.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/gpslib.c b/gpslib.c
new file mode 100644
index 00000000..ddd4582e
--- /dev/null
+++ b/gpslib.c
@@ -0,0 +1,38 @@
+/* $Id$ */
+/*
+ * Python binding for the libgps library functions
+ */
+#include <Python.h>
+
+#include <stdio.h>
+#include "gps.h"
+
+static PyObject *
+gpslib_wgs84_separation(PyObject *self, PyObject *args)
+{
+ const double lat, lon;
+ double sep;
+
+ if (!PyArg_ParseTuple(args, "dd", &lat, &lon))
+ return NULL;
+ sep = wgs84_separation(lat, lon);
+ return Py_BuildValue("d", sep);
+}
+
+/* List of functions defined in the module */
+
+static PyMethodDef gpslib_methods[] = {
+ {"wgs84_separation", gpslib_wgs84_separation, METH_VARARGS,
+ PyDoc_STR("Return WGS85 geidetic separation in meters.")},
+ {NULL, NULL} /* sentinel */
+};
+
+PyDoc_STRVAR(module_doc,
+"Python binding of selected libgps library routines.\n\
+");
+
+PyMODINIT_FUNC
+initgpslib(void)
+{
+ Py_InitModule3("gpslib", gpslib_methods, module_doc);
+}