mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 07:57:07 +00:00
Filter missing values out of JSON data for binary packing
This commit is contained in:
@@ -4,11 +4,24 @@ 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 data = bundle(json, {type: req.query.type ?? 2});
|
||||
console.log("bundle", data);
|
||||
let json = await sequence.get(req.params.project, req.params.sequence, req.query);
|
||||
const type = req.query.type ?? 2;
|
||||
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();
|
||||
} catch (err) {
|
||||
next(err);
|
||||
|
||||
Reference in New Issue
Block a user