-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
M3 calculations + some interactive updates
- Loading branch information
1 parent
720b591
commit 2c81ac6
Showing
9 changed files
with
533 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const DataPoint = require('../models/dataPoint'); | ||
|
||
const gasCalculations = { | ||
total(req, res) { | ||
DataPoint.aggregate([ | ||
{ | ||
$project: { | ||
Bag_Height: "$Bag_Height", | ||
} | ||
}, | ||
{ | ||
$match: { | ||
Bag_Height: { | ||
$lte: 240, | ||
$gte: 20 | ||
} | ||
} | ||
} | ||
], (err, results) => { | ||
totalData = { | ||
used: 0, | ||
generated: 0 | ||
} | ||
let last = 0; | ||
results.forEach(function(result) { | ||
totalGas = 2.82 * 2.34 * (result.Bag_Height / 100); | ||
if(last === 0) { | ||
last = totalGas; | ||
} else if(totalGas > last) { | ||
totalData.generated += totalGas - last; | ||
} else if(totalGas < last) { | ||
console.log(last - totalGas) | ||
totalData.used += last - totalGas; | ||
} | ||
last = totalGas; | ||
}) | ||
res.send(totalData) | ||
}) | ||
|
||
} | ||
} | ||
|
||
module.exports = gasCalculations; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,84 @@ | ||
/* ALL IMPORTANT CONFIG DATA | ||
------------------------------------------------ */ | ||
const config = { | ||
allMaps: [], | ||
actualMap: document.getElementsByTagName('map')[0], | ||
allAreas: false, | ||
areaCoords: [], | ||
vector: false, | ||
timer: false | ||
}; | ||
// /* ALL IMPORTANT CONFIG DATA | ||
// ------------------------------------------------ */ | ||
// const config = { | ||
// allMaps: [], | ||
// actualMap: document.getElementsByTagName('map')[0], | ||
// allAreas: null, | ||
// areaCoords: [], | ||
// vector: null, | ||
// }; | ||
// | ||
// /* RECALCULATION FUNCTIONALITY | ||
// ------------------------------------------------ */ | ||
// const RecalculateImageMap = { | ||
// init() { | ||
// /* AUTOMATICALLY UPDATE COORDINATES ON RESIZED WINDOW | ||
// ------------------------------------------------ */ | ||
// window.addEventListener('resize', ImageMapSetup.init); | ||
// if (!config.actualMap.newSize) { | ||
// RecalculateImageMap.start(); | ||
// } | ||
// }, | ||
// start() { | ||
// console.log(config.areaCoords.length) | ||
// if(config.areaCoords.length >= 3) { | ||
// console.log('fired') | ||
// config.areaCoords.splice(3,6) | ||
// } | ||
// config.allAreas = config.actualMap.getElementsByTagName('area'); | ||
// config.vector = document.getElementById('interactive_vector'); | ||
// /* ALL COORDINATES TO ARRAY | ||
// ------------------------------------------------ */ | ||
// for (let i = 0; i < config.allAreas.length; i++) { | ||
// const coords = config.allAreas[i].coords; | ||
// config.areaCoords.push(coords.replace(/ *, */g, ',').replace(/ +/g, ',')); | ||
// } | ||
// RecalculateImageMap.resize(); | ||
// }, | ||
// resize() { | ||
// /* FOR EACH AREA => RESIZE THE COORDINATES | ||
// ------------------------------------------------ */ | ||
// config.areaCoords.forEach(function(area, i) { | ||
// config.allAreas[i].coords = RecalculateImageMap.scale(area); | ||
// }); | ||
// }, | ||
// scale(area) { | ||
// const allValues = area.split(','); | ||
// /* CHECK FOR DIFFERENCE IN SCREENSIZE | ||
// ------------------------------------------------ */ | ||
// let totalScale = config.vector.width / config.vector.naturalWidth; | ||
// let newArea = []; | ||
// /* CHANGE EACH COORDINATE BASED ON THE NEW SCALE (DIFFERENCE SINCE LAST WIDTH) | ||
// ------------------------------------------------ */ | ||
// allValues.map(function(coordinate) { | ||
// let result = Math.round(Number(coordinate) * totalScale); | ||
// newArea.push(result); | ||
// }); | ||
// return newArea; | ||
// } | ||
// }; | ||
// | ||
// /* INITIALIZE RESIZING | ||
// ------------------------------------------------ */ | ||
// const ImageMapSetup = { | ||
// init() { | ||
// ImageMapSetup.start(config.actualMap); | ||
// }, | ||
// start(element) { | ||
// if (element) { | ||
// RecalculateImageMap.init(element); | ||
// config.allMaps.push(element); | ||
// } | ||
// } | ||
// }; | ||
// | ||
// ImageMapSetup.init(); | ||
|
||
/* RECALCULATION FUNCTIONALITY | ||
------------------------------------------------ */ | ||
const RecalculateImageMap = { | ||
init() { | ||
/* AUTOMATICALLY UPDATE COORDINATES ON RESIZED WINDOW | ||
------------------------------------------------ */ | ||
window.addEventListener('resize', ImageMapSetup.init); | ||
if (!config.actualMap.newSize) { | ||
RecalculateImageMap.start(); | ||
} | ||
}, | ||
start() { | ||
config.allAreas = config.actualMap.getElementsByTagName('area'); | ||
config.vector = document.getElementById('interactive_vector'); | ||
/* ALL COORDINATES TO ARRAY | ||
------------------------------------------------ */ | ||
for (let i = 0; i < config.allAreas.length; i++) { | ||
const coords = config.allAreas[i].coords; | ||
config.areaCoords.push(coords.replace(/ *, */g, ',').replace(/ +/g, ',')); | ||
} | ||
RecalculateImageMap.resize(); | ||
}, | ||
resize() { | ||
/* FOR EACH AREA => RESIZE THE COORDINATES | ||
------------------------------------------------ */ | ||
config.areaCoords.forEach(function(area, i) { | ||
config.allAreas[i].coords = RecalculateImageMap.scale(area); | ||
}); | ||
}, | ||
scale(area) { | ||
const allValues = area.split(','); | ||
/* CHECK FOR DIFFERENCE IN SCREENSIZE | ||
------------------------------------------------ */ | ||
let totalScale = config.vector.width / config.vector.naturalWidth; | ||
let newArea = []; | ||
/* CHANGE EACH COORDINATE BASED ON THE NEW SCALE (DIFFERENCE SINCE LAST WIDTH) | ||
------------------------------------------------ */ | ||
allValues.map(function(coordinate) { | ||
let result = Math.round(Number(coordinate) * totalScale); | ||
newArea.push(result); | ||
}); | ||
return newArea; | ||
} | ||
}; | ||
const tank_2 = document.getElementById('Tank2'); | ||
console.log(tank_2); | ||
|
||
/* INITIALIZE RESIZING | ||
------------------------------------------------ */ | ||
const ImageMapSetup = { | ||
init() { | ||
ImageMapSetup.start(config.actualMap); | ||
}, | ||
start(element) { | ||
if (element) { | ||
RecalculateImageMap.init(element); | ||
config.allMaps.push(element); | ||
} | ||
} | ||
}; | ||
tank_2.addEventListener("mouseover", showInfo) | ||
|
||
ImageMapSetup.init(); | ||
function showInfo() { | ||
console.log('hover'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.