-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.js
57 lines (49 loc) · 1.37 KB
/
main.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
// Create a World Window for the canvas.
var wwd = new WorldWind.WorldWindow("worldwind")
// Add some image layers to the World Window's globe.
wwd.addLayer(new WorldWind.BMNGOneImageLayer())
wwd.addLayer(new WorldWind.BingAerialWithLabelsLayer())
// Add a compass, a coordinates display and some view controls to the World Window.
wwd.addLayer(new WorldWind.CompassLayer())
wwd.addLayer(new WorldWind.CoordinatesDisplayLayer(wwd))
wwd.addLayer(new WorldWind.ViewControlsLayer(wwd))
// Add a CovJSON layer
CovJSON.read('grid.covjson').then(function (cov) {
var firstParamKey = cov.parameters.keys().next().value
var covjsonLayer = CovJSONLayer(cov, {
displayName: 'CovJSON Grid',
paramKey: firstParamKey
})
wwd.addLayer(covjsonLayer)
wwd.goTo(new WorldWind.Position(50, 10, 4000000))
})
// add a computed coverage layer
function linspace (start, end, n) {
var d = (end - start) / (n - 1 )
return {
length: n,
get: function (i) {
return start + i * d
}
}
}
var nx = 3000
var ny = 3000
var griddata = xndarray({
length: nx*ny,
get: function (i) {
return i
}
}, {
shape: [ny,nx],
names: ['y','x'],
coords: {
y: linspace(-70, 70, ny),
x: linspace(-100, 0, nx)
}
})
var covjsonLayer = new CovJSONGridLayer(CovUtils.fromXndarray(griddata), {
displayName: 'Generated Grid',
paletteExtent: [0,nx*ny]
})
wwd.addLayer(covjsonLayer)