Skip to content

Commit

Permalink
issue #30 - Fix display EO, MODEL and EO / MODEL layer
Browse files Browse the repository at this point in the history
  • Loading branch information
CIMAManuel committed May 27, 2019
1 parent 6d141ad commit 7a649b7
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 46 deletions.
1 change: 1 addition & 0 deletions client/js/angular/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var baseAPIurl = "http://seadrif.cimafoundation.org/authseadrif/api/";
var dollarMultiplier = 0;
var startDateRuns = 2018;
var rpValueApp = 0;
var bMapRaster = false;

rfseaApp.config(function($translateProvider, $translatePartialLoaderProvider, $locationProvider, $httpProvider) {

Expand Down
153 changes: 120 additions & 33 deletions client/js/angular/controller_countries_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ rfseaApp.controller('rfsea_countries_Ctrl', function($rootScope, $scope, $window
rfseaSrv.clearMap(map);
$scope.maptype = 'scale';
$scope.mapType = "";
bMapRaster = false;
setCountrySelected($scope.countrySelected);
}
});
Expand Down Expand Up @@ -474,7 +475,7 @@ rfseaApp.controller('rfsea_countries_Ctrl', function($rootScope, $scope, $window
}

function setColorMap(dataValue){
return rfseaSrv.setColorMap(dataValue, $scope.paletteColors);
return rfseaSrv.setColorMap(dataValue, $scope.paletteColors_saved);
}

function setFirstView(){
Expand Down Expand Up @@ -518,7 +519,9 @@ rfseaApp.controller('rfsea_countries_Ctrl', function($rootScope, $scope, $window

$scope.addLayersMap = function(mapType, legendTitle){

//Clear map from others map layer
rfseaSrv.clearMapLayerNational(map);
rfseaSrv.clearMap(map);

if($scope.mapType !== mapType)
{
Expand All @@ -544,22 +547,25 @@ rfseaApp.controller('rfsea_countries_Ctrl', function($rootScope, $scope, $window
});
}

$q.all(promises).then(function(reponse) {
$q.all(promises).then(function(response) {
//Do nothing
bMapRaster = true;
loadMapLayers(!$scope.bPeople, true);

});
} else {
$scope.mapType = "";
$scope.maptype = "scale";
$scope.paletteColors = angular.copy($scope.paletteColors_saved);
bMapRaster = false;
loadMapLayers(!$scope.bPeople, true);
}

}

function setLayer_eo(idCountry, idDistrict){

rfseaSrv.getProvinceDetails(idCountry, idDistrict, $scope.dateSelected, function(data)
{
// Country zone details
rfseaSrv.getProvinceDetails_promise(idCountry, idDistrict, $scope.dateSelected).then(function(data){

var bounds = new L.LatLngBounds(
new L.LatLng(data.data.imgs.eo.extent.ne[0],data.data.imgs.eo.extent.ne[1]),
Expand All @@ -581,22 +587,48 @@ rfseaApp.controller('rfsea_countries_Ctrl', function($rootScope, $scope, $window

map.addLayer($scope.overlay);

}, function(data)
{
// Error
console.log(data);
vex.dialog.alert({
message: 'API loading error.'
})
});



// rfseaSrv.getProvinceDetails(idCountry, idDistrict, $scope.dateSelected, function(data)
// {
// // Country zone details
//
// var bounds = new L.LatLngBounds(
// new L.LatLng(data.data.imgs.eo.extent.ne[0],data.data.imgs.eo.extent.ne[1]),
// new L.LatLng(data.data.imgs.eo.extent.sw[0],data.data.imgs.eo.extent.sw[1])
// );
//
// // Set legend parameters
// $scope.paletteColors = data.data.imgs.eo.legend;
// $scope.palettePosition = "bottomright";
// $scope.maptype = "value-translate";
//
// $scope.overlay = new L.ImageOverlay(baseAPIurl + 'data/img/?img=' + data.data.imgs.eo.img, bounds, {
// opacity: 1,
// interactive: true,
// attribution: ''
// });
//
// $scope.overlay.myTag = "MapCompaire";
//
// map.addLayer($scope.overlay);
//
// }, function(data)
// {
// // Error
// console.log(data);
// vex.dialog.alert({
// message: 'API loading error.'
// })
// });

}

function setLayer_eo_wd(idCountry, idDistrict) {

rfseaSrv.getProvinceDetails(idCountry, idDistrict, $scope.dateSelected, function(data)
{
// Country zone details
rfseaSrv.getProvinceDetails_promise(idCountry, idDistrict, $scope.dateSelected).then(function(data){

var bounds = new L.LatLngBounds(
new L.LatLng(data.data.imgs.compare_eo_wd.extent.ne[0],data.data.imgs.compare_eo_wd.extent.ne[1]),
Expand All @@ -618,22 +650,49 @@ rfseaApp.controller('rfsea_countries_Ctrl', function($rootScope, $scope, $window

map.addLayer($scope.overlay);

}, function(data)
{
// Error
console.log(data);
vex.dialog.alert({
message: 'API loading error.'
})
});


// rfseaSrv.getProvinceDetails(idCountry, idDistrict, $scope.dateSelected, function(data)
// {
// // Country zone details
//
// var bounds = new L.LatLngBounds(
// new L.LatLng(data.data.imgs.compare_eo_wd.extent.ne[0],data.data.imgs.compare_eo_wd.extent.ne[1]),
// new L.LatLng(data.data.imgs.compare_eo_wd.extent.sw[0],data.data.imgs.compare_eo_wd.extent.sw[1])
// );
//
// // Set legend parameters
// $scope.paletteColors = data.data.imgs.compare_eo_wd.legend;
// $scope.palettePosition = "bottomright";
// $scope.maptype = "value-translate";
//
// $scope.overlay = new L.ImageOverlay(baseAPIurl + 'data/img/?img=' + data.data.imgs.compare_eo_wd.img, bounds, {
// opacity: 1,
// interactive: true,
// attribution: ''
// });
//
// $scope.overlay.myTag = "MapCompaire";
//
// map.addLayer($scope.overlay);
//
// }, function(data)
// {
// // Error
// console.log(data);
// vex.dialog.alert({
// message: 'API loading error.'
// })
// });

}

function setLayer_wd(idCountry, idDistrict) {

rfseaSrv.getProvinceDetails(idCountry, idDistrict, $scope.dateSelected, function(data)
{
// Country zone details
console.log('model map')

rfseaSrv.getProvinceDetails_promise(idCountry, idDistrict, $scope.dateSelected).then(function(data){

var bounds = new L.LatLngBounds(
new L.LatLng(data.data.imgs.wd.extent.ne[0],data.data.imgs.wd.extent.ne[1]),
Expand All @@ -654,16 +713,43 @@ rfseaApp.controller('rfsea_countries_Ctrl', function($rootScope, $scope, $window
$scope.overlay.myTag = "MapCompaire";

map.addLayer($scope.overlay);

}, function(data)
{
// Error
console.log(data);
vex.dialog.alert({
message: 'API loading error.'
})
});



// rfseaSrv.getProvinceDetails_promise(idCountry, idDistrict, $scope.dateSelected, function(data)
// {
// // Country zone details
//
// var bounds = new L.LatLngBounds(
// new L.LatLng(data.data.imgs.wd.extent.ne[0],data.data.imgs.wd.extent.ne[1]),
// new L.LatLng(data.data.imgs.wd.extent.sw[0],data.data.imgs.wd.extent.sw[1])
// );
//
// // Set legend parameters
// $scope.paletteColors = data.data.imgs.wd.legend;
// $scope.palettePosition = "bottomright";
// $scope.maptype = "value-translate";
//
// $scope.overlay = new L.ImageOverlay(baseAPIurl + 'data/img/?img=' + data.data.imgs.wd.img, bounds, {
// opacity: 1,
// interactive: true,
// attribution: ''
// });
//
// $scope.overlay.myTag = "MapCompaire";
//
// map.addLayer($scope.overlay);
//
// }, function(data)
// {
// // Error
// console.log(data);
// vex.dialog.alert({
// message: 'API loading error.'
// })
// });

}

/***************************************************/
Expand Down Expand Up @@ -730,6 +816,7 @@ rfseaApp.controller('rfsea_countries_Ctrl', function($rootScope, $scope, $window
{
//Set new RUN date
$scope.dateSelected = RunDate;
bMapRaster = false;
init();
}

Expand Down
67 changes: 54 additions & 13 deletions client/js/angular/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Created by Manuel on 13/01/2017.
*/

rfseaApp.service("rfseaSrv", ['$http', '$filter', function($http, $filter)
rfseaApp.service("rfseaSrv", ['$http', '$filter', function($http, $filter, $rootScope)
{

/*****************************************************************************************/
Expand Down Expand Up @@ -123,7 +123,7 @@ rfseaApp.service("rfseaSrv", ['$http', '$filter', function($http, $filter)

$http({
method: 'GET',
url: baseAPIurl + 'data/' + countryID + '/' + zoneID + '/zonedetails/'
url: url
}).then(function (data) {
if(onSuccess) onSuccess(data)
},function(data){
Expand All @@ -132,6 +132,25 @@ rfseaApp.service("rfseaSrv", ['$http', '$filter', function($http, $filter)

}

this.getProvinceDetails_promise = function(countryID, zoneID, date){

var url = "";
if(date == '')
{
url = baseAPIurl + 'data/' + countryID + '/' + zoneID + '/zonedetails/';
} else {
url = baseAPIurl + 'data/' + countryID + '/' + zoneID + '/zonedetails/?d=' + date;
}

return $http({
method: 'GET',
url: url
})
.then(function(data){return data})
.catch(function(error){console.log(error)});

}

// This API allow the user to obtain the byte stream of one image. This API call should be used as a url to a file.
this.getImage = function(imgID, onSuccess, onError){

Expand Down Expand Up @@ -278,21 +297,43 @@ rfseaApp.service("rfseaSrv", ['$http', '$filter', function($http, $filter)
var objColor = {};
var color = [];
var opacity = 0;
var paletteColorTemp = angular.copy(paletteColors);

if(dataValue.properties.data === 0){
opacity = 0.1;
} else {
opacity = 0.5;
}

color = $filter('filter')(paletteColors, function(item){
color = $filter('filter')(paletteColorTemp, function(item){
return dataValue.properties.data >= item.label_min && dataValue.properties.data < item.label_max;
});

objColor = {
color: "#22293e",
fillColor: color[0].color,
fillOpacity: opacity
if(bMapRaster){
//Raster Maps layer loaded

if(dataValue.properties.data === 0){
color= "#22293e";
} else {
color= color[0].color;
}

objColor = {
color: color,
fillColor: color[0].color,
fillOpacity: 0,
'stroke-width': 5
}

} else {
//Affected people layer loaded

if(dataValue.properties.data === 0){
opacity = 0.1;
} else {
opacity = 0.5;
}

objColor = {
color: "#22293e",
fillColor: color[0].color,
fillOpacity: opacity
}

}

return objColor;
Expand Down

0 comments on commit 7a649b7

Please sign in to comment.