-
Notifications
You must be signed in to change notification settings - Fork 2
/
noise.html
185 lines (159 loc) · 7.37 KB
/
noise.html
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="WebGLTextureOverlay.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.3/proj4.js"></script>
<script src="lib/jickle.js"></script>
<style>
html,body{
height: 100%;
width: 100%;
overflow: hidden;
margin: 0;
padding: 0;
}
#map{
height: 100%;
width: 100%;
}
canvas.leaflet-heatmap-layer{
position: absolute;
top: 0px;
left: 0px;
}
</style>
<script>
$.getJICKLE = function(path, onload){
var xhr = new XMLHttpRequest();
xhr.open('GET', path, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(){
onload(JICKLE.parse(xhr.response));
};
xhr.send();
}
$(function(){
var map = L.map('map').setView([59.984134,-119.960313], 6);
//var map = L.map('map').setView([52,-85], 6);
L.tileLayer('http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg', {
subdomains: '1234'
}).addTo(map);
var overlay = L.webglTextureOverlay()
.addTo(map);
var intensityLayer = overlay.addLayer();
// interpolation handling
var setInterpolation = function(){
intensityLayer.setInterpolation(interpolationSelect.val());
};
var interpolationSelect = $('<select></select>')
.appendTo('body')
.css({position:'absolute', top:50, right:10})
.change(setInterpolation);
for(var i=0; i<overlay.interpolations.length; i++){
var interpolation = overlay.interpolations[i];
$('<option></option>')
.text(interpolation)
.appendTo(interpolationSelect);
}
setInterpolation();
// fade function handling
var setFadeFun = function(){
intensityLayer.setFadeFun(fadeFunSelect.val(), {
spatialFrequency: parseFloat(spatialFrequency.val()),
timeFrequency: parseFloat(timeFrequency.val()),
amplitude: parseFloat(amplitude.val()),
attack: parseFloat(attack.val())
});
};
var fadeFunSelect = $('<select></select>')
.appendTo('body')
.css({position:'absolute', top:110, right:10})
.change(setFadeFun);
for(var i=0; i<overlay.fades.length; i++){
var fadeFunction = overlay.fades[i];
$('<option></option>')
.text(fadeFunction)
.appendTo(fadeFunSelect);
}
var spatialFrequency = $('<input type="range" min="0.5" max="20" value="5" step="0.01"></input>')
.appendTo('body')
.css({position:'absolute', top:130, right:10, width:300})
.bind('input', setFadeFun);
var timeFrequency = $('<input type="range" min="1.0" max="50" value="8" step="0.01"></input>')
.appendTo('body')
.css({position:'absolute', top:150, right:10, width:300})
.bind('input', setFadeFun);
var amplitude = $('<input type="range" min="0.5" max="10" value="1.5" step="0.01"></input>')
.appendTo('body')
.css({position:'absolute', top:170, right:10, width:300})
.bind('input', setFadeFun);
var attack = $('<input type="range" min="0" max="0.5" value="0.25" step="0.01"></input>')
.appendTo('body')
.css({position:'absolute', top:190, right:10, width:300})
.bind('input', setFadeFun);
setFadeFun();
// fade factor handling
var setTime = function(){
var t = parseFloat(time.val());
intensityLayer.setTime(t);
}
var time = $('<input type="range" min="1900" max="2060" value="1900" step="0.01"></input>')
.appendTo('body')
.css({position:'absolute', top:80, right:10, width:300})
.bind('input', setTime);
setTime()
// data handling
$.getJSON('data/colors.json', function(colors){
var setColor = function(){
intensityLayer.setColormap(colors[colorSelect.val()]);
};
var colorSelect = $('<select></select>')
.appendTo('body')
.css({position:'absolute', top:10, right:10})
.change(setColor);
for(name in colors){
var option = $('<option></option>')
.text(name)
.appendTo(colorSelect);
}
setColor();
var setData = function(){
var dataName = dataSelect.val();
var dataPath = 'data/' + dataName + '.jickle';
$.getJICKLE(dataPath, function(data){
intensityLayer.setData({
width: data.width,
height: data.height,
bitmaps: data.bitmaps,
projection: data.projection,
bounds: {
left: data.left,
right: data.right,
top: data.top,
bottom: data.bottom
}
});
});
};
var dataSelect = $('<select></select>')
.appendTo('body')
.css({position:'absolute', top:30, right:10})
.change(setData);
$('<option></option>')
.text('annual-precipitation-video')
.appendTo(dataSelect)
$('<option></option>')
.text('human-population-video')
.appendTo(dataSelect)
setData();
});
});
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>