Commit 23c0d905 authored by Sven Schneider's avatar Sven Schneider
Browse files

trying to change process of adding more data to list. Updated date picker

parent 9c7ea6b4
...@@ -73,10 +73,10 @@ ...@@ -73,10 +73,10 @@
</div> </div>
<form id="DatePicker"> <form id="DatePicker">
<label>Select Date:</label> <label>Select Date:</label>
<input type="date" id="DateOfInterest" name="DateOfInterest" min="2020-01-01" max="2020-12-31"> <input type="date" id="DateOfInterest" name="DateOfInterest" min="2020-01-01" max="2020-12-31" onchange='DateConvert();'>
<input type="submit" value="Submit"> <!-- <input type="submit" value="Submit"> -->
</form> </form>
<p>Date selected: <span id="DateSelected"></span> </p> <p>Date selected: <span id="DateSelected">01.01.2020</span> </p>
</div> </div>
</nav> </nav>
</div> </div>
...@@ -139,14 +139,33 @@ ...@@ -139,14 +139,33 @@
</div> </div>
</div> </div>
<script> <script>
document.getElementById('DatePicker').onsubmit = function() { // document.getElementById('DatePicker').onsubmit = function() {
var dateSelected = document.getElementById('DateOfInterest').value; // var dateSelected = document.getElementById('DateOfInterest').value;
var asDateType = new Date(dateSelected) // var asDateType = new Date(dateSelected)
console.log(typeof(dateSelected)); // console.log(typeof(dateSelected));
document.getElementById('DateSelected').innerHTML = dateSelected; // document.getElementById('DateSelected').innerHTML = dateSelected;
return false; // return false;
}; // };
function DateConvert() {
var MyDate = document.getElementById("DateOfInterest").value;
//Need to take Raw Date into the moment function or it will be subject to Javascript Date Shifting
//Note no time stamp on this one.
//Make New Date Object
MyDate = new Date(MyDate);
//Convert OldSchool
ConvertMyDate(MyDate);
}
function ConvertMyDate(MyDate) {
MyDate = new Date(MyDate);
var Year = String(MyDate.getFullYear());
var Month = ("0" + (String(MyDate.getMonth() + 1))).slice(-2);
var Day = ("0" + (String(MyDate.getDate() + 0))).slice(-2);
MyDate = Day + "." + Month + "." + Year;
document.getElementById("DateSelected").innerHTML = MyDate;
}
</script> </script>
</body> </body>
......
/** /**
* *
* @param {JSON} obj JSON object on which to replace a specific key. * @param {JSON} obj JSON object on which to replace a specific key.
...@@ -7,7 +6,7 @@ ...@@ -7,7 +6,7 @@
* usage: myjson.forEach((obj) => renameKey(obj, "oldkey", "newkey")); * usage: myjson.forEach((obj) => renameKey(obj, "oldkey", "newkey"));
*/ */
function renameKey(obj, oldKey, newKey) { function renameKey(obj, oldKey, newKey) {
obj[newKey] = obj[oldKey]; obj[newKey] = obj[oldKey];
delete obj[oldKey]; delete obj[oldKey];
} }
...@@ -96,7 +95,7 @@ export const aggregateResponse = function(obsArray, hours, method) { ...@@ -96,7 +95,7 @@ export const aggregateResponse = function(obsArray, hours, method) {
aggregatedVals.push(vals.reduce(function(a, b) { return Math.max(a, b); })); aggregatedVals.push(vals.reduce(function(a, b) { return Math.max(a, b); }));
break; break;
default: default:
aggregatedVals.push(vals.reduce(function(a, b) { return a + b / vals.length; },-1)); aggregatedVals.push(vals.reduce(function(a, b) { return a + b / vals.length; }, -1));
} }
vals = []; // clear the daily value vector vals = []; // clear the daily value vector
vals.push(jsonData[d].temperature); // now push first entry of new day into my temp value vector. vals.push(jsonData[d].temperature); // now push first entry of new day into my temp value vector.
...@@ -142,7 +141,7 @@ export const aggregateResponse = function(obsArray, hours, method) { ...@@ -142,7 +141,7 @@ export const aggregateResponse = function(obsArray, hours, method) {
aggregatedVals.push(vals.reduce(function(a, b) { return Math.max(a, b); }, )); aggregatedVals.push(vals.reduce(function(a, b) { return Math.max(a, b); }, ));
break; break;
default: default:
aggregatedVals.push(vals.reduce(function(a, b) { return a + b / vals.length; },-1)); aggregatedVals.push(vals.reduce(function(a, b) { return a + b / vals.length; }, -1));
} }
vals = []; // clear the daily value vector vals = []; // clear the daily value vector
vals.push(jsonData[d].temperature); // now push first entry of new day into my temp value vector. vals.push(jsonData[d].temperature); // now push first entry of new day into my temp value vector.
...@@ -158,8 +157,10 @@ export const aggregateResponse = function(obsArray, hours, method) { ...@@ -158,8 +157,10 @@ export const aggregateResponse = function(obsArray, hours, method) {
} // end else } // end else
// return newOutput;
return {
originalFormat: newOutput,
return newOutput; aggDates: aggDates,
aggVals: aggregatedVals
};
} }
\ No newline at end of file
...@@ -48,13 +48,13 @@ const viewer = new Cesium.Viewer("cesiumGlobeContainer", { ...@@ -48,13 +48,13 @@ const viewer = new Cesium.Viewer("cesiumGlobeContainer", {
* @param {String} urlTiles URL to the 3DTiles to be loaded * @param {String} urlTiles URL to the 3DTiles to be loaded
* @returns {undefined} undefined * @returns {undefined} undefined
*/ */
const loadTiles = function (urlTiles) { const loadTiles = function(urlTiles) {
const tileset = new Cesium.Cesium3DTileset({ const tileset = new Cesium.Cesium3DTileset({
url: urlTiles, url: urlTiles,
}); });
viewer.scene.primitives.add(tileset); viewer.scene.primitives.add(tileset);
tileset.readyPromise.then(function () { tileset.readyPromise.then(function() {
viewer viewer
.zoomTo( .zoomTo(
tileset, tileset,
...@@ -63,7 +63,7 @@ const loadTiles = function (urlTiles) { ...@@ -63,7 +63,7 @@ const loadTiles = function (urlTiles) {
tileset.boundingSphere.radius / 0.5 tileset.boundingSphere.radius / 0.5
) )
) )
.otherwise(function (err) { .otherwise(function(err) {
throw err; throw err;
}); });
}); });
...@@ -74,7 +74,7 @@ const loadTiles = function (urlTiles) { ...@@ -74,7 +74,7 @@ const loadTiles = function (urlTiles) {
* @param{*} * @param{*}
* @returns {undefined} undefined * @returns {undefined} undefined
*/ */
const loadNonDetailed = function () { const loadNonDetailed = function() {
// Paths to data sources // Paths to data sources
const URL_3DTILES = "data_3d/3dtiles/1_full/tileset.json"; const URL_3DTILES = "data_3d/3dtiles/1_full/tileset.json";
...@@ -88,7 +88,7 @@ const loadNonDetailed = function () { ...@@ -88,7 +88,7 @@ const loadNonDetailed = function () {
* @param {String} gltfId Name of the glTF model file without the extension i.e. exclude the `.gltf` suffix * @param {String} gltfId Name of the glTF model file without the extension i.e. exclude the `.gltf` suffix
* @returns {undefined} undefined * @returns {undefined} undefined
*/ */
const gltfLoad = function (gltfUrl, gltfId) { const gltfLoad = function(gltfUrl, gltfId) {
const modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame( const modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
Cesium.Cartesian3.fromDegrees(9.083385, 48.881342, 0) Cesium.Cartesian3.fromDegrees(9.083385, 48.881342, 0)
); );
...@@ -108,7 +108,7 @@ const gltfLoad = function (gltfUrl, gltfId) { ...@@ -108,7 +108,7 @@ const gltfLoad = function (gltfUrl, gltfId) {
* @param{*} * @param{*}
* @returns {undefined} undefined * @returns {undefined} undefined
*/ */
const loadDetailed = function () { const loadDetailed = function() {
// Paths to data sources // Paths to data sources
const URL_3DTILES = "data_3d/3dtiles/2_partial/tileset.json"; const URL_3DTILES = "data_3d/3dtiles/2_partial/tileset.json";
const URL_GLTF = "data_3d/gltf"; const URL_GLTF = "data_3d/gltf";
...@@ -173,7 +173,7 @@ if (!LOAD_DETAILED_BLDG225) { ...@@ -173,7 +173,7 @@ if (!LOAD_DETAILED_BLDG225) {
* @param {*} * @param {*}
* @returns {undefined} * @returns {undefined}
*/ */
const activate3DTileFeaturePicking = function () { const activate3DTileFeaturePicking = function() {
// HTML overlay for showing feature name on mouseover // HTML overlay for showing feature name on mouseover
const nameOverlay = document.createElement("div"); const nameOverlay = document.createElement("div");
viewer.container.appendChild(nameOverlay); viewer.container.appendChild(nameOverlay);
...@@ -319,12 +319,14 @@ const activate3DTileFeaturePicking = function () { ...@@ -319,12 +319,14 @@ const activate3DTileFeaturePicking = function () {
// }, // },
// }); // });
const buildingIDs = [75, 76, 77, 78, 79, 80]; const BUILDING_STREAM_ID = [75, 76, 77, 78, 79, 80];
// var ALLDATA = []; const BUILDING_ID = ["101", "102", "107", "112, 118", "125", "225"];
// ALLDATA = [];
var bld = 0;
for (var bld = 0; bld < buildingIDs.length; bld++) { for (bld = 0; bld < BUILDING_STREAM_ID.length; bld++) {
var baseUrlBld = getObservationsUrl(BASE_URL, buildingIDs[bld]); var baseUrlBld = getObservationsUrl(BASE_URL, BUILDING_STREAM_ID[bld]);
const axiosGetRequest = axios.get(baseUrlBld, { const axiosGetRequest = axios.get(baseUrlBld, {
params: { params: {
"$resultFormat": PARAM_RESULT_FORMAT, "$resultFormat": PARAM_RESULT_FORMAT,
...@@ -361,11 +363,20 @@ const activate3DTileFeaturePicking = function () { ...@@ -361,11 +363,20 @@ const activate3DTileFeaturePicking = function () {
}) })
.then((observationArr) => { .then((observationArr) => {
var agg = aggregateResponse(observationArr, 0, 'mean'); var agg = aggregateResponse(observationArr, 0, 'mean');
ALLDATA.push(agg); var tmpObj = {
id: BUILDING_ID[bld],
streamID: BUILDING_STREAM_ID[bld],
timestamp: agg.aggDates,
data: agg.aggVals,
};
ALLDATA.push(tmpObj);
// console.log(agg); // console.log(agg);
drawHeatMapHC(formatSTAResponseForHeatMap(agg)); drawHeatMapHC(formatSTAResponseForHeatMap(agg.originalFormat));
drawLineChartHC(formatSTAResponseForLineChart(agg)); drawLineChartHC(formatSTAResponseForLineChart(agg.originalFormat));
console.log(ALLDATA.length); console.log(ALLDATA.length);
var selectedDate = document.getElementById("DateSelected").value;
console.log(selectedDate);
// alert('waiting...'); // alert('waiting...');
}); });
......
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