const { bundle } = require('../../../../lib/binary');
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 data = bundle(json, {type: req.query.type ?? 0});
		console.log("bundle", data);

		res.status(200).send(Buffer.from(data));
		next();
	} catch (err) {
		next(err);
	}

};
