mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 08:37:07 +00:00
Adapt RTI save function to refactored project configuration in DB
This commit is contained in:
@@ -8,14 +8,10 @@ let last_tstamp = 0;
|
|||||||
async function getAllProjectConfigs () {
|
async function getAllProjectConfigs () {
|
||||||
const client = await pool.connect();
|
const client = await pool.connect();
|
||||||
|
|
||||||
const res0 = await client.query("SELECT schema FROM projects;");
|
const text = `SELECT schema, meta AS data FROM projects;`;
|
||||||
const text = res0.rows.map(r => {
|
const res = await client.query(text);
|
||||||
return `SELECT '${r.schema}' AS schema, data FROM ${r.schema}.file_data WHERE (data->>'archived')::boolean IS NOT true AND data->>'id' IS NOT NULL`;
|
|
||||||
}).join("\nUNION ALL ");
|
|
||||||
|
|
||||||
const res1 = await client.query(text);
|
|
||||||
client.release();
|
client.release();
|
||||||
return res1.rows.map(r => Object.assign(r.data, {schema: r.schema}));
|
return res.rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getNearestPreplot (candidates) {
|
async function getNearestPreplot (candidates) {
|
||||||
@@ -141,14 +137,14 @@ async function saveOnline (dataset, opts = {}) {
|
|||||||
await client.query(`
|
await client.query(`
|
||||||
INSERT INTO raw_shots
|
INSERT INTO raw_shots
|
||||||
(sequence, line, point, objref, tstamp, geometry, hash)
|
(sequence, line, point, objref, tstamp, geometry, hash)
|
||||||
VALUES ($1, $2, $3, $4, $5, ST_SetSRID(ST_MakePoint($6, $7), (SELECT (data->>'epsg')::integer AS epsg FROM file_data WHERE data ? 'id')), '*online*')
|
VALUES ($1, $2, $3, $4, $5, ST_SetSRID(ST_MakePoint($6, $7), (select (project_configuration()->>'epsg')::integer as epsg)), '*online*')
|
||||||
ON CONFLICT DO NOTHING;
|
ON CONFLICT DO NOTHING;
|
||||||
`, [item.sequence, item.line, item.point, 0, item.tstamp, item.easting, item.northing]);
|
`, [item.sequence, item.line, item.point, 0, item.tstamp, item.easting, item.northing]);
|
||||||
} else if (item.latitude && item.longitude) {
|
} else if (item.latitude && item.longitude) {
|
||||||
await client.query(`
|
await client.query(`
|
||||||
INSERT INTO raw_shots
|
INSERT INTO raw_shots
|
||||||
(sequence, line, point, objref, tstamp, geometry, hash)
|
(sequence, line, point, objref, tstamp, geometry, hash)
|
||||||
VALUES ($1, $2, $3, $4, $5, ST_Transform(ST_SetSRID(ST_MakePoint($6, $7), 4326), (SELECT (data->>'epsg')::integer AS epsg FROM file_data WHERE data ? 'id')), '*online*')
|
VALUES ($1, $2, $3, $4, $5, ST_Transform(ST_SetSRID(ST_MakePoint($6, $7), 4326), (select (project_configuration()->>'epsg')::integer as epsg)), '*online*')
|
||||||
ON CONFLICT DO NOTHING;
|
ON CONFLICT DO NOTHING;
|
||||||
`, [item.sequence, item.line, item.point, 0, item.tstamp, item.longitude, item.latitude]);
|
`, [item.sequence, item.line, item.point, 0, item.tstamp, item.longitude, item.latitude]);
|
||||||
} else {
|
} else {
|
||||||
@@ -186,7 +182,7 @@ async function saveOffline (navData, opts = {}) {
|
|||||||
} else if (schema && hasEastNorth) {
|
} else if (schema && hasEastNorth) {
|
||||||
const text = `
|
const text = `
|
||||||
INSERT INTO real_time_inputs (tstamp, geometry, meta)
|
INSERT INTO real_time_inputs (tstamp, geometry, meta)
|
||||||
VALUES ($1, ST_Transform(ST_SetSRID(ST_MakePoint($2, $3), (SELECT (data->>'epsg')::integer AS epsg FROM ${schema}.file_data)), 4326), $4);
|
VALUES ($1, ST_Transform(ST_SetSRID(ST_MakePoint($2, $3), (select (project_configuration()->>'epsg')::integer as epsg), 4326), $4);
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const values = [navData.tstamp, navData.longitude, navData.latitude, navData.payload];
|
const values = [navData.tstamp, navData.longitude, navData.latitude, navData.payload];
|
||||||
|
|||||||
Reference in New Issue
Block a user