Commit 37a474e1 authored by Patrick's avatar Patrick
Browse files

update server

parent d048ed10
......@@ -870,4 +870,62 @@ app.get('/TrafficFlow', async (req, res) => {
}
});
\ No newline at end of file
app.post('/getSTANoiseHist', async (req, res) => {
console.log('command angekommen ////// STANoise/////!')
const pointData = req.query;
// console.log(pointData);
try {
let origURL = 'http://193.196.138.56/frost-noise-api/v1.1/Datastreams(1)/Observations?$orderby=phenomenonTime%20asc'
let STALAeq = await STA_getApiResponse(origURL);
let STALAeqColl = [];
// let origURLmin = 'http://193.196.138.56/frost-noise-api/v1.1/Datastreams(2)/Observations?$orderby=phenomenonTime%20asc'
// let STALAeqmin = await STA_getApiResponse(origURLmin);
// let origURLmax = 'http://193.196.138.56/frost-noise-api/v1.1/Datastreams(3)/Observations?$orderby=phenomenonTime%20asc'
// let STALAeqmax = await STA_getApiResponse(origURLmax);
//eq
for (var i = 0; i<= STALAeq.value.length -1; i++){
var newNum = "noise";
var newVal = "LAeq";
STALAeq.value[i][newNum] = newVal;
STALAeqColl.push(STALAeq.value[i]);
}
do {
STALAeq = await STA_getApiResponse(STALAeq["@iot.nextLink"]);
for (var j = 0; j<= STALAeq.value.length -1; j++){
STALAeqColl.push(STALAeq.value[j]);
}
} while ("@iot.nextLink" in STALAeq);
console.log(STALAeqColl.length)
res.json(STALAeqColl);
}
catch (err) {
console.log('.../loadSetP failed!\n' + err);
}
});
function STA_getApiResponse(url) {
return new Promise(function (resolve, reject) {
// console.log(url)
axios.get(url)
.then(function (response) {
// handle success
// console.log(response.data);
resolve(response.data);
})
.catch(function (error) {
// handle error
// console.log(error);
reject(error);
});
});
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment