From 5f2026dae224c38b6f725e9697626edf989698eb Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 29 Mar 2011 08:39:56 -0400 Subject: Make the Maidenhead convrter available in Python. --- gpsclient.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gpsclient.c') diff --git a/gpsclient.c b/gpsclient.c index f32b8af6..85269688 100644 --- a/gpsclient.c +++ b/gpsclient.c @@ -49,6 +49,18 @@ gpsclient_wgs84_separation(PyObject *self, PyObject *args) return Py_BuildValue("d", sep); } +static PyObject * +gpsclient_maidenhead(PyObject *self, PyObject *args) +{ + const double lat, lon; + char *gs; + + if (!PyArg_ParseTuple(args, "dd", &lat, &lon)) + return NULL; + gs = maidenhead(lat, lon); + return Py_BuildValue("s", gs); +} + /* List of functions defined in the module */ static PyMethodDef gpsclient_methods[] = { @@ -58,6 +70,8 @@ static PyMethodDef gpsclient_methods[] = { PyDoc_STR("String-format a latitude/longitude.")}, {"gpsd_units", gpsclient_gpsd_units, METH_VARARGS, PyDoc_STR("Deduce a set of units from locale and environment.")}, + {"maidenhead", gpsclient_maidenhead, METH_VARARGS, + PyDoc_STR("Maidenhead grid-square locator from lat/lon.")}, {NULL, NULL} /* sentinel */ }; -- cgit v1.2.1