From 126f2bdac2d6ec6dff586fc5f027c5627ac116b6 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Wed, 31 Jul 2019 15:11:40 +0100 Subject: [PATCH] Add geojson-debug build task --- build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build b/build index 28bfd18..7acd16f 100755 --- a/build +++ b/build @@ -41,6 +41,7 @@ if [[ "$#" -lt 1 ]]; then echo -e " ${CACTION}client-watch${RS} - Auto-rebuild the client-side code on modification."; echo -e " ${CACTION}dev-server${RS} - Start the development web server for the web interface."; echo -e " ${CACTION}dev-server-stop${RS} - Stop the development web server."; + echo -e " ${CACTION}geojson-debug${RS} - Generate some GeoJSON from the raw readings for debugging purposes (paste into geojson.io)"; echo -e ""; exit 1; @@ -200,6 +201,9 @@ task_dev-server-stop() { task_end $?; } +task_geojson() { + sqlite3 lorawan.sqlite 'SELECT readings.latitude, readings.longitude, rssis.rssi FROM readings LEFT JOIN rssis ON readings.id = rssis.reading_id ORDER BY readings.latitude,readings.longitude;' | perl -pe 'chomp if eof' | jq --raw-input --slurp 'split("\n") | map(split("|") | map(if . == "" then null else tonumber end)) | map({type: "Feature", geometry: { type: "Point", "coordinates": [ .[1], .[0] ] }, properties: { "rssi": .[2], "marker-color": (if .[2] == null then "#dd0707" else "#04a104" end), "marker-symbol": "circle" }}) | { type: "FeatureCollection", features: . }' +} ###############################################################################