diff --git a/ipmd/static/ipmd/js/ipmdlib.js b/ipmd/static/ipmd/js/ipmdlib.js index 8536862f8aa882cccc31b4f6b3a0c4a79ef163ff..3c40f2cafd9af7e864f0004fe15736e37c631148 100644 --- a/ipmd/static/ipmd/js/ipmdlib.js +++ b/ipmd/static/ipmd/js/ipmdlib.js @@ -176,7 +176,7 @@ async function getLocationWeatherData(endpoint, longitude, latitude, parameters, + "&latitude=" + latitude + "¶meters=" + parameters.join(",") ); - return await response.json(); + return (response.status == 200) ? await response.json() : null; } /** @@ -295,7 +295,6 @@ async function isPointCoveredByDatasource(coordinate, datasource) return true; } let geoJson = await getDatasourceFeatures(JSON.parse(datasource.spatial.geoJSON), datasource.spatial.countries); - console.info(geoJson); let retVal = false; for(let i=0; i<geoJson.features.length;i++) { diff --git a/ipmd/templates/ipmd/saddlegallmidgeform.html b/ipmd/templates/ipmd/saddlegallmidgeform.html index 9183560386c45471ba87dd0bb7b5d33af0fe3954..932fc31c562eef6592c90c74171f5a4fd22584b2 100644 --- a/ipmd/templates/ipmd/saddlegallmidgeform.html +++ b/ipmd/templates/ipmd/saddlegallmidgeform.html @@ -355,6 +355,12 @@ else { coordinate = getLatLon(); + // Need to check that the selected datasource covers the requested location + if(! await isPointCoveredByDatasource(coordinate, currentWeatherDatasource)) + { + alert("ERROR: The selected historic datasource does not cover your selected location. Please select an appropriate location or datasource."); + return; + } weatherData = await getLocationWeatherData( getWeatherDatasourceEndpoint(currentWeatherDatasource), coordinate[0], @@ -379,6 +385,12 @@ // 2. Forecast weather data if(currentForecastWeatherDatasource != undefined) { + // Need to check that the selected datasource covers the requested location + if(! await isPointCoveredByDatasource(coordinate, currentForecastWeatherDatasource)) + { + alert("ERROR: The selected forecast datasource does not cover your selected location. Please select an appropriate location or datasource."); + return; + } forecastData = await getLocationWeatherData( getWeatherDatasourceEndpoint(currentForecastWeatherDatasource), document.getElementById("longitude").value, @@ -408,8 +420,15 @@ weatherData = mergeWeatherData(weatherData, forecastData); } } - - inputData["weatherData"] = weatherData; + if(weatherData != null) + { + inputData["weatherData"] = weatherData; + } + else + { + alert("ERROR: Could not get weather data. Please check if your datasource covers your location."); + return; + } } // Ready to call server? let result = mockResult;