mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 13:07:08 +00:00
GIS final: return multiple features.
Rather than a single massive FeatureCollection.
This commit is contained in:
@@ -35,29 +35,24 @@ async function points (projectId, options = {}) {
|
||||
];
|
||||
|
||||
const text = `
|
||||
SELECT json_build_object(
|
||||
'type', 'FeatureCollection',
|
||||
'features', json_agg(geojson::json)) geojson
|
||||
SELECT ST_AsGeoJSON(t.*) geojson
|
||||
FROM (
|
||||
SELECT ST_AsGeoJSON(t.*) geojson
|
||||
FROM (
|
||||
SELECT fl.line sailline, fs.line, point, sequence, objref, tstamp, ST_Transform(geometry, 4326) geometry
|
||||
FROM final_lines fl
|
||||
INNER JOIN final_shots fs 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 fl.line sailline, fs.line, point, sequence, objref, tstamp, ST_Transform(geometry, 4326) geometry
|
||||
FROM final_lines fl
|
||||
INNER JOIN final_shots fs 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 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));
|
||||
} else {
|
||||
throw {status: 404};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user