mirror of
https://github.com/owntracks/recorder.git
synced 2024-11-15 09:58:40 -07:00
allow negative _geoprec
This commit is contained in:
parent
4ec7d81665
commit
838a303d38
@ -1093,5 +1093,5 @@ It actually is possible to gateway location publishes arriving via HTTP into MQT
|
||||
|
||||
### 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. So, for example, if Recorder is running with precision 7, say, and the received payload contains `"_geoprec" : 2` the 2 will be used for this particular publish. This is not used in the OwnTracks apps, but it can be used with payloads you generate otherwise.
|
||||
If a payload is received with an element called `_geoprec` it contains an overide for the Recorder's configured reverse-geo precision. So, for example, if Recorder is running with precision 7, say, and the received payload contains `"_geoprec" : 2` the 2 will be used for this particular publish. This is not used in the OwnTracks apps, but it can be used with payloads you generate otherwise. If `_geoprec` is negative, new reverse geo lookups will not be performed, but cached entries of `abs(_geoprec)` will be used.
|
||||
|
||||
|
26
recorder.c
26
recorder.c
@ -849,7 +849,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, geoprec);
|
||||
p = geohash_encode(lat, lon, abs(geoprec));
|
||||
if (p != NULL) {
|
||||
utstring_printf(ghash, "%s", p);
|
||||
free(p);
|
||||
@ -870,19 +870,21 @@ void handle_message(void *userdata, char *topic, char *payload, size_t payloadle
|
||||
utstring_printf(addr, "%s", j->string_);
|
||||
}
|
||||
} else {
|
||||
if ((geo = revgeo(ud, lat, lon, addr, cc)) != NULL) {
|
||||
gcache_json_put(ud->gc, UB(ghash), geo);
|
||||
} else {
|
||||
/* We didn't obtain reverse Geo, maybe because of over
|
||||
* quota; make a note of the missing geohash */
|
||||
if (geoprec > 0) {
|
||||
if ((geo = revgeo(ud, lat, lon, addr, cc)) != NULL) {
|
||||
gcache_json_put(ud->gc, UB(ghash), geo);
|
||||
} else {
|
||||
/* We didn't obtain reverse Geo, maybe because of over
|
||||
* quota; make a note of the missing geohash */
|
||||
|
||||
char gfile[BUFSIZ];
|
||||
FILE *fp;
|
||||
char gfile[BUFSIZ];
|
||||
FILE *fp;
|
||||
|
||||
snprintf(gfile, BUFSIZ, "%s/ghash/missing", STORAGEDIR);
|
||||
if ((fp = fopen(gfile, "a")) != NULL) {
|
||||
fprintf(fp, "%s %lf %lf\n", UB(ghash), lat, lon);
|
||||
fclose(fp);
|
||||
snprintf(gfile, BUFSIZ, "%s/ghash/missing", STORAGEDIR);
|
||||
if ((fp = fopen(gfile, "a")) != NULL) {
|
||||
fprintf(fp, "%s %lf %lf\n", UB(ghash), lat, lon);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -675,7 +675,7 @@ static JsonNode *line_to_location(char *line)
|
||||
geoprec = j->number_;
|
||||
}
|
||||
|
||||
if ((ghash = geohash_encode(lat, lon, geoprec)) != NULL) {
|
||||
if ((ghash = geohash_encode(lat, lon, abs(geoprec))) != NULL) {
|
||||
json_append_member(o, "ghash", json_mkstring(ghash));
|
||||
get_geo(o, ghash);
|
||||
free(ghash);
|
||||
|
Loading…
Reference in New Issue
Block a user