Add support for controlling the accuracy of the receiver location
written in the JSON metadata used by the webmap.
This commit is contained in:
parent
bbcfbb8279
commit
58dfbdcb6b
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -3,6 +3,8 @@ dump1090-mutability (1.08.2302.14+1mu-4) UNRELEASED; urgency=medium
|
|||
* Remove half-implemented --no-decode option.
|
||||
* Remove Windows support files that aren't needed for the Debian package.
|
||||
* Remove some legacy support scripts not needed by the Debian package.
|
||||
* Add support for controlling the accuracy of the receiver location
|
||||
written in the JSON metadata used by the webmap.
|
||||
|
||||
-- Oliver Jowett <oliver@mutability.co.uk> Sat, 27 Dec 2014 20:08:44 +0000
|
||||
|
||||
|
|
3
debian/config-template
vendored
3
debian/config-template
vendored
|
@ -112,5 +112,8 @@ JSON_DIR=
|
|||
# Interval between writing json state (in seconds). 0 disables.
|
||||
JSON_INTERVAL=
|
||||
|
||||
# Accuracy of receiver location to write to json state, one of "exact" / "approximate" / "none"
|
||||
JSON_LOCATION_ACCURACY=
|
||||
|
||||
# Additional options that are passed to the Daemon.
|
||||
EXTRA_ARGS=
|
||||
|
|
2
debian/dump1090-mutability.config
vendored
2
debian/dump1090-mutability.config
vendored
|
@ -47,6 +47,7 @@ if [ -e $CONFIGFILE ]; then
|
|||
db_set $NAME/stats-interval "$STATS_INTERVAL"
|
||||
db_set $NAME/json-dir "$JSON_DIR"
|
||||
db_set $NAME/json-interval "$JSON_INTERVAL"
|
||||
db_set $NAME/json-location-accuracy "$JSON_LOCATION_ACCURACY"
|
||||
db_set $NAME/extra-args "$EXTRA_ARGS"
|
||||
fi
|
||||
|
||||
|
@ -202,6 +203,7 @@ db_go || true; db_get $NAME/auto-start; if [ "$RET" = "true" ]; then
|
|||
db_go || true; db_get $NAME/json-interval; if [ -n "$RET" ] && [ "$RET" -gt 0 ]; then
|
||||
# only if json-interval was given and non-zero
|
||||
db_input low $NAME/json-dir || true
|
||||
db_input low $NAME/json-location-accuracy || true
|
||||
fi
|
||||
|
||||
db_input low $NAME/extra-args || true
|
||||
|
|
6
debian/dump1090-mutability.init
vendored
6
debian/dump1090-mutability.init
vendored
|
@ -83,6 +83,12 @@ if [ -n "$NET_BIND_ADDRESS" ]; then ARGS="$ARGS --net-bind-address $NET_BIND_ADD
|
|||
if [ -n "$STATS_INTERVAL" ]; then ARGS="$ARGS --stats-every $STATS_INTERVAL"; fi
|
||||
if [ -n "$JSON_DIR" ]; then ARGS="$ARGS --write-json $JSON_DIR"; fi
|
||||
if [ -n "$JSON_INTERVAL" ]; then ARGS="$ARGS --write-json-every $JSON_INTERVAL"; fi
|
||||
case "x$JSON_LOCATION_ACCURACY" in
|
||||
xexact) ARGS="$ARGS --json-location-accuracy 2" ;;
|
||||
xapproximate) ARGS="$ARGS --json-location-accuracy 1" ;;
|
||||
*) ARGS="$ARGS --json-location-accuracy 0" ;;
|
||||
esac
|
||||
|
||||
if [ -n "$EXTRA_ARGS" ]; then ARGS="$ARGS $EXTRA_ARGS"; fi
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
|
|
1
debian/dump1090-mutability.postinst
vendored
1
debian/dump1090-mutability.postinst
vendored
|
@ -84,6 +84,7 @@ case "$1" in
|
|||
subvar stats-interval STATS_INTERVAL
|
||||
subvar json-dir JSON_DIR
|
||||
subvar json-interval JSON_INTERVAL
|
||||
subvar json-location-accuracy JSON_LOCATION_ACCURACY
|
||||
subvar extra-args EXTRA_ARGS
|
||||
|
||||
cp -a -f $CONFIGFILE $CONFIGFILE.tmp
|
||||
|
|
21
debian/dump1090-mutability.templates
vendored
21
debian/dump1090-mutability.templates
vendored
|
@ -234,6 +234,27 @@ Description: Interval between writing JSON aircraft state, in seconds:
|
|||
Type: string
|
||||
Default: 1
|
||||
|
||||
Template: dump1090-mutability/json-location-accuracy
|
||||
Description: Receiver location accuracy to show in the web interface:
|
||||
dump1090 can provide the configured receiver location to the web map,
|
||||
so that the map can show distances from the receiver.
|
||||
.
|
||||
For privacy reasons, if you are making the map publicly available you
|
||||
may not want to show the exact location of the receiver. There are three
|
||||
options available to control what is shown:
|
||||
.
|
||||
approximate: dump1090 will provide the receiver location rounded to the
|
||||
nearest 0.01 degree of latitude and longitude. This gives a location
|
||||
that is accurate to within about 0.5 - 1km.
|
||||
.
|
||||
exact: dump1090 will provide the exact receiver location.
|
||||
.
|
||||
none: dump1090 will not provide the receiver location at all; distance
|
||||
display will be disabled.
|
||||
Type: select
|
||||
Choices: approximate, exact, none
|
||||
Default: approximate
|
||||
|
||||
Template: dump1090-mutability/extra-args
|
||||
Description: Extra arguments to pass to dump1090:
|
||||
Here you can add any extra arguments you want to pass to dump1090.
|
||||
|
|
|
@ -83,6 +83,7 @@ void modesInitConfig(void) {
|
|||
Modes.fUserLat = MODES_USER_LATITUDE_DFLT;
|
||||
Modes.fUserLon = MODES_USER_LONGITUDE_DFLT;
|
||||
Modes.json_interval = 1;
|
||||
Modes.json_location_accuracy = 1;
|
||||
}
|
||||
//
|
||||
//=========================================================================
|
||||
|
@ -448,6 +449,7 @@ void showHelp(void) {
|
|||
"--no-decode Don't decode the message contents beyond the minimum necessary\n"
|
||||
"--write-json <dir> Periodically write json output to <dir> (for serving by a separate webserver)\n"
|
||||
"--write-json-every <t> Write json output every t seconds (default 1)\n"
|
||||
"--json-location-accuracy <n> Accuracy of receiver location in json metadata: 0=no location, 1=approximate, 2=exact\n"
|
||||
"--help Show this help\n"
|
||||
"\n"
|
||||
"Debug mode flags: d = Log frames decoded with errors\n"
|
||||
|
@ -844,6 +846,8 @@ int main(int argc, char **argv) {
|
|||
strcat(Modes.json_metadata_path, "/receiver.json");
|
||||
} else if (!strcmp(argv[j], "--write-json-every") && more) {
|
||||
Modes.json_interval = atoi(argv[++j]);
|
||||
} else if (!strcmp(argv[j], "--json-location-accuracy") && more) {
|
||||
Modes.json_location_accuracy = atoi(argv[++j]);
|
||||
#endif
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
|
|
|
@ -371,6 +371,7 @@ struct { // Internal state
|
|||
char *json_aircraft_path; // Path to json aircraft file to write, or NULL not to.
|
||||
char *json_metadata_path; // Path to json metadata file to write, or NULL not to.
|
||||
int json_interval; // Interval between rewriting the json aircraft file
|
||||
int json_location_accuracy; // Accuracy of location metadata: 0=none, 1=approx, 2=exact
|
||||
|
||||
// User details
|
||||
double fUserLat; // Users receiver/antenna lat/lon needed for initial surface location
|
||||
|
|
9
net_io.c
9
net_io.c
|
@ -739,11 +739,18 @@ char *generateReceiverJson(int *len)
|
|||
"\"refresh\" : %d",
|
||||
MODES_DUMP1090_VERSION, Modes.json_interval * 1000);
|
||||
|
||||
if (Modes.fUserLat != 0.0 || Modes.fUserLon != 0.0) {
|
||||
if (Modes.json_location_accuracy && (Modes.fUserLat != 0.0 || Modes.fUserLon != 0.0)) {
|
||||
if (Modes.json_location_accuracy == 1) {
|
||||
p += sprintf(p, ", " \
|
||||
"\"lat\" : %.2f, "
|
||||
"\"lon\" : %.2f",
|
||||
Modes.fUserLat, Modes.fUserLon); // round to 2dp - about 0.5-1km accuracy - for privacy reasons
|
||||
} else {
|
||||
p += sprintf(p, ", " \
|
||||
"\"lat\" : %.6f, "
|
||||
"\"lon\" : %.6f",
|
||||
Modes.fUserLat, Modes.fUserLon); // exact location
|
||||
}
|
||||
}
|
||||
|
||||
p += sprintf(p, " }\n");
|
||||
|
|
Loading…
Reference in a new issue