Bugfix: Use latitude and longitude instead of lat long

This commit is contained in:
Starbeamrainbowlabs 2019-07-10 14:32:58 +01:00
parent 70d29a9517
commit 1ee184d82d
4 changed files with 37 additions and 40 deletions

View File

@ -6,19 +6,18 @@ class GatewayRepo {
} }
add(...gateways) { add(...gateways) {
if(typeof this.query_insert == "undefined") const statement = this.db.prepare(`INSERT INTO gateways (
this.query_insert = this.db.prepare(`INSERT INTO gateways ( id,
id, latitude, longitude,
lat, long, altitude
altitude ) VALUES (
) VALUES ( :id,
:id, :latitude, :longitude,
:latitude, :longitude, :altitude
:altitude )`);
)`);
for(let gateway of gateways) for(let gateway of gateways)
this.insert_query.run(gateway); statement.run(gateway);
} }
/** /**

View File

@ -6,21 +6,20 @@ class RSSIRepo {
} }
add(...rssis) { add(...rssis) {
if(typeof this.query_insert == "undefined") const statement = this.db.prepare(`INSERT INTO rssis (
this.query_insert = this.db.prepare(`INSERT INTO rssis ( id,
id, reading_id, gateway_id,
reading_id, gateway_id, rssi, snr,
rssi, snr, channel
channel ) VALUES (
) VALUES ( :id,
:id, :reading_id, :gateway_id,
:reading_id, :gateway_id, :rssi, :snr,
:rssi, :snr, :channel
:channel )`);
)`);
for(let rssi of rssis) for(let rssi of rssis)
this.insert_query.run(rssi); statement.run(rssi);
} }
iterate() { iterate() {

View File

@ -7,19 +7,18 @@ class ReadingRepo {
} }
add(reading) { add(reading) {
if(typeof this.query_insert == "undefined") const statement = this.db.prepare(`INSERT INTO readings (
this.query_insert = this.db.prepare(`INSERT INTO readings ( id,
id, latitude, longitude,
lat, long, data_rate, code_rate
data_rate, code_rate ) VALUES (
) VALUES ( :id,
:id, :latitude,
:latitude, :longitude,
:longitude, :data_rate, :code_rate
:data_rate, :code_rate );`);
)`);
let new_id = this.insert_query.run(reading).lastInsertRowid; let new_id = statement.run(reading).lastInsertRowid;
// Attach the new id to the rssi objects // Attach the new id to the rssi objects
for(let rssi of reading.rssis) for(let rssi of reading.rssis)

View File

@ -1,8 +1,8 @@
-- See for data provided by TTN https://www.thethingsnetwork.org/docs/applications/mqtt/api.html -- See for data provided by TTN https://www.thethingsnetwork.org/docs/applications/mqtt/api.html
CREATE TABLE IF NOT EXISTS readings ( CREATE TABLE IF NOT EXISTS readings (
id INTEGER PRIMARY KEY, -- Random unique integer id INTEGER PRIMARY KEY, -- Random unique integer
lat FLOAT NOT NULL, -- Latitude component of GPS co-ordinates of reading latitude FLOAT NOT NULL, -- Latitude component of GPS co-ordinates of reading
long FLOAT NOT NULL, -- Longitude component of GPS co-ordinates of reading, longitude FLOAT NOT NULL, -- Longitude component of GPS co-ordinates of reading,
data_rate TEXT NOT NULL, -- The id of the data rate code in the data_rates table that describes the data rate at which the message was transmitted data_rate TEXT NOT NULL, -- The id of the data rate code in the data_rates table that describes the data rate at which the message was transmitted
code_rate TEXT -- The coding rate at which the message was transmitted. FUTURE: This may need to be an INTEGER field - not sure code_rate TEXT -- The coding rate at which the message was transmitted. FUTURE: This may need to be an INTEGER field - not sure
-- bit_rate INTEGER, -- The bit rate at which the message was transmitted -- We didn't actually recieve this - disparity between API docs & actual message -- bit_rate INTEGER, -- The bit rate at which the message was transmitted -- We didn't actually recieve this - disparity between API docs & actual message
@ -17,8 +17,8 @@ CREATE TABLE IF NOT EXISTS rssis (
); );
CREATE TABLE IF NOT EXISTS gateways ( CREATE TABLE IF NOT EXISTS gateways (
id TEXT PRIMARY KEY, -- The gateway's name id TEXT PRIMARY KEY, -- The gateway's name
lat FLOAT, -- Latitude component of the claimed GPS co-ordinates of the gateway latitude FLOAT, -- Latitude component of the claimed GPS co-ordinates of the gateway
long FLOAT, -- Longitude component of the claimed GPS co-ordinates of the gateway longitude FLOAT, -- Longitude component of the claimed GPS co-ordinates of the gateway
altitude FLOAT -- Claimed alitude of the gateway altitude FLOAT -- Claimed alitude of the gateway
); );