-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprocessor.js
More file actions
62 lines (50 loc) · 1.67 KB
/
Copy pathprocessor.js
File metadata and controls
62 lines (50 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// processor.js
const redisclient = require('./redis-client');
let tools = require('./3Dprocessor/tools');
module.exports = async function (job) {
// Do some heavy work
const synthesisid = job.data.synthesisid;
// let existingroads = job.data.rfc;
let constraintedDesigns = job.data.gj;
const systems = job.data.sys;
// if (existingroads.features.length > 0) {
// existingroads = tools.bufferExistingRoads(existingroads);
// }
let curFeats = constraintedDesigns.features;
let flen = curFeats.length;
let fullproc = flen;
let counter = 0;
let finalGJFeats = [];
for (let h = 0; h < flen; h++) {
let cur3DGeom = [];
// for every feature , create a point grid.
let curFeat = curFeats[h];
try {
cur3DGeom = tools.generateFinal3DGeoms(curFeat, 0);
} catch (error) {
}
if (cur3DGeom) {
finalGJFeats.push.apply(finalGJFeats, cur3DGeom);
}
counter += 1;
job.progress({
'percent': parseInt((100 * counter) / fullproc),
'synthesisid': synthesisid
});
}
let final3DGeoms = {
"type": "FeatureCollection",
"features": finalGJFeats
};
// const final3DGeoms = tools.generateFinal3DGeoms(constraintedDesigns, 1, existingroads);
// job.progress(50);
let center = tools.generateCenter(constraintedDesigns);
// console.log(center, unitCounts);
// job.progress(100);
console.log('Computation Complete..');
redisclient.set(synthesisid, JSON.stringify({
"finalGeoms": final3DGeoms,
"center": center
}));
return Promise.resolve(synthesisid);
}