Files
dougal-software/lib/www/server/api/middleware/sequence/point/get/geojson.js
D. Berge 920ea83ece Add API endpoint to retrieve a single shotpoint.
This will be used by the new event dialogue in the
frontend to get shotpoint information when creating
or editing events.
2022-02-27 19:56:21 +01:00

29 lines
522 B
JavaScript

const { sequence } = require('../../../../../lib/db');
module.exports = async function (req, res, next) {
try {
const feature = await sequence.point.get(req.params.project, req.params.sequence, req.params.point, req.query);
if (feature) {
const geojson = {
type: "Feature",
geometry: feature.geometry,
properties: {...feature}
};
delete geojson.properties.geometry;
res.status(200).send(geojson);
} else {
res.status(404).send();
}
next();
} catch (err) {
next(err);
}
};