Use CSS to display no go upload errors

This commit is contained in:
Gautier Pelloux-Prayer 2019-08-07 10:38:22 +02:00
parent b116438de9
commit a9d0b01ee2
2 changed files with 24 additions and 5 deletions

View file

@ -425,30 +425,37 @@
reader.onload = function() {
resolve(reader.result);
};
reader.onerror = function() {
$('#nogoError').text(
'Cannot read file: ' + reader.error.message
);
$('#nogoError').css('display', 'block');
};
reader.readAsText(nogoFile);
}).then(function(response) {
return JSON.parse(response);
});
} else {
$('#nogoError').text('Error: Missing file or URL.');
$('#nogoError').text('Missing file or URL.');
$('#nogoError').css('display', 'block');
return false;
}
var nogoWeight = parseFloat($('#nogoWeight').val());
if (isNaN(nogoWeight)) {
$('#nogoError').text('Error: Missing default nogo weight.');
$('#nogoError').text('Missing default nogo weight.');
$('#nogoError').css('display', 'block');
return false;
}
var nogoRadius = parseFloat($('#nogoRadius').val());
if (isNaN(nogoRadius) || nogoRadius < 0) {
$('#nogoError').text('Error: Invalid default nogo radius.');
$('#nogoError').text('Invalid default nogo radius.');
$('#nogoError').css('display', 'block');
return false;
}
var nogoBuffer = parseFloat($('#nogoBuffer').val());
if (isNaN(nogoBuffer)) {
$('#nogoError').text('Error: Invalid nogo buffering radius.');
$('#nogoError').text('Invalid nogo buffering radius.');
$('#nogoError').css('display', 'block');
return false;
}
@ -471,6 +478,14 @@
}
});
if (cleanedGeoJSONFeatures.length === 0) {
$('#nogoError').text(
'No valid area found in provided input.'
);
$('#nogoError').css('display', 'block');
return false;
}
var geoJSON = L.geoJson(
turf.featureCollection(cleanedGeoJSONFeatures),
{