Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
iCity
EnergyDashboard
Commits
01d1be71
Commit
01d1be71
authored
Jul 16, 2021
by
Sven Schneider
Browse files
added functionality to find the data for a specific date from the aggregated data array
parent
801165ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/js/aggregation.js
View file @
01d1be71
...
...
@@ -24,6 +24,49 @@ function convertArray2JSON(arr) {
}
/**
*
* @param {Array} array containing dates of type Date
* @param {Date} date date to look for in array
* @returns postition of the array where the date was matched
*/
export
const
whereIsDateInArray
=
function
(
array
,
date
)
{
const
DAY
=
date
.
getDate
();
const
MONTH
=
date
.
getMonth
();
var
pos
=
-
1
;
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
)
{
var
day
=
array
[
i
].
getDate
();
var
month
=
array
[
i
].
getMonth
();
if
(
day
===
DAY
&&
MONTH
===
month
)
{
pos
=
i
;
}
}
return
pos
;
}
/**
* Converts the date string from DD.MM.YYYY obtained from HTML date picker to -> MM.DD.YYYY
* @param {String} selctedDate containing a date string in the format DD.MM.YYYY
* @returns {String} of the provided date in the format MM.DD.YYYY
*/
export
const
switchDayMonth_inDate
=
function
(
selectedDate
)
{
var
splitedString
=
selectedDate
.
split
(
'
.
'
);
var
newDate
=
[];
newDate
.
push
(
splitedString
[
1
]);
newDate
.
push
(
splitedString
[
0
]);
newDate
.
push
(
splitedString
[
2
]);
return
newDate
.
join
(
'
.
'
);;
}
/**
* Format the response from SensorThings API to make it suitable for heatmap
* @param {Array} obsArray Response from SensorThings API as array
...
...
public/js/appCesium.js
View file @
01d1be71
...
...
@@ -3,6 +3,8 @@
// Functions
import
{
aggregateResponse
,
switchDayMonth_inDate
,
whereIsDateInArray
,
}
from
"
./aggregation.js
"
;
...
...
@@ -374,8 +376,21 @@ const activate3DTileFeaturePicking = function() {
drawHeatMapHC
(
formatSTAResponseForHeatMap
(
agg
.
originalFormat
));
drawLineChartHC
(
formatSTAResponseForLineChart
(
agg
.
originalFormat
));
console
.
log
(
ALLDATA
.
length
);
var
selectedDate
=
document
.
getElementById
(
"
DateSelected
"
).
value
;
console
.
log
(
selectedDate
);
var
selectedDate
=
document
.
getElementById
(
"
DateSelected
"
).
innerHTML
;
var
date
=
new
Date
(
Date
.
parse
(
switchDayMonth_inDate
(
selectedDate
)
)
);
var
p
=
whereIsDateInArray
(
ALLDATA
[
0
].
timestamp
,
date
);
if
(
p
==
-
1
)
console
.
log
(
'
date not found in date array
'
);
else
console
.
log
(
'
date found at position
'
+
p
);
console
.
log
(
date
);
// alert('waiting...');
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment