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

Check that gridded datasources cover the selected location

parent a1bf419f
Branches
No related tags found
2 merge requests!13Saddlegallmidge form idec 372,!12feat: Add test page (spatial) with mapserver layer in openlayers map
......@@ -176,7 +176,7 @@ async function getLocationWeatherData(endpoint, longitude, latitude, parameters,
+ "&latitude=" + latitude
+ "&parameters=" + 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++)
{
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment