Skip to content
Snippets Groups Projects
Commit 71ab1346 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Merge branch 'spotit_wp_34_bugfix' into 'develop'

Avoiding meltdown in Grid Model run

See merge request !6
parents 2e4dd379 362b45ad
Branches
Tags
2 merge requests!17Develop,!6Avoiding meltdown in Grid Model run
...@@ -20,8 +20,13 @@ ...@@ -20,8 +20,13 @@
package no.nibio.vips.logic.scheduling.model.grid.preprocessor; package no.nibio.vips.logic.scheduling.model.grid.preprocessor;
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -34,6 +39,7 @@ import no.nibio.vips.logic.entity.PointOfInterestWeatherStation; ...@@ -34,6 +39,7 @@ import no.nibio.vips.logic.entity.PointOfInterestWeatherStation;
import no.nibio.vips.logic.scheduling.model.ModelRunPreprocessor; import no.nibio.vips.logic.scheduling.model.ModelRunPreprocessor;
import no.nibio.vips.logic.scheduling.model.PreprocessorException; import no.nibio.vips.logic.scheduling.model.PreprocessorException;
import no.nibio.vips.logic.util.SessionControllerGetter; import no.nibio.vips.logic.util.SessionControllerGetter;
import no.nibio.vips.logic.util.SystemTime;
import no.nibio.vips.util.WeatherElements; import no.nibio.vips.util.WeatherElements;
import no.nibio.vips.util.WeatherObservationListException; import no.nibio.vips.util.WeatherObservationListException;
import no.nibio.vips.util.WeatherUtil; import no.nibio.vips.util.WeatherUtil;
...@@ -105,6 +111,10 @@ public class ZymoseptoriaSimpleRiskGridModelPreprocessor extends ModelRunPreproc ...@@ -105,6 +111,10 @@ public class ZymoseptoriaSimpleRiskGridModelPreprocessor extends ModelRunPreproc
List<WeatherObservation> stationObs;// = new ArrayList<>(); List<WeatherObservation> stationObs;// = new ArrayList<>();
WeatherDataSourceUtil wdsUtil = new WeatherDataSourceUtil(); WeatherDataSourceUtil wdsUtil = new WeatherDataSourceUtil();
WeatherUtil wUtil = new WeatherUtil(); WeatherUtil wUtil = new WeatherUtil();
// We run this for max 1 week back in time to make sure it doesn't crash
ZonedDateTime aWeekAgo = ZonedDateTime.ofInstant(SystemTime.getSystemTime().toInstant(), ZoneId.of("Europe/Oslo")).minus(1, ChronoUnit.WEEKS);
ZonedDateTime aWeekAhead = ZonedDateTime.ofInstant(SystemTime.getSystemTime().toInstant(), ZoneId.of("Europe/Oslo")).plus(1, ChronoUnit.WEEKS);
try { try {
stationObs = wdsUtil.getWeatherObservations( stationObs = wdsUtil.getWeatherObservations(
...@@ -116,8 +126,8 @@ public class ZymoseptoriaSimpleRiskGridModelPreprocessor extends ModelRunPreproc ...@@ -116,8 +126,8 @@ public class ZymoseptoriaSimpleRiskGridModelPreprocessor extends ModelRunPreproc
WeatherElements.PRECIPITATION, WeatherElements.PRECIPITATION,
WeatherElements.TEMPERATURE_MEAN WeatherElements.TEMPERATURE_MEAN
}, },
configuration.getDateStartInTimeZone(), Date.from(aWeekAgo.toInstant()),
configuration.getDateEndInTimeZone(), Date.from(aWeekAhead.toInstant()),
true true
); );
stationObs = wUtil.checkForAndFixHourlyTimeSeriesHoles(stationObs); stationObs = wUtil.checkForAndFixHourlyTimeSeriesHoles(stationObs);
......
This diff is collapsed.
...@@ -26,13 +26,14 @@ ...@@ -26,13 +26,14 @@
var hostName; var hostName;
var results; var results;
//var localTimeZoneOffset = 120; //var localTimeZoneOffset = 120;
var todayAtMidnight = getTodayAtMidnight(); var todayAtMidnight;
var featureOverlays = {mainMap:null, subMap1: null, subMap2: null, subMap3: null, subMap4: null}; var featureOverlays = {mainMap:null, subMap1: null, subMap2: null, subMap3: null, subMap4: null};
var maps = {mainMap:null, subMap1: null, subMap2: null, subMap3: null, subMap4: null}; var maps = {mainMap:null, subMap1: null, subMap2: null, subMap3: null, subMap4: null};
var language = "en"; var language = "en";
var initMap = function () var initMap = function ()
{ {
todayAtMidnight = getTodayAtMidnight();
var zymoGridMapContainer = document.getElementById("zymoGridMapContainer"); var zymoGridMapContainer = document.getElementById("zymoGridMapContainer");
language = zymoGridMapContainer.getAttribute("data-language") != null ? zymoGridMapContainer.getAttribute("data-language") : language; language = zymoGridMapContainer.getAttribute("data-language") != null ? zymoGridMapContainer.getAttribute("data-language") : language;
zymoGridMapContainer.innerHTML = "<div id='mainMap'>" zymoGridMapContainer.innerHTML = "<div id='mainMap'>"
...@@ -83,6 +84,7 @@ var initMap = function () ...@@ -83,6 +84,7 @@ var initMap = function ()
ajax(hostName + "/rest/forecastresults/-1000", function(e){ ajax(hostName + "/rest/forecastresults/-1000", function(e){
//ajax("http://vipslogic-local.no/rest/forecastresults/-1000", function(e){ //ajax("http://vipslogic-local.no/rest/forecastresults/-1000", function(e){
results = JSON.parse(e.target.responseText); results = JSON.parse(e.target.responseText);
console.info(todayAtMidnight);
var currentDay = todayAtMidnight; var currentDay = todayAtMidnight;
for(var mapName in maps) for(var mapName in maps)
{ {
...@@ -178,15 +180,19 @@ function parseJSONDate(theDateString) ...@@ -178,15 +180,19 @@ function parseJSONDate(theDateString)
function getTodayAtMidnight() function getTodayAtMidnight()
{ {
//return moment("");
// TODO:Add momentjs support here!!!
var now = new Date(); var now = new Date();
var midnightString = now.getFullYear() + "-" + var midnightString = now.getFullYear() + "-" +
('0' + (now.getMonth()+1)).slice(-2) + "-" + ('0' + (now.getMonth()+1)).slice(-2) + "-" +
('0' + (now.getDate()-1)).slice(-2) + ('0' + (now.getDate()-1)).slice(-2) +
"T22:00:00.000+0000"; "T23:00:00.000+0000";
return new Date(midnightString); return new Date(midnightString);
// OR RETURN A FIXED DATE FOR TESTING // OR RETURN A FIXED DATE FOR TESTING
return new Date("2017-09-07T22:00:00.000+0000"); //return new Date("2017-09-07T22:00:00.000+0000");
} }
...@@ -209,8 +215,8 @@ document.addEventListener("DOMContentLoaded", function() { ...@@ -209,8 +215,8 @@ document.addEventListener("DOMContentLoaded", function() {
} }
} }
hostName = me.src.substring(0,me.src.indexOf("/public")); hostName = me.src.substring(0,me.src.indexOf("/public"));
// Creating a chain here: First we load ol.css, then nordic_septoria_whs.css // Creating a chain here: First we load ol.css, then nordic_septoria_whs.css,
// and finally ol.js. Then we initialize the Map // ol.js and finally moment.min.js. Then we initialize the Map
loadHeadElement("link", loadHeadElement("link",
{ {
href: hostName + "/public/nordic_septoria_whs/ol.css", href: hostName + "/public/nordic_septoria_whs/ol.css",
...@@ -224,7 +230,21 @@ document.addEventListener("DOMContentLoaded", function() { ...@@ -224,7 +230,21 @@ document.addEventListener("DOMContentLoaded", function() {
rel: "stylesheet", rel: "stylesheet",
media: "screen" media: "screen"
}, },
function(){ loadHeadElement("script", { src: hostName + "/public/nordic_septoria_whs/ol.js" }, initMap); } function(){
loadHeadElement("script",
{
src: hostName + "/public/nordic_septoria_whs/ol.js"
},
function() {
loadHeadElement("script",
{
src: hostName + "/public/nordic_septoria_whs/moment.min.js"
},
initMap
);
}
);
}
); );
} }
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment