Implement sequence/get API endpoint.

It returns data for all individual points in a sequence.
This commit is contained in:
D. Berge
2021-09-04 18:04:52 +02:00
parent 8d3b7adc78
commit 45fe467a21
7 changed files with 194 additions and 127 deletions

View File

@@ -0,0 +1,28 @@
const { sequence } = require('../../../../lib/db');
module.exports = async function (req, res, next) {
try {
const json = await sequence.get(req.params.project, req.params.sequence, req.query);
const geometry = req.query.geometry || "geometrypreplot";
const geojson = {
type: "FeatureCollection",
features: json.map(feature => {
return {
type: "Feature",
geometry: feature[geometry],
properties: {...feature}
}
})
};
res.status(200).send(geojson);
next();
} catch (err) {
next(err);
}
};