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) {
if(typeof this.query_insert == "undefined")
this.query_insert = this.db.prepare(`INSERT INTO gateways (
id,
lat, long,
altitude
) VALUES (
:id,
:latitude, :longitude,
:altitude
)`);
const statement = this.db.prepare(`INSERT INTO gateways (
id,
latitude, longitude,
altitude
) VALUES (
:id,
:latitude, :longitude,
:altitude
)`);
for(let gateway of gateways)
this.insert_query.run(gateway);
statement.run(gateway);
}
/**

View file

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

View file

@ -7,19 +7,18 @@ class ReadingRepo {
}
add(reading) {
if(typeof this.query_insert == "undefined")
this.query_insert = this.db.prepare(`INSERT INTO readings (
id,
lat, long,
data_rate, code_rate
) VALUES (
:id,
:latitude,
:longitude,
:data_rate, :code_rate
)`);
const statement = this.db.prepare(`INSERT INTO readings (
id,
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)

View file

@ -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
);