mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:27:09 +00:00
GIS raw: return “stalks” showing the positioning error
This commit is contained in:
@@ -35,30 +35,45 @@ async function points (projectId, options = {}) {
|
||||
options.limit || 5000
|
||||
];
|
||||
|
||||
// const text = `
|
||||
// SELECT ST_AsGeoJSON(t.*) geojson
|
||||
// FROM (
|
||||
// SELECT rl.line sailline, rs.line, point, sequence, objref, tstamp, ST_Transform(geometry, 4326) geometry
|
||||
// FROM raw_lines rl
|
||||
// INNER JOIN raw_shots rs USING (sequence)
|
||||
// WHERE
|
||||
// ($1 IS true
|
||||
// AND ST_Transform(geometry, 4326) && ST_MakeEnvelope($2, $3, $4, $5, 4326)
|
||||
// )
|
||||
// OR ($1 IS false AND true)
|
||||
// LIMIT $6
|
||||
// ) t
|
||||
// `;
|
||||
|
||||
const text = `
|
||||
SELECT json_build_object(
|
||||
'type', 'FeatureCollection',
|
||||
'features', json_agg(geojson::json)) geojson
|
||||
SELECT ST_AsGeoJSON(t.*, 'geometry') geojson, ST_AsGeoJSON(t.delta_geom) delta
|
||||
FROM (
|
||||
SELECT ST_AsGeoJSON(t.*) geojson
|
||||
FROM (
|
||||
SELECT rl.line sailline, rs.line, point, sequence, objref, tstamp, ST_Transform(geometry, 4326) geometry
|
||||
FROM raw_lines rl
|
||||
INNER JOIN raw_shots rs USING (sequence)
|
||||
WHERE
|
||||
($1 IS true
|
||||
AND ST_Transform(geometry, 4326) && ST_MakeEnvelope($2, $3, $4, $5, 4326)
|
||||
)
|
||||
OR ($1 IS false AND true)
|
||||
LIMIT $6
|
||||
) t
|
||||
) f;
|
||||
SELECT rl.line sailline, rs.line, rs.point, sequence, objref, tstamp, ST_Transform(rs.geometry, 4326) geometry,
|
||||
ST_Transform(ST_MakeLine(pp.geometry, rs.geometry), 4326) delta_geom
|
||||
FROM raw_lines rl
|
||||
INNER JOIN raw_shots rs USING (sequence)
|
||||
LEFT JOIN preplot_points pp ON rs.line = pp.line AND rs.point = pp.point
|
||||
WHERE
|
||||
($1 IS true
|
||||
AND ST_Transform(rs.geometry, 4326) && ST_MakeEnvelope($2, $3, $4, $5, 4326)
|
||||
)
|
||||
OR ($1 IS false AND true)
|
||||
LIMIT $6
|
||||
) t
|
||||
`;
|
||||
|
||||
const res = await pool.query(text, values);
|
||||
|
||||
if (res.rows && res.rows.length) {
|
||||
return res.rows[0].geojson;
|
||||
return res.rows.map(r => [
|
||||
JSON.parse(r.geojson),
|
||||
JSON.parse(r.delta)
|
||||
]).flat();
|
||||
} else {
|
||||
throw {status: 404};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user