Commit 60cb21f2 authored by Pithon Kabiro's avatar Pithon Kabiro
Browse files

New function: format observations for scatter plot

The function paramaters are two observation arrays which are responses
from a SensorThings API instance.

The logic of the function is based on the premise that the first input
observation array is the larger of the two.
parent aa583ae0
......@@ -792,6 +792,46 @@ const drawScatterPlotHC = function (
});
};
const formatSTAResponseForScatterPlot = function (obsArrayOne, obsArrayTwo) {
// Check if the arrays have the same length
// We want `obsArrayOne` to be the larger array
const [obsArrayOneChecked, obsArrayTwoChecked] = (() => {
if (obsArrayTwo.length > obsArrayOne.length) {
return [obsArrayTwo, obsArrayOne];
} else if (
obsArrayOne.length > obsArrayTwo.length ||
obsArrayOne.length === obsArrayTwo.length
) {
return [obsArrayOne, obsArrayTwo];
}
})();
console.log(obsArrayOneChecked.length);
console.log(obsArrayTwoChecked.length);
};
(async () => {
const sensorsOfInterestArr = [
// ["225", "vl", "60min"],
["125", "rl", "60min"],
["weather_station_521", "outside_temp", "60min"],
];
const observationsPlusMetadata =
await getMetadataPlusObservationsFromMultipleDatastreams(
sensorsOfInterestArr
);
// Extract the observations and metadata for each sensor
// Array elements in same order as input array
const [
[obsSensorOneArr, obsSensorTwoArr],
[metadataSensorOne, metadataSensorTwo],
] = observationsPlusMetadata;
formatSTAResponseForScatterPlot(obsSensorOneArr, obsSensorTwoArr);
})();
/**
* Test drawing of scatter plot chart
*/
......@@ -823,7 +863,7 @@ const drawScatterPlotHCTest = async function () {
};
(async () => {
await drawScatterPlotHCTest();
// await drawScatterPlotHCTest();
})();
export {
......
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