summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cgps.c2
-rw-r--r--gpsclient.c14
-rw-r--r--gpsdclient.c2
-rw-r--r--gpsdclient.h2
-rw-r--r--lcdgps.c6
5 files changed, 20 insertions, 6 deletions
diff --git a/cgps.c b/cgps.c
index 503489b8..6f2eefab 100644
--- a/cgps.c
+++ b/cgps.c
@@ -694,7 +694,7 @@ static void update_gps_panel(struct gps_data_t *gpsdata)
/* Fill in the grid square (esr thought *this* one was interesting). */
/*@-branchstate@*/
if (isnan(gpsdata->fix.longitude)==0 && isnan(gpsdata->fix.latitude)==0)
- s = latlon2maidenhead(gpsdata->fix.latitude,gpsdata->fix.longitude);
+ s = maidenhead(gpsdata->fix.latitude,gpsdata->fix.longitude);
else
s = "n/a";
(void)mvwprintw(datawin, 15, DATAWIN_VALUE_OFFSET + 5, "%-*s", 22, s);
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 */
};
diff --git a/gpsdclient.c b/gpsdclient.c
index c9137c52..b4c0723a 100644
--- a/gpsdclient.c
+++ b/gpsdclient.c
@@ -175,7 +175,7 @@ void gpsd_source_spec(const char *arg, struct fixsource_t *source)
/*@ +observertrans -statictrans +mustfreeonly +branchstate +kepttrans @*/
-char *latlon2maidenhead(double n, double e)
+char *maidenhead(double n, double e)
/* lat/lon to Maidenhead (from QGrid - http://users.pandora.be/on4qz/qgrid/) */
{
static char buf[7];
diff --git a/gpsdclient.h b/gpsdclient.h
index 54cf0554..799de6ce 100644
--- a/gpsdclient.h
+++ b/gpsdclient.h
@@ -26,7 +26,7 @@ extern /*@observer@*/ char *deg_to_str( enum deg_str_type type, double f);
extern void gpsd_source_spec(/*@null@*/const char *fromstring,
/*@out@*/struct fixsource_t *source);
-char *latlon2maidenhead(double n,double e);
+char *maidenhead(double n,double e);
#endif /* _GPSDCLIENT_H_ */
/* gpsdclient.h ends here */
diff --git a/lcdgps.c b/lcdgps.c
index 790c96c8..52bc1fab 100644
--- a/lcdgps.c
+++ b/lcdgps.c
@@ -181,11 +181,11 @@ static void update_lcd(struct gps_data_t *gpsdata)
{
char tmpbuf[255];
int n;
- char *s, *maidenhead;
+ char *s, *gridsquare;
int track;
/* Get our location in Maidenhead. */
- maidenhead = latlon2maidenhead(gpsdata->fix.latitude,gpsdata->fix.longitude);
+ gridsquare = maidenhead(gpsdata->fix.latitude,gpsdata->fix.longitude);
/* Fill in the latitude and longitude. */
if (gpsdata->fix.mode >= MODE_2D) {
@@ -223,7 +223,7 @@ static void update_lcd(struct gps_data_t *gpsdata)
for(n=0;n<CLIMB;n++) avgclimb+=climb[n];
avgclimb/=CLIMB;
snprintf(tmpbuf, 254, "widget_set gpsd four 1 4 {%d %s %s %d fpm }\n",
- (int)(gpsdata->fix.altitude*altfactor), altunits, maidenhead, (int)(avgclimb * METERS_TO_FEET * 60));
+ (int)(gpsdata->fix.altitude*altfactor), altunits, gridsquare, (int)(avgclimb * METERS_TO_FEET * 60));
} else {
snprintf(tmpbuf, 254, "widget_set gpsd four 1 4 {n/a}\n");
}