diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-03-29 08:39:56 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-03-29 08:39:56 -0400 |
commit | 5f2026dae224c38b6f725e9697626edf989698eb (patch) | |
tree | 00669a230af25e66de1189bb28914bb8baec45fb /gpsclient.c | |
parent | 4873e25e90661026c16aa169096ca94254389f16 (diff) | |
download | gpsd-5f2026dae224c38b6f725e9697626edf989698eb.tar.gz |
Make the Maidenhead convrter available in Python.
Diffstat (limited to 'gpsclient.c')
-rw-r--r-- | gpsclient.c | 14 |
1 files changed, 14 insertions, 0 deletions
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 */ }; |