
const { line } = require('../../../../lib/db');

module.exports = async function (req, res, next) {

	try {
		const json = await line.get(req.params.project, req.params.class, req.params.line, {wgs84: true, ...req.query});

		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);
	}


};
