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) {
|
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,
|
||||||
lat, long,
|
latitude, longitude,
|
||||||
altitude
|
altitude
|
||||||
) VALUES (
|
) VALUES (
|
||||||
:id,
|
:id,
|
||||||
|
@ -18,7 +17,7 @@ class GatewayRepo {
|
||||||
)`);
|
)`);
|
||||||
|
|
||||||
for(let gateway of gateways)
|
for(let gateway of gateways)
|
||||||
this.insert_query.run(gateway);
|
statement.run(gateway);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,8 +6,7 @@ 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,
|
||||||
|
@ -20,7 +19,7 @@ class RSSIRepo {
|
||||||
)`);
|
)`);
|
||||||
|
|
||||||
for(let rssi of rssis)
|
for(let rssi of rssis)
|
||||||
this.insert_query.run(rssi);
|
statement.run(rssi);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterate() {
|
iterate() {
|
||||||
|
|
|
@ -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,
|
||||||
lat, long,
|
latitude, longitude,
|
||||||
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)
|
||||||
|
|
|
@ -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
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue