diff --git a/public/js/appCesium.js b/public/js/appCesium.js index 10d4e4ea200a73138b48bf4f5f8ed40586b7a91b..342c84998da5a00f60469d4060e22fa378a3effa 100644 --- a/public/js/appCesium.js +++ b/public/js/appCesium.js @@ -26,6 +26,8 @@ import { PARAM_SELECT, } from "./appChart.js"; +var ALLDATA = []; + Cesium.Ion.defaultAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyODgxYzJlNi1kNDZiLTQ3ZmQtYmUxYy0yMWI0OGM3NDA5MzAiLCJpZCI6NDczOSwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU0MTUyMzU0MX0.shj2hM3pvsvcmE_wMb2aBDuk_cKWmFmbolltInGImwU"; @@ -46,13 +48,13 @@ const viewer = new Cesium.Viewer("cesiumGlobeContainer", { * @param {String} urlTiles URL to the 3DTiles to be loaded * @returns {undefined} undefined */ -const loadTiles = function(urlTiles) { +const loadTiles = function (urlTiles) { const tileset = new Cesium.Cesium3DTileset({ url: urlTiles, }); viewer.scene.primitives.add(tileset); - tileset.readyPromise.then(function() { + tileset.readyPromise.then(function () { viewer .zoomTo( tileset, @@ -61,7 +63,7 @@ const loadTiles = function(urlTiles) { tileset.boundingSphere.radius / 0.5 ) ) - .otherwise(function(err) { + .otherwise(function (err) { throw err; }); }); @@ -72,7 +74,7 @@ const loadTiles = function(urlTiles) { * @param{*} * @returns {undefined} undefined */ -const loadNonDetailed = function() { +const loadNonDetailed = function () { // Paths to data sources const URL_3DTILES = "data_3d/3dtiles/1_full/tileset.json"; @@ -86,7 +88,7 @@ const loadNonDetailed = function() { * @param {String} gltfId Name of the glTF model file without the extension i.e. exclude the `.gltf` suffix * @returns {undefined} undefined */ -const gltfLoad = function(gltfUrl, gltfId) { +const gltfLoad = function (gltfUrl, gltfId) { const modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame( Cesium.Cartesian3.fromDegrees(9.083385, 48.881342, 0) ); @@ -106,7 +108,7 @@ const gltfLoad = function(gltfUrl, gltfId) { * @param{*} * @returns {undefined} undefined */ -const loadDetailed = function() { +const loadDetailed = function () { // Paths to data sources const URL_3DTILES = "data_3d/3dtiles/2_partial/tileset.json"; const URL_GLTF = "data_3d/gltf"; @@ -171,7 +173,7 @@ if (!LOAD_DETAILED_BLDG225) { * @param {*} * @returns {undefined} */ -const activate3DTileFeaturePicking = function() { +const activate3DTileFeaturePicking = function () { // HTML overlay for showing feature name on mouseover const nameOverlay = document.createElement("div"); viewer.container.appendChild(nameOverlay); @@ -308,46 +310,68 @@ const activate3DTileFeaturePicking = function() { ); const PARAM_FILTER = createTemporalFilterString("2020-01-01", "2021-01-01"); - const axiosGetRequest = axios.get(BASE_URL_OBSERVATIONS, { - params: { - "$resultFormat": PARAM_RESULT_FORMAT, - "$orderBy": PARAM_ORDER_BY, - "$filter": PARAM_FILTER, - "$select": PARAM_SELECT, - }, - }); - + // const axiosGetRequest = axios.get(BASE_URL_OBSERVATIONS, { + // params: { + // "$resultFormat": PARAM_RESULT_FORMAT, + // "$orderBy": PARAM_ORDER_BY, + // "$filter": PARAM_FILTER, + // "$select": PARAM_SELECT, + // }, + // }); + + const buildingIDs = [75, 76, 77, 78, 79, 80]; + // var ALLDATA = []; + + for (var bld = 0; bld < buildingIDs.length; bld++) { + + var baseUrlBld = getObservationsUrl(BASE_URL, buildingIDs[bld]); + const axiosGetRequest = axios.get(baseUrlBld, { + params: { + "$resultFormat": PARAM_RESULT_FORMAT, + "$orderBy": PARAM_ORDER_BY, + "$filter": PARAM_FILTER, + "$select": PARAM_SELECT, + }, + }); - // Get "ALL" the Observations that satisfy our query - followNextLink(axiosGetRequest) - .then((success) => { - const successValue = success.data.value; + // Get "ALL" the Observations that satisfy our query + followNextLink(axiosGetRequest) + .then((success) => { + const successValue = success.data.value; + + // Array that will hold the combined observations + const combinedObservations = []; + + successValue.forEach((dataObj) => { + // Each page of results will have a dataArray that holds the observations + const dataArrays = dataObj.dataArray; + + combinedObservations.push(...dataArrays); + }); + // DEBUG: Check total number of observations + console.log(combinedObservations.length); + // DEBUG: Print the array of observations + console.log(combinedObservations); + + return combinedObservations; + }) + .catch((err) => { + console.log("ERROR: ") + console.log(err); + }) + .then((observationArr) => { + var agg = aggregateResponse(observationArr, 0, 'mean'); + ALLDATA.push(agg); + // console.log(agg); + drawHeatMapHC(formatSTAResponseForHeatMap(agg)); + drawLineChartHC(formatSTAResponseForLineChart(agg)); + console.log(ALLDATA.length); + // alert('waiting...'); + }); - // Array that will hold the combined observations - const combinedObservations = []; - successValue.forEach((dataObj) => { - // Each page of results will have a dataArray that holds the observations - const dataArrays = dataObj.dataArray; - combinedObservations.push(...dataArrays); - }); - // DEBUG: Check total number of observations - console.log(combinedObservations.length); - // DEBUG: Print the array of observations - console.log(combinedObservations); - - return combinedObservations; - }) - .catch((err) => { - console.log(err); - }) - .then((observationArr) => { - var agg = aggregateResponse(observationArr, 0, 'mean'); - // console.log(agg); - drawHeatMapHC(formatSTAResponseForHeatMap(agg)); - drawLineChartHC(formatSTAResponseForLineChart(agg)); - }); + } }, Cesium.ScreenSpaceEventType.LEFT_CLICK);