diff --git a/ipmd/static/ipmd/js/ipmdlib.js b/ipmd/static/ipmd/js/ipmdlib.js
index 56415cf8398a4fb85e4c17b4b6c4be9c6b8dd017..cab3b064937d27a55ba9693d28158d60577a02c9 100644
--- a/ipmd/static/ipmd/js/ipmdlib.js
+++ b/ipmd/static/ipmd/js/ipmdlib.js
@@ -190,6 +190,34 @@ function getPragmaticWeatherParameterList(requestedParameters, availableParamete
}
+/**
+ * Displays the weather data in a table
+ * @param {Object} weatherData the weatherData in IPM Decisions format
+ * @param {HTMLElement} container the element to render to
+ * @param {String} tableClass for styling the table, e.g. using Bootstrap
+ */
+ function renderWeatherData(weatherData, container, tableClass){
+ let dates = getDateArray(weatherData.timeStart, weatherData.interval, weatherData.locationWeatherData[0].length);
+ let html = "<table" + (tableClass != undefined ? " class=\"" + tableClass + "\"" : "") + "><thead><tr><th>Time</th>";
+ weatherData.weatherParameters.forEach(function(weatherParameterId){
+ html +="<th>" + getWeatherParameter(weatherParameterId).name + "</th>";
+ });
+
+ html += "</tr></thead>"
+ html += "<tbody>";
+ //console.info("Weatherdata length: " + weatherData.locationWeatherData[0].data.length);
+ for(let i=0;i< weatherData.locationWeatherData[0].data.length;i++)
+ {
+ html += "<tr><td>" + moment(dates[i]).format("YYYY-MM-DD HH:mm:ss") + "</td>";
+ weatherData.locationWeatherData[0].data[i].forEach(function(val){html+="<td>" + val + "</td>";})
+ html += "</tr>";
+ }
+ html += "</tbody>";
+ html += "</table>";
+ container.innerHTML = html;
+
+ }
+
/**
* Merges the two datasets. Keeping the primaryData if both sets have data for same time and parameter
* If a merge operation is not possible, primaryData is returned unchanged
@@ -364,15 +392,14 @@ async function initDataSourceMap(containerId, geoJson, countryCodeList)
map = null;
}
- //console.info(countryCodeList);
- //console.info(geoJson);
// If no data, no map
if((geoJson == undefined || geoJson == null || geoJson.features.length == 0) && (countryCodeList == null || countryCodeList.length == 0))
{
document.getElementById(containerId).innerHTML = "NO GEODATA PROVIDED BY WEATHER DATA SOURCE";
return;
}
- else{
+ else
+ {
document.getElementById(containerId).innerHTML = "";
}
@@ -398,8 +425,8 @@ async function initDataSourceMap(containerId, geoJson, countryCodeList)
// center to correct map projection)
var view = new ol.View({
center: ol.proj.transform([10,65], 'EPSG:4326', map.getView().getProjection().getCode()),
- zoom: 7,
- maxZoom: 7
+ zoom: 7//,
+ //maxZoom: 7
});
map.setView(view);
@@ -416,7 +443,6 @@ async function initDataSourceMap(containerId, geoJson, countryCodeList)
});
}
-
// If not, we have to get geoJson mapped to the countries
else if (countryCodeList != undefined && countryCodeList != null && countryCodeList.length > 0) {
let countryBoundaries = await getCountryBoundaries(countryCodeList);
@@ -429,16 +455,18 @@ async function initDataSourceMap(containerId, geoJson, countryCodeList)
if(drawnFeatures != undefined)
{
-
//console.info(drawnFeatures);
+ // Create an empty layer
var featureOverlay = new ol.layer.Vector({
source: new ol.source.Vector({
features: features
})
});
+ // Add the stations or area
featureOverlay.getSource().addFeatures(drawnFeatures);
featureOverlay.setMap(map);
+ // Fit the features to the extent of the map
extent = featureOverlay.getSource().getExtent();
map.getView().fit(extent, map.getSize());
}
diff --git a/ipmd/templates/ipmd/saddlegallmidgeform.html b/ipmd/templates/ipmd/saddlegallmidgeform.html
index 4b7f065e35063d6571f4a24b19864c164292fb74..26e2ba86282e94aa0099e7683cc18ab12c780e28 100644
--- a/ipmd/templates/ipmd/saddlegallmidgeform.html
+++ b/ipmd/templates/ipmd/saddlegallmidgeform.html
@@ -380,28 +380,6 @@
renderWeatherData(weatherData, document.getElementById("weatherData"), "table table-striped")
}
- function renderWeatherData(weatherData, container, tableClass){
- let dates = getDateArray(weatherData.timeStart, weatherData.interval, weatherData.locationWeatherData[0].length);
- let html = "<table" + (tableClass != undefined ? " class=\"" + tableClass + "\"" : "") + "><thead><tr><th>Time</th>";
- weatherData.weatherParameters.forEach(function(weatherParameterId){
- html +="<th>" + getWeatherParameter(weatherParameterId).name + "</th>";
- });
-
- html += "</tr></thead>"
- html += "<tbody>";
- //console.info("Weatherdata length: " + weatherData.locationWeatherData[0].data.length);
- for(let i=0;i< weatherData.locationWeatherData[0].data.length;i++)
- {
- html += "<tr><td>" + moment(dates[i]).format("YYYY-MM-DD HH:mm:ss") + "</td>";
- weatherData.locationWeatherData[0].data[i].forEach(function(val){html+="<td>" + val + "</td>";})
- html += "</tr>";
- }
- html += "</tbody>";
- html += "</table>";
- container.innerHTML = html;
-
- }
-
// Mock result!!! Waiting for ADAS to fix CORS issue