diff --git a/Dev-Notes.md b/Dev-Notes.md index bfe6a84..7c7e8e0 100644 --- a/Dev-Notes.md +++ b/Dev-Notes.md @@ -1,11 +1,12 @@ ## 20240117 -Example SQL query to create a `qgis_friendly` view that converts Cayenne GPS location into PostGIS point, includes RSSI, time, and gatewayId, and filters on gatewayId: +Example SQL query to create a `qgis_friendly` view that converts Cayenne GPS location into PostGIS point, includes unique ID, RSSI, time, and gatewayId, and filters on gatewayId: ```sql CREATE OR REPLACE VIEW qgis_friendly AS -WITH data(gatewayId, time, alt, lat, lon, rssi) AS +WITH data(id, gatewayId, time, alt, lat, lon, rssi) AS (SELECT + deduplication_id, rx_info -> 0 ->> 'gatewayId', time, CAST (object -> 'gpsLocation' -> '1' ->> 'altitude' AS FLOAT), @@ -13,7 +14,8 @@ WITH data(gatewayId, time, alt, lat, lon, rssi) AS CAST (object -> 'gpsLocation' -> '1' ->> 'longitude' AS FLOAT), CAST (rx_info -> 0 ->> 'rssi' AS INTEGER) FROM event_up) -SELECT +SELECT + id, gatewayId, time, ST_SetSRID(ST_MakePoint(lon, lat, alt), 4326) AS location,