This repository was archived by the owner on Jan 19, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesteKernelGausiano.html
More file actions
175 lines (127 loc) · 5.35 KB
/
Copy pathtesteKernelGausiano.html
File metadata and controls
175 lines (127 loc) · 5.35 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Quick Start - Leaflet</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css" integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA==" crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js" integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA==" crossorigin=""></script>
<script src='https://npmcdn.com/@turf/turf/turf.min.js'></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chroma-js/1.3.7/chroma.min.js"></script>
</head>
<body>
<div id="mapid" style="width: 1200px; height: 900px;"></div>
<script>
var h = 15;
var areaJson = {"type":"Polygon","coordinates":[[[-53.2098614,-24.3000435],[-53.2105532,-24.2998583],[-53.2109657,-24.2993532],[-53.2115398,-24.2993448],[-53.2124094,-24.297742],[-53.2127809,-24.2974012],[-53.2207925,-24.2962012],[-53.221644,-24.2965361],[-53.2222243,-24.2979741],[-53.2216208,-24.3002919],[-53.2219343,-24.3022873],[-53.2216323,-24.3032511],[-53.2212139,-24.3034486],[-53.217101,-24.3036766],[-53.2148378,-24.3046601],[-53.2116584,-24.3048551],[-53.2099158,-24.3046485],[-53.2098614,-24.3000435],[-53.2098614,-24.3000435]]]};
var pontosComPeso = [
[-53.22161882, -24.30118093, 1],
[-53.22138295, -24.29714482, 1],
[-53.21988196, -24.30127444, 1],
[-53.21962501, -24.30258456, 1],
[-53.21918588, -24.29934324, 1],
[-53.21915521, -24.3033509, 1],
[-53.21906179, -24.30310445, 1],
[-53.21816861, -24.30014024, 1],
[-53.21812818, -24.30138849, 1],
[-53.21718541, -24.30273996, 1],
[-53.21702594, -24.3017541, 1],
[-53.21699119, -24.30197869, 1],
[-53.21692578, -24.30199683, 1],
[-53.21661104, -24.29948709, 1],
[-53.21605175, -24.30151013, 1],
[-53.21485867, -24.30008093, 1],
[-53.21446668, -24.29963489, 1],
[-53.21383935, -24.30166479, 1],
[-53.21275825, -24.29768951, 1],
[-53.21216219, -24.29973922, 1],
[-53.21162634, -24.3017988, 1],
[-53.21128604, -24.30209445, 1],
[-53.21078907, -24.3026255, 1],
[-53.21045956, -24.30008577, 1],
[-53.21033637, -24.30216756, 1],
[-53.21025036, -24.30004382, 1],
[-53.21018187, -24.30216682, 1],
[-53.21017414, -24.30316423, 1],
[-53.21014091, -24.30005189, 1],
[-53.20999731, -24.30441826, 1],
[-53.20992246, -24.30191171, 1],
[-53.20988271, -24.30019703, 1],
[-53.21988759, -24.30131856,1*100],
[-53.20994361, -24.30193939,1*100],
[-53.22167497, -24.30120798,2*100],
[-53.21927701, -24.29904331,2*100],
[-53.21797397, -24.30144273,2*100],
[-53.21681325, -24.29919796,5*100],
[-53.21412204, -24.29935754,5*100],
[-53.211794, -24.29950127, 6*100]
];
var pontosFunction = [];
pontosComPeso.forEach(function(a){
for(var i = 1; i< a[2]; i++){
pontosFunction.push(function(x,y){
var primeiraParte = -(1/(2*h));
var segundaParte = (Math.pow((x-a[0]), 2) + Math.pow((y-a[1]), 2));
return Math.exp(primeiraParte * segundaParte);
});
}
});
function formula(x, y){
var primeiraParte = 1/(2*Math.PI*pontosFunction.length)
var somatorio = pontosFunction.map(f => f(x, y)).reduce((a, b) => a +b , 0);
return primeiraParte*somatorio;
}
var map = L.map('mapid');
L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
maxZoom: 16,
minZoom:1
}).addTo(map);
var areaLayer = L.geoJSON(areaJson);
map.fitBounds(areaLayer.getBounds());
areaLayer.addTo(map);
pontosComPeso.forEach(function(p){
var marker = L.circleMarker(p.slice(0,2).reverse(), {
radius: 5
}).addTo(map);
marker.bindPopup(p[2] + '');
});
var cellSide = 0.01;
var bbox = areaLayer.getBounds().toBBoxString().split(',').map(function(item) {
return parseFloat(item);
});
var squareGridJson = turf.hexGrid(bbox, cellSide);
var areaLayerLayer = L.geoJSON(squareGridJson);
var min = Infinity;
var max = -Infinity;
areaLayerLayer.eachLayer(function(layer){
var center = layer.getBounds().getCenter();
var r = formula(center.lng, center.lat);
if(max < r){
max = r;
}
if(min > r){
min = r;
}
});
var color = chroma.scale(['green', 'yellow', 'red']).domain([min, max]);
var i = 0;
areaLayerLayer.eachLayer(function(l){
var center = l.getBounds().getCenter();
var intersect = turf.intersect(areaLayer.toGeoJSON().features[0], l.toGeoJSON());
if(intersect){
var style = {
color: color(formula(center.lng, center.lat)).hex(),
weight: 0,
fillOpacity: 1
};
l = L.geoJSON(intersect);
l.setStyle(style);
l.addTo(map);
l.bringToBack();
}
i++;
});
</script>
</body>
</html>