-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
72 lines (58 loc) · 1.97 KB
/
index.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
var {kriging_contour}=require('./dist/kriging-contour');
var fs=require('fs');
let mapCenter=[118, 32];
//首次加载,自动渲染一次差值图
let extent = [mapCenter[0]-.05,mapCenter[1]-.05,mapCenter[0]+.05,mapCenter[1]+.05];
let dataset = {
"type" : "FeatureCollection",
"features" : []
};
let values=[],lngs=[],lats=[];
//随机生成100个点,在指定范围内
for (let i = 0; i < 100; i++) {
//lngs.push(mapCenter[0]+Math.random()*0.1-.05);
//lats.push(mapCenter[1]+Math.random()*0.1-.05);
//values.push(Math.random()*100);
let feature={
"type" : "Feature",
"properties" : {
"level" : Math.random()*100
},
"geometry" : {
"type" : "Point",
"coordinates" : [mapCenter[0]+Math.random()*0.1-.05,mapCenter[1]+Math.random()*0.1-.05]
}
};
dataset.features.push(feature);
}
let aaa=kriging_contour(dataset,'level',{
model:'exponential',
sigma2:0,
alpha:100
},[0,10,20,30,40,50,60,70,80,90,100]);
let str = JSON.stringify(aaa);
fs.writeFile('./data.json',str,function(err){
if (err) {
res.status(500).send('Server is error...')
}
});
/*
let params={
mapCenter:[118, 32],
//mapCenter:[114.360456, 30.538622],
maxValue:100,
krigingModel:'exponential',//model还可选'gaussian','spherical'
krigingSigma2:0,
krigingAlpha:100,
canvasAlpha:0.9,//canvas图层透明度
colors:["#006837", "#1a9850", "#66bd63", "#a6d96a", "#d9ef8b", "#ffffbf",
"#fee08b", "#fdae61", "#f46d43", "#d73027", "#a50026"],
};*/
// let variogram=kriging.train(values,lngs,lats,
// 'exponential',0,100);
// let polygons=[];
// polygons.push([[extent[0],extent[1]],[extent[0],extent[3]],
// [extent[2],extent[3]],[extent[2],extent[1]]]);
// let grid=kriging.grid(polygons,variogram,(extent[2]-extent[0])/200,(extent[3]-extent[1])/200);
// let ds=kriging.contour(grid,[0,10,20,30,40,50,60,70,80,90,100]);
console.log(aaa);