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 pathtesteIDW.html
More file actions
160 lines (112 loc) · 5.11 KB
/
Copy pathtesteIDW.html
File metadata and controls
160 lines (112 loc) · 5.11 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
<!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 potencia = 1.5;
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, 0],
// [-53.22138295, -24.29714482, 0],
// [-53.21988196, -24.30127444, 0],
// [-53.21962501, -24.30258456, 0],
// [-53.21918588, -24.29934324, 0],
// [-53.21915521, -24.3033509, 0],
// [-53.21906179, -24.30310445, 0],
// [-53.21816861, -24.30014024, 0],
// [-53.21812818, -24.30138849, 0],
// [-53.21718541, -24.30273996, 0],
// [-53.21702594, -24.3017541, 0],
// [-53.21699119, -24.30197869, 0],
// [-53.21692578, -24.30199683, 0],
// [-53.21661104, -24.29948709, 0],
// [-53.21605175, -24.30151013, 0],
// [-53.21485867, -24.30008093, 0],
// [-53.21446668, -24.29963489, 0],
// [-53.21383935, -24.30166479, 0],
// [-53.21275825, -24.29768951, 0],
// [-53.21216219, -24.29973922, 0],
// [-53.21162634, -24.3017988, 0],
// [-53.21128604, -24.30209445, 0],
[-53.21078907, -24.3026255, 0],
[-53.21045956, -24.30008577, 0],
[-53.21033637, -24.30216756, 0],
[-53.21025036, -24.30004382, 0],
[-53.21018187, -24.30216682, 0],
[-53.21017414, -24.30316423, 0],
[-53.21014091, -24.30005189, 0],
[-53.20999731, -24.30441826, 0],
[-53.20992246, -24.30191171, 0],
[-53.20988271, -24.30019703, 0],
[-53.21988759, -24.30131856,1],
[-53.20994361, -24.30193939,1],
[-53.22167497, -24.30120798,2],
[-53.21927701, -24.29904331,2],
[-53.21797397, -24.30144273,2],
[-53.21681325, -24.29919796,5],
[-53.21412204, -24.29935754,5],
[-53.211794, -24.29950127, 6]
];
var map = L.map('mapid');
pontosComPeso.forEach(function(p){
var marker = L.circleMarker(p.slice(0,2).reverse(), {
radius: 5
}).addTo(map);
marker.bindPopup(p[2] + '');
});
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);
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);
areaLayerLayer.eachLayer(function(l){
var centro = l.getBounds().getCenter();
var primeiroPedacoValorPonto = pontosComPeso.map(function(a){
var contagem = a[2];
var latLng = a.slice(0,2).reverse();
return contagem / Math.pow(centro.distanceTo(latLng), potencia);
}).reduce((a,b) => a+b, 0);
var segundoPedacoValorPonto = pontosComPeso.map(function(a){
var latLng = a.slice(0,2).reverse();
return 1 / Math.pow(centro.distanceTo(latLng), potencia);
}).reduce((a,b) => a+b, 0);
l.valorPonto = primeiroPedacoValorPonto/segundoPedacoValorPonto;
});
var color = chroma.scale(['green', 'yellow', 'red']).domain([1, 2]);
var i = 0;
areaLayerLayer.eachLayer(function(l) {
var intersect = turf.intersect(areaLayer.toGeoJSON().features[0], l.toGeoJSON());
if(intersect){
var style = {
color: color(l.valorPonto).hex(),
weight: 0,
fillOpacity: 1
};
l = L.geoJSON(intersect);
l.setStyle(style);
l.addTo(map);
l.bringToBack();
}
i++;
});
</script>
</body>
</html>