Bugfix: Use latitude and longitude instead of lat long
This commit is contained in:
parent
70d29a9517
commit
1ee184d82d
4 changed files with 37 additions and 40 deletions
|
@ -6,10 +6,9 @@ class GatewayRepo {
|
|||
}
|
||||
|
||||
add(...gateways) {
|
||||
if(typeof this.query_insert == "undefined")
|
||||
this.query_insert = this.db.prepare(`INSERT INTO gateways (
|
||||
const statement = this.db.prepare(`INSERT INTO gateways (
|
||||
id,
|
||||
lat, long,
|
||||
latitude, longitude,
|
||||
altitude
|
||||
) VALUES (
|
||||
:id,
|
||||
|
@ -18,7 +17,7 @@ class GatewayRepo {
|
|||
)`);
|
||||
|
||||
for(let gateway of gateways)
|
||||
this.insert_query.run(gateway);
|
||||
statement.run(gateway);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,8 +6,7 @@ class RSSIRepo {
|
|||
}
|
||||
|
||||
add(...rssis) {
|
||||
if(typeof this.query_insert == "undefined")
|
||||
this.query_insert = this.db.prepare(`INSERT INTO rssis (
|
||||
const statement = this.db.prepare(`INSERT INTO rssis (
|
||||
id,
|
||||
reading_id, gateway_id,
|
||||
rssi, snr,
|
||||
|
@ -20,7 +19,7 @@ class RSSIRepo {
|
|||
)`);
|
||||
|
||||
for(let rssi of rssis)
|
||||
this.insert_query.run(rssi);
|
||||
statement.run(rssi);
|
||||
}
|
||||
|
||||
iterate() {
|
||||
|
|
|
@ -7,19 +7,18 @@ class ReadingRepo {
|
|||
}
|
||||
|
||||
add(reading) {
|
||||
if(typeof this.query_insert == "undefined")
|
||||
this.query_insert = this.db.prepare(`INSERT INTO readings (
|
||||
const statement = this.db.prepare(`INSERT INTO readings (
|
||||
id,
|
||||
lat, long,
|
||||
latitude, longitude,
|
||||
data_rate, code_rate
|
||||
) VALUES (
|
||||
:id,
|
||||
:latitude,
|
||||
:longitude,
|
||||
: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
|
||||
for(let rssi of reading.rssis)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
-- See for data provided by TTN https://www.thethingsnetwork.org/docs/applications/mqtt/api.html
|
||||
CREATE TABLE IF NOT EXISTS readings (
|
||||
id INTEGER PRIMARY KEY, -- Random unique integer
|
||||
lat FLOAT NOT NULL, -- Latitude component of GPS co-ordinates of reading
|
||||
long FLOAT NOT NULL, -- Longitude component of GPS co-ordinates of reading,
|
||||
latitude FLOAT NOT NULL, -- Latitude 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
|
||||
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
|
||||
|
@ -17,8 +17,8 @@ CREATE TABLE IF NOT EXISTS rssis (
|
|||
);
|
||||
CREATE TABLE IF NOT EXISTS gateways (
|
||||
id TEXT PRIMARY KEY, -- The gateway's name
|
||||
lat 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
|
||||
latitude FLOAT, -- Latitude 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
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue