Commit fc9e6f80 authored by Pithon Kabiro's avatar Pithon Kabiro
Browse files

New function: highlight selected buildings

Wraps logic of applying styling to selected buildings plus removing
duplicate building IDs
parent ca0d8d3a
...@@ -52,7 +52,7 @@ const loadTiles = function (buildingTileset) { ...@@ -52,7 +52,7 @@ const loadTiles = function (buildingTileset) {
buildingTileset.readyPromise.then(function () { buildingTileset.readyPromise.then(function () {
viewer viewer
.zoomTo( .zoomTo(
tileset, buildingTileset,
new Cesium.HeadingPitchRange( new Cesium.HeadingPitchRange(
0.0, 0.0,
-0.5, -0.5,
...@@ -344,3 +344,32 @@ const applyStylingForSelectedBuildings = function ( ...@@ -344,3 +344,32 @@ const applyStylingForSelectedBuildings = function (
}, },
}); });
}; };
/**
* Highlight the building(s) that are selected in the buildings & data points drop-down list
*
* @param {Array} selectedBldgsDataPntsSmplngRateAbbrevNestedArr An array which contains one or more nested arrays of abbreviations of building(s), data point(s) and sampling rate(s)
* @returns {undefined} undefined
*/
const highlightSelectedBuildings = function (
selectedBldgsDataPntsSmplngRateAbbrevNestedArr
) {
// The building ID is the first element
const buildingIdArr = selectedBldgsDataPntsSmplngRateAbbrevNestedArr.map(
(bldgDataPtSmplngRateAbbrev) => bldgDataPtSmplngRateAbbrev[0]
);
// Use a set to remove duplicates
const uniqueBuildingIdArr = [...new Set(buildingIdArr)];
applyStylingForSelectedBuildings(
nonDetailedBuilding225Tileset,
uniqueBuildingIdArr
);
};
export {
nonDetailedBuilding225Tileset,
resetStylingForAllBuildings,
highlightSelectedBuildings,
};
...@@ -51,6 +51,12 @@ import { drawLineChartBasedOnSelectedOptions } from "./src_modules/dropDownListC ...@@ -51,6 +51,12 @@ import { drawLineChartBasedOnSelectedOptions } from "./src_modules/dropDownListC
import { drawScatterPlotBasedOnSelectedOptions } from "./src_modules/dropDownListChartScatterPlot.mjs"; import { drawScatterPlotBasedOnSelectedOptions } from "./src_modules/dropDownListChartScatterPlot.mjs";
import {
nonDetailedBuilding225Tileset,
resetStylingForAllBuildings,
highlightSelectedBuildings,
} from "./appCesium.js";
/** /**
* Callback function that wraps the logic of populating the linked drop down lists. * Callback function that wraps the logic of populating the linked drop down lists.
* Will run on `DOMContentLoaded` event * Will run on `DOMContentLoaded` event
...@@ -71,6 +77,9 @@ const afterDocumentLoads = function () { ...@@ -71,6 +77,9 @@ const afterDocumentLoads = function () {
*/ */
const drawChartUsingSelectedOptions = async function () { const drawChartUsingSelectedOptions = async function () {
try { try {
// Reset the styling of the 3D tileset, in case building(s) were highlighted
resetStylingForAllBuildings(nonDetailedBuilding225Tileset);
// Note: The chart type amd aggregation type + duration are the first and // Note: The chart type amd aggregation type + duration are the first and
// third elements respectively, we have ignored the second and fourth elements // third elements respectively, we have ignored the second and fourth elements
const [selectedChartTypeArr, , selectedAggregationTypeDurationArr] = const [selectedChartTypeArr, , selectedAggregationTypeDurationArr] =
...@@ -95,6 +104,11 @@ const drawChartUsingSelectedOptions = async function () { ...@@ -95,6 +104,11 @@ const drawChartUsingSelectedOptions = async function () {
const [[, , selectedSamplingRateAbbrev]] = const [[, , selectedSamplingRateAbbrev]] =
selectedBuildingsDataPointsSamplingRateAbbrevNestedArr; selectedBuildingsDataPointsSamplingRateAbbrevNestedArr;
// Highlight the selected buildings
highlightSelectedBuildings(
selectedBuildingsDataPointsSamplingRateAbbrevNestedArr
);
// User-specified start date and end date for aggregation - used by MULTIPLE chart types // User-specified start date and end date for aggregation - used by MULTIPLE chart types
const AGGREGATION_START_DATE = "2020-01-01"; const AGGREGATION_START_DATE = "2020-01-01";
const AGGREGATION_STOP_DATE = "2020-12-31"; const AGGREGATION_STOP_DATE = "2020-12-31";
......
Markdown is supported
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