mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:37:08 +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) {
|
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));
|
res.status(200).send(Buffer.from(data));
|
||||||
|
} else {
|
||||||
|
res.status(404).send();
|
||||||
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
next(err);
|
next(err);
|
||||||
|
|||||||
Reference in New Issue
Block a user