mirror of
https://github.com/owntracks/recorder.git
synced 2026-08-27 16:57:21 +00:00
@@ -1091,3 +1091,6 @@ We also have a Docker image to create containers which integrate a [Mosquitto br
|
||||
|
||||
It actually is possible to gateway location publishes arriving via HTTP into MQTT, though you should be careful not to create loops. You can accomplish this with one or more Lua hooks using MQTT from within Lua.
|
||||
|
||||
### Override reverse-geo precision
|
||||
|
||||
If a payload is received with an element called `_geoprec` it contains an ovveride for the Recorder's configured reverse-geo precision.
|
||||
|
||||
+16
-2
@@ -536,7 +536,7 @@ void handle_message(void *userdata, char *topic, char *payload, size_t payloadle
|
||||
static UT_string *reltopic = NULL, *filename = NULL;
|
||||
char *jsonstring, *_typestr = NULL;
|
||||
time_t now;
|
||||
int pingping = FALSE, skipslash = 0;
|
||||
int pingping = FALSE, skipslash = 0, geoprec = geohash_prec();
|
||||
int r_ok = TRUE; /* True if recording enabled for a publish */
|
||||
payload_type _type;
|
||||
|
||||
@@ -777,6 +777,12 @@ void handle_message(void *userdata, char *topic, char *payload, size_t payloadle
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
if (impossible_rule(ud, UB(username), UB(device), tst, lat, lon) == TRUE) {
|
||||
goto cleanup;
|
||||
}
|
||||
*/
|
||||
|
||||
if ((j = json_find_member(json, "acc")) != NULL) {
|
||||
if (j->tag == JSON_STRING) {
|
||||
acc = atof(j->string_);
|
||||
@@ -798,6 +804,14 @@ void handle_message(void *userdata, char *topic, char *payload, size_t payloadle
|
||||
}
|
||||
}
|
||||
|
||||
if ((j = json_find_member(json, "_geoprec")) != NULL) {
|
||||
if (j->tag == JSON_STRING) {
|
||||
geoprec = atoi(j->string_);
|
||||
} else {
|
||||
geoprec = j->number_;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Haversine */
|
||||
|
||||
@@ -833,7 +847,7 @@ void handle_message(void *userdata, char *topic, char *payload, size_t payloadle
|
||||
utstring_renew(ghash);
|
||||
utstring_renew(addr);
|
||||
utstring_renew(cc);
|
||||
p = geohash_encode(lat, lon, geohash_prec());
|
||||
p = geohash_encode(lat, lon, geoprec);
|
||||
if (p != NULL) {
|
||||
utstring_printf(ghash, "%s", p);
|
||||
free(p);
|
||||
|
||||
@@ -634,6 +634,7 @@ static JsonNode *line_to_location(char *line)
|
||||
char tstamp[64], *bp;
|
||||
double lat, lon;
|
||||
long tst;
|
||||
int geoprec = geohash_prec();
|
||||
|
||||
snprintf(tstamp, 21, "%s", line);
|
||||
|
||||
@@ -670,7 +671,11 @@ static JsonNode *line_to_location(char *line)
|
||||
lon = j->number_;
|
||||
}
|
||||
|
||||
if ((ghash = geohash_encode(lat, lon, geohash_prec())) != NULL) {
|
||||
if ((j = json_find_member(o, "_geoprec")) != NULL) {
|
||||
geoprec = j->number_;
|
||||
}
|
||||
|
||||
if ((ghash = geohash_encode(lat, lon, geoprec)) != NULL) {
|
||||
json_append_member(o, "ghash", json_mkstring(ghash));
|
||||
get_geo(o, ghash);
|
||||
free(ghash);
|
||||
|
||||
Reference in New Issue
Block a user