Filter missing values out of JSON data for binary packing

This commit is contained in:
D. Berge
2025-08-08 12:15:39 +02:00
parent 695add5da6
commit 07874ffe0b

View File

@@ -4,11 +4,24 @@ const { sequence } = require('../../../../lib/db');
module.exports = async function (req, res, next) { module.exports = async function (req, res, next) {
try { try {
const json = await sequence.get(req.params.project, req.params.sequence, req.query); let json = await sequence.get(req.params.project, req.params.sequence, req.query);
const data = bundle(json, {type: req.query.type ?? 2}); const type = req.query.type ?? 2;
console.log("bundle", data); if (type == 2) {
// Filter out missing raw data
json = json.filter(el => el.geometryraw);
} else if (type == 3) {
// Filter out missing final data
json = json.filter(el => el.geometryfinal);
}
if (json.length) {
const data = bundle(json, {type});
console.log("bundle", data);
res.status(200).send(Buffer.from(data));
} else {
res.status(404).send();
}
res.status(200).send(Buffer.from(data));
next(); next();
} catch (err) { } catch (err) {
next(err); next(err);