Commit e563318e authored by Antonella Giachino's avatar Antonella Giachino
Browse files

Fixed bug about selection on SPATIAL_ATTRIBUTE data type (without association)

parent 2537ddc2
......@@ -330,8 +330,9 @@ function cockpitChartWidgetControllerFunction(
if (selectionsOfDataset.hasOwnProperty(columnName)) {
var selectionsValues = selectionsOfDataset[columnName]
for (var z=0 ; z < selectionsValues.length ; z++){
var filterValue = selectionsValues[z]
var filterValue = selectionsValues[z];
// clean the value from the parenthesis ( )
filterValue = filterValue.replace(/[()]/g, '');
// clean the value from the parenthesis ''
filterValue = filterValue.replace(/['']/g, '');
......@@ -344,6 +345,9 @@ function cockpitChartWidgetControllerFunction(
}
//apply the filter function
var columnObject = scope.getColumnObjectFromName(scope.ngModel.content.columnSelectedOfDataset,columnName);
if (!columnObject){
columnObject = scope.getColumnObjectFromName(widgetDataset.metadata.fieldsMeta,columnName);
}
//use the alias to match the filtercolumn name
var filterColumnname = columnObject.alias;
var columnType = columnObject.fieldType;
......@@ -509,7 +513,7 @@ function cockpitChartWidgetControllerFunction(
if (rows[i][dataIndex]){
for (var y=0; y < values.length ; y++){
//handle Attribute as String and Measure as number
if (columnType == 'ATTRIBUTE'){
if (columnType == 'ATTRIBUTE' || columnType == 'SPATIAL_ATTRIBUTE'){
if (rows[i][dataIndex] == values[y]){
toReturn.push(rows[i]);
}
......
......@@ -134,9 +134,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
formattedSelection[columnObject.aliasToShow || columnObject.alias] = {"values":[], "type": columnObject.fieldType};
for(var k in datasetSelection[s]){
// clean the value from the parenthesis ( )
var x = datasetSelection[s][k].replace(/[()]/g, '').replace(/['']/g, '').split(/[,]/g);
for(var i=0; i<x.length; i++){
formattedSelection[columnObject.aliasToShow || columnObject.alias].values.push(x[i]);
if (columnObject.fieldType == "SPATIAL_ATTRIBUTE") {
//for spatial attribute doens't split value
var x = datasetSelection[s][k].replace(/[()]/g, '').replace(/['']/g, '');
formattedSelection[columnObject.aliasToShow || columnObject.alias].values.push(x);
}else{
var x = datasetSelection[s][k].replace(/[()]/g, '').replace(/['']/g, '').split(/[,]/g);
for(var i=0; i<x.length; i++){
formattedSelection[columnObject.aliasToShow || columnObject.alias].values.push(x[i]);
}
}
}
}
......@@ -198,6 +204,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
if (eval(expression) == false){
datastore.rows.splice(i,1);
}
}else if (filters[f].type == 'SPATIAL_ATTRIBUTE'){
var value = datastore.rows[i][columnName];
if (filters[f].values.indexOf(value)==-1){
datastore.rows.splice(i,1);
}
}
}
}
......@@ -409,6 +421,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
layer.setZIndex(layerDef.order*1000);
layer.modalSelectionColumn = layerDef.modalSelectionColumn;
layer.hasShownDetails = layerDef.hasShownDetails;
layer.isHeatmap = isHeatmap;
layer.isCluster = isCluster;
if ($scope.map)
$scope.map.addLayer(layer); //add layer to ol.Map
......@@ -498,8 +512,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
$scope.doSelection($scope.selectedLayer.modalSelectionColumn, $scope.props[$scope.selectedLayer.modalSelectionColumn].value, null, null, null, null, $scope.selectedLayer.dsId);
}
//popup isn't shown with cluster
if (!$scope.clickOnFeature || !$scope.selectedLayer.hasShownDetails){
//popup isn't shown with cluster and heatmap
if ($scope.selectedLayer.isCluster || $scope.selectedLayer.isHeatmap || !$scope.selectedLayer.hasShownDetails){
$scope.closer.onclick();
return;
}
......
......@@ -472,6 +472,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//using the reformatted filters
var filters = selection ? selection : $scope.reformatFilters();
for(var f in filters){
for(var d = dataset.length - 1; d >= 0; d--){
//if the column is an attribute check in filter
if (filters[f].type == 'ATTRIBUTE'){
......@@ -502,6 +503,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
if (eval(expression) == false){
dataset.splice(d,1);
}
}else if (filters[f].type == 'SPATIAL_ATTRIBUTE'){
var value = dataset[d][f];
if (filters[f].values.indexOf(value)==-1){
dataset.splice(d,1);
}
}
}
}
......@@ -529,9 +536,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
formattedSelection[columnObject.aliasToShow || columnObject.alias] = {"values":[], "type": columnObject.fieldType};
for(var k in datasetSelection[s]){
// clean the value from the parenthesis ( )
var x = datasetSelection[s][k].replace(/[()]/g, '').replace(/['']/g, '').split(/[,]/g);
for(var i=0; i<x.length; i++){
formattedSelection[columnObject.aliasToShow || columnObject.alias].values.push(x[i]);
if (columnObject.fieldType == "SPATIAL_ATTRIBUTE") {
//for spatial attribute doens't split value
var x = datasetSelection[s][k].replace(/[()]/g, '').replace(/['']/g, '');
formattedSelection[columnObject.aliasToShow || columnObject.alias].values.push(x);
}else{
var x = datasetSelection[s][k].replace(/[()]/g, '').replace(/['']/g, '').split(/[,]/g);
for(var i=0; i<x.length; i++){
formattedSelection[columnObject.aliasToShow || columnObject.alias].values.push(x[i]);
}
}
}
}
......
......@@ -335,7 +335,7 @@
// apply formule: w = w-min/max-min (http://www.statisticshowto.com/normalized/)
weight = (p.value - minmax.minValue)/(minmax.maxValue-minmax.minValue);
weight = Math.round(weight * 1000) / 1000; //round 3 digits
if (weight == 0) weight = parseFloat("0.2"); //force weight for minimum values
// if (weight == 0) weight = parseFloat("0.2"); //force weight for minimum values
// console.log("Id ["+ props.id.value + "] - Label [" + minmaxLabel + "] - value [" + p.value + "] - weight [" + weight+ "]");
return weight;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment