forked from HackaBXL/2014_think-of-the-children
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.js
98 lines (87 loc) · 3.18 KB
/
functions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
function addToTags(elem) {
console.log($(elem).val());
window.att = $(elem);
$(elem).parent().parent().find('#tagsimput').val($(elem).val())
}
function isInArray(v, a) {
var in_array = false;
for (var e in a) {
if (v.toLowerCase() == a[e].toLowerCase()) {
in_array = true;
break;
}
}
return in_array;
};
function extrapolateLinearly(pastValue, currentValue, yearsBetweenValues, numberOfYearsInTheFuture) {
return currentValue + numberOfYearsInTheFuture * (currentValue - pastValue) / yearsBetweenValues;
}
var Colors = (function() {
var a = 7,
b = 7,
c = 0.8,
d = 1.5;
var green = function(x) {
return Math.floor(1 / (1 + Math.exp(-a * (x - c))) * 255);
}
var red = function(x) {
return Math.floor(1 / (1 + Math.exp(-b * (d - x))) * 255);
}
return {
toColor: function(x) {
return 'rgb(' + red(x) + ', ' + green(x) + ', 0)';
}
}
})();
var getProvince = function (data){
var province = {
bruxelles: [],
brabantFlamand: [],
brabantWallon: [],
anvers: [],
flandreOccidentale: [],
flandreOrientale: [],
limbourg: [],
hainaut: [],
liege: [],
luxembourg: [],
namur: []
}
data.forEach(function(e){
if (e.properties.INS.toString().charAt(0) == '2' && e.properties.INS.toString().charAt(1) == '1'){
//$rootScope.myProviceArray.push(e);
province.bruxelles.push(e.properties.INS.toString());
}
else if ((e.properties.INS.toString().charAt(0) == '2' && e.properties.INS.toString().charAt(1) == '3') || (e.properties.INS.toString().charAt(0) == '2' && e.properties.INS.toString().charAt(1) == '4')){
province.brabantFlamand.push(e.properties.INS.toString());
}
else if (e.properties.INS.toString().charAt(0) == '2' && e.properties.INS.toString().charAt(1) == '5'){
province.brabantWallon.push(e.properties.INS.toString());
}
else if (e.properties.INS.toString().charAt(0) == '1'){
province.anvers.push(e.properties.INS.toString());
}
else if (e.properties.INS.toString().charAt(0) == '3'){
province.flandreOccidentale.push(e.properties.INS.toString());
}
else if (e.properties.INS.toString().charAt(0) == '4'){
province.flandreOrientale.push(e.properties.INS.toString());
}
else if (e.properties.INS.toString().charAt(0) == '5'){
province.hainaut.push(e.properties.INS.toString());
}
else if (e.properties.INS.toString().charAt(0) == '6'){
province.liege.push(e.properties.INS.toString());
}
else if (e.properties.INS.toString().charAt(0) == '7'){
province.limbourg.push(e.properties.INS.toString());
}
else if (e.properties.INS.toString().charAt(0) == '8'){
province.luxembourg.push(e.properties.INS.toString());
}
else if (e.properties.INS.toString().charAt(0) == '9'){
province.namur.push(e.properties.INS.toString());
}
});
return province;
};