@deck.gl/carto 9.0.21 → 9.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/layer-map.d.ts +4 -6
- package/dist/api/layer-map.d.ts.map +1 -1
- package/dist/api/layer-map.js +16 -17
- package/dist/cartoRasterTile-worker.js +1 -1
- package/dist/cartoSpatialTile-worker.js +1 -1
- package/dist/cartoVectorTile-worker.js +1 -1
- package/dist/dist.dev.js +1982 -1606
- package/dist/index.cjs +747 -517
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/layers/cluster-tile-layer.d.ts +41 -0
- package/dist/layers/cluster-tile-layer.d.ts.map +1 -0
- package/dist/layers/cluster-tile-layer.js +116 -0
- package/dist/layers/cluster-utils.d.ts +30 -0
- package/dist/layers/cluster-utils.d.ts.map +1 -0
- package/dist/layers/cluster-utils.js +122 -0
- package/dist/layers/schema/carto-raster-tile-loader.js +1 -1
- package/dist/layers/schema/carto-spatial-tile-loader.js +1 -1
- package/dist/layers/schema/carto-vector-tile-loader.js +1 -1
- package/dist/style/color-bins-style.d.ts +1 -2
- package/dist/style/color-bins-style.d.ts.map +1 -1
- package/dist/style/color-categories-style.d.ts +1 -2
- package/dist/style/color-categories-style.d.ts.map +1 -1
- package/dist/style/color-continuous-style.d.ts +1 -2
- package/dist/style/color-continuous-style.d.ts.map +1 -1
- package/dist/style/palette.d.ts +1 -1
- package/dist/style/palette.d.ts.map +1 -1
- package/dist.min.js +10 -10
- package/package.json +2 -2
- package/src/api/layer-map.ts +30 -29
- package/src/index.ts +3 -0
- package/src/layers/cluster-tile-layer.ts +218 -0
- package/src/layers/cluster-utils.ts +160 -0
- package/src/style/color-bins-style.ts +2 -2
- package/src/style/color-categories-style.ts +2 -2
- package/src/style/color-continuous-style.ts +2 -2
- package/src/style/palette.ts +1 -2
package/dist/dist.dev.js
CHANGED
|
@@ -41,9 +41,9 @@ var __exports__ = (() => {
|
|
|
41
41
|
));
|
|
42
42
|
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
|
|
43
43
|
|
|
44
|
-
// external-global-plugin:@deck.gl/
|
|
45
|
-
var
|
|
46
|
-
"external-global-plugin:@deck.gl/
|
|
44
|
+
// external-global-plugin:@deck.gl/layers
|
|
45
|
+
var require_layers = __commonJS({
|
|
46
|
+
"external-global-plugin:@deck.gl/layers"(exports, module) {
|
|
47
47
|
module.exports = globalThis.deck;
|
|
48
48
|
}
|
|
49
49
|
});
|
|
@@ -55,1086 +55,1086 @@ var __exports__ = (() => {
|
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
// external-global-plugin
|
|
59
|
-
var
|
|
60
|
-
"external-global-plugin
|
|
61
|
-
module.exports = globalThis.
|
|
58
|
+
// external-global-plugin:@loaders.gl/core
|
|
59
|
+
var require_core = __commonJS({
|
|
60
|
+
"external-global-plugin:@loaders.gl/core"(exports, module) {
|
|
61
|
+
module.exports = globalThis.loaders;
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
// external-global-plugin:@
|
|
65
|
+
// external-global-plugin:@deck.gl/core
|
|
66
66
|
var require_core2 = __commonJS({
|
|
67
|
-
"external-global-plugin:@
|
|
68
|
-
module.exports = globalThis.
|
|
67
|
+
"external-global-plugin:@deck.gl/core"(exports, module) {
|
|
68
|
+
module.exports = globalThis.deck;
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
// ../../node_modules/
|
|
73
|
-
var
|
|
74
|
-
"../../node_modules/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var
|
|
79
|
-
var
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
72
|
+
// ../../node_modules/tilebelt/index.js
|
|
73
|
+
var require_tilebelt = __commonJS({
|
|
74
|
+
"../../node_modules/tilebelt/index.js"(exports, module) {
|
|
75
|
+
var d2r = Math.PI / 180;
|
|
76
|
+
var r2d = 180 / Math.PI;
|
|
77
|
+
function tileToBBOX(tile) {
|
|
78
|
+
var e = tile2lon(tile[0] + 1, tile[2]);
|
|
79
|
+
var w = tile2lon(tile[0], tile[2]);
|
|
80
|
+
var s = tile2lat(tile[1] + 1, tile[2]);
|
|
81
|
+
var n = tile2lat(tile[1], tile[2]);
|
|
82
|
+
return [w, s, e, n];
|
|
83
|
+
}
|
|
84
|
+
function tileToGeoJSON(tile) {
|
|
85
|
+
var bbox = tileToBBOX(tile);
|
|
86
|
+
var poly = {
|
|
87
|
+
type: "Polygon",
|
|
88
|
+
coordinates: [
|
|
89
|
+
[
|
|
90
|
+
[bbox[0], bbox[1]],
|
|
91
|
+
[bbox[0], bbox[3]],
|
|
92
|
+
[bbox[2], bbox[3]],
|
|
93
|
+
[bbox[2], bbox[1]],
|
|
94
|
+
[bbox[0], bbox[1]]
|
|
95
|
+
]
|
|
96
|
+
]
|
|
97
|
+
};
|
|
98
|
+
return poly;
|
|
99
|
+
}
|
|
100
|
+
function tile2lon(x, z) {
|
|
101
|
+
return x / Math.pow(2, z) * 360 - 180;
|
|
102
|
+
}
|
|
103
|
+
function tile2lat(y, z) {
|
|
104
|
+
var n = Math.PI - 2 * Math.PI * y / Math.pow(2, z);
|
|
105
|
+
return r2d * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
|
|
106
|
+
}
|
|
107
|
+
function pointToTile(lon, lat, z) {
|
|
108
|
+
var tile = pointToTileFraction(lon, lat, z);
|
|
109
|
+
tile[0] = Math.floor(tile[0]);
|
|
110
|
+
tile[1] = Math.floor(tile[1]);
|
|
111
|
+
return tile;
|
|
112
|
+
}
|
|
113
|
+
function getChildren(tile) {
|
|
114
|
+
return [
|
|
115
|
+
[tile[0] * 2, tile[1] * 2, tile[2] + 1],
|
|
116
|
+
[tile[0] * 2 + 1, tile[1] * 2, tile[2] + 1],
|
|
117
|
+
[tile[0] * 2 + 1, tile[1] * 2 + 1, tile[2] + 1],
|
|
118
|
+
[tile[0] * 2, tile[1] * 2 + 1, tile[2] + 1]
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
function getParent(tile) {
|
|
122
|
+
if (tile[0] % 2 === 0 && tile[1] % 2 === 0) {
|
|
123
|
+
return [tile[0] / 2, tile[1] / 2, tile[2] - 1];
|
|
124
|
+
} else if (tile[0] % 2 === 0 && !tile[1] % 2 === 0) {
|
|
125
|
+
return [tile[0] / 2, (tile[1] - 1) / 2, tile[2] - 1];
|
|
126
|
+
} else if (!tile[0] % 2 === 0 && tile[1] % 2 === 0) {
|
|
127
|
+
return [(tile[0] - 1) / 2, tile[1] / 2, tile[2] - 1];
|
|
128
|
+
} else {
|
|
129
|
+
return [(tile[0] - 1) / 2, (tile[1] - 1) / 2, tile[2] - 1];
|
|
89
130
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
131
|
+
}
|
|
132
|
+
function getSiblings(tile) {
|
|
133
|
+
return getChildren(getParent(tile));
|
|
134
|
+
}
|
|
135
|
+
function hasSiblings(tile, tiles2) {
|
|
136
|
+
var siblings = getSiblings(tile);
|
|
137
|
+
for (var i = 0; i < siblings.length; i++) {
|
|
138
|
+
if (!hasTile(tiles2, siblings[i]))
|
|
139
|
+
return false;
|
|
94
140
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
e = e - eBias;
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
function hasTile(tiles2, tile) {
|
|
144
|
+
for (var i = 0; i < tiles2.length; i++) {
|
|
145
|
+
if (tilesEqual(tiles2[i], tile))
|
|
146
|
+
return true;
|
|
102
147
|
}
|
|
103
|
-
return
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
var
|
|
110
|
-
var
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
} else {
|
|
119
|
-
e = Math.floor(Math.log(value) / Math.LN2);
|
|
120
|
-
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
121
|
-
e--;
|
|
122
|
-
c *= 2;
|
|
123
|
-
}
|
|
124
|
-
if (e + eBias >= 1) {
|
|
125
|
-
value += rt / c;
|
|
126
|
-
} else {
|
|
127
|
-
value += rt * Math.pow(2, 1 - eBias);
|
|
128
|
-
}
|
|
129
|
-
if (value * c >= 2) {
|
|
130
|
-
e++;
|
|
131
|
-
c /= 2;
|
|
132
|
-
}
|
|
133
|
-
if (e + eBias >= eMax) {
|
|
134
|
-
m = 0;
|
|
135
|
-
e = eMax;
|
|
136
|
-
} else if (e + eBias >= 1) {
|
|
137
|
-
m = (value * c - 1) * Math.pow(2, mLen);
|
|
138
|
-
e = e + eBias;
|
|
139
|
-
} else {
|
|
140
|
-
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
141
|
-
e = 0;
|
|
142
|
-
}
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
function tilesEqual(tile1, tile2) {
|
|
151
|
+
return tile1[0] === tile2[0] && tile1[1] === tile2[1] && tile1[2] === tile2[2];
|
|
152
|
+
}
|
|
153
|
+
function tileToQuadkey(tile) {
|
|
154
|
+
var index2 = "";
|
|
155
|
+
for (var z = tile[2]; z > 0; z--) {
|
|
156
|
+
var b = 0;
|
|
157
|
+
var mask = 1 << z - 1;
|
|
158
|
+
if ((tile[0] & mask) !== 0)
|
|
159
|
+
b++;
|
|
160
|
+
if ((tile[1] & mask) !== 0)
|
|
161
|
+
b += 2;
|
|
162
|
+
index2 += b.toString();
|
|
143
163
|
}
|
|
144
|
-
|
|
164
|
+
return index2;
|
|
165
|
+
}
|
|
166
|
+
function quadkeyToTile(quadkey) {
|
|
167
|
+
var x = 0;
|
|
168
|
+
var y = 0;
|
|
169
|
+
var z = quadkey.length;
|
|
170
|
+
for (var i = z; i > 0; i--) {
|
|
171
|
+
var mask = 1 << i - 1;
|
|
172
|
+
switch (quadkey[z - i]) {
|
|
173
|
+
case "0":
|
|
174
|
+
break;
|
|
175
|
+
case "1":
|
|
176
|
+
x |= mask;
|
|
177
|
+
break;
|
|
178
|
+
case "2":
|
|
179
|
+
y |= mask;
|
|
180
|
+
break;
|
|
181
|
+
case "3":
|
|
182
|
+
x |= mask;
|
|
183
|
+
y |= mask;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
145
186
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
187
|
+
return [x, y, z];
|
|
188
|
+
}
|
|
189
|
+
function bboxToTile(bboxCoords) {
|
|
190
|
+
var min2 = pointToTile(bboxCoords[0], bboxCoords[1], 32);
|
|
191
|
+
var max2 = pointToTile(bboxCoords[2], bboxCoords[3], 32);
|
|
192
|
+
var bbox = [min2[0], min2[1], max2[0], max2[1]];
|
|
193
|
+
var z = getBboxZoom(bbox);
|
|
194
|
+
if (z === 0)
|
|
195
|
+
return [0, 0, 0];
|
|
196
|
+
var x = bbox[0] >>> 32 - z;
|
|
197
|
+
var y = bbox[1] >>> 32 - z;
|
|
198
|
+
return [x, y, z];
|
|
199
|
+
}
|
|
200
|
+
function getBboxZoom(bbox) {
|
|
201
|
+
var MAX_ZOOM = 28;
|
|
202
|
+
for (var z = 0; z < MAX_ZOOM; z++) {
|
|
203
|
+
var mask = 1 << 32 - (z + 1);
|
|
204
|
+
if ((bbox[0] & mask) != (bbox[2] & mask) || (bbox[1] & mask) != (bbox[3] & mask)) {
|
|
205
|
+
return z;
|
|
206
|
+
}
|
|
149
207
|
}
|
|
150
|
-
|
|
208
|
+
return MAX_ZOOM;
|
|
209
|
+
}
|
|
210
|
+
function pointToTileFraction(lon, lat, z) {
|
|
211
|
+
var sin = Math.sin(lat * d2r), z2 = Math.pow(2, z), x = z2 * (lon / 360 + 0.5), y = z2 * (0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI);
|
|
212
|
+
return [x, y, z];
|
|
213
|
+
}
|
|
214
|
+
module.exports = {
|
|
215
|
+
tileToGeoJSON,
|
|
216
|
+
tileToBBOX,
|
|
217
|
+
getChildren,
|
|
218
|
+
getParent,
|
|
219
|
+
getSiblings,
|
|
220
|
+
hasTile,
|
|
221
|
+
hasSiblings,
|
|
222
|
+
tilesEqual,
|
|
223
|
+
tileToQuadkey,
|
|
224
|
+
quadkeyToTile,
|
|
225
|
+
pointToTile,
|
|
226
|
+
bboxToTile,
|
|
227
|
+
pointToTileFraction
|
|
151
228
|
};
|
|
152
229
|
}
|
|
153
230
|
});
|
|
154
231
|
|
|
155
|
-
// ../../node_modules/
|
|
156
|
-
var
|
|
157
|
-
"../../node_modules/
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
this.type = 0;
|
|
165
|
-
this.length = this.buf.length;
|
|
166
|
-
}
|
|
167
|
-
Pbf.Varint = 0;
|
|
168
|
-
Pbf.Fixed64 = 1;
|
|
169
|
-
Pbf.Bytes = 2;
|
|
170
|
-
Pbf.Fixed32 = 5;
|
|
171
|
-
var SHIFT_LEFT_32 = (1 << 16) * (1 << 16);
|
|
172
|
-
var SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
|
|
173
|
-
var TEXT_DECODER_MIN_LENGTH = 12;
|
|
174
|
-
var utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf8");
|
|
175
|
-
Pbf.prototype = {
|
|
176
|
-
destroy: function() {
|
|
177
|
-
this.buf = null;
|
|
178
|
-
},
|
|
179
|
-
readFields: function(readField, result, end) {
|
|
180
|
-
end = end || this.length;
|
|
181
|
-
while (this.pos < end) {
|
|
182
|
-
var val = this.readVarint(), tag = val >> 3, startPos = this.pos;
|
|
183
|
-
this.type = val & 7;
|
|
184
|
-
readField(tag, result, this);
|
|
185
|
-
if (this.pos === startPos)
|
|
186
|
-
this.skip(val);
|
|
187
|
-
}
|
|
188
|
-
return result;
|
|
189
|
-
},
|
|
190
|
-
readMessage: function(readField, result) {
|
|
191
|
-
return this.readFields(readField, result, this.readVarint() + this.pos);
|
|
192
|
-
},
|
|
193
|
-
readFixed32: function() {
|
|
194
|
-
var val = readUInt32(this.buf, this.pos);
|
|
195
|
-
this.pos += 4;
|
|
196
|
-
return val;
|
|
197
|
-
},
|
|
198
|
-
readSFixed32: function() {
|
|
199
|
-
var val = readInt32(this.buf, this.pos);
|
|
200
|
-
this.pos += 4;
|
|
201
|
-
return val;
|
|
202
|
-
},
|
|
203
|
-
readFixed64: function() {
|
|
204
|
-
var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
|
|
205
|
-
this.pos += 8;
|
|
206
|
-
return val;
|
|
207
|
-
},
|
|
208
|
-
readSFixed64: function() {
|
|
209
|
-
var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
|
|
210
|
-
this.pos += 8;
|
|
211
|
-
return val;
|
|
212
|
-
},
|
|
213
|
-
readFloat: function() {
|
|
214
|
-
var val = ieee754.read(this.buf, this.pos, true, 23, 4);
|
|
215
|
-
this.pos += 4;
|
|
216
|
-
return val;
|
|
217
|
-
},
|
|
218
|
-
readDouble: function() {
|
|
219
|
-
var val = ieee754.read(this.buf, this.pos, true, 52, 8);
|
|
220
|
-
this.pos += 8;
|
|
221
|
-
return val;
|
|
222
|
-
},
|
|
223
|
-
readVarint: function(isSigned) {
|
|
224
|
-
var buf = this.buf, val, b;
|
|
225
|
-
b = buf[this.pos++];
|
|
226
|
-
val = b & 127;
|
|
227
|
-
if (b < 128)
|
|
228
|
-
return val;
|
|
229
|
-
b = buf[this.pos++];
|
|
230
|
-
val |= (b & 127) << 7;
|
|
231
|
-
if (b < 128)
|
|
232
|
-
return val;
|
|
233
|
-
b = buf[this.pos++];
|
|
234
|
-
val |= (b & 127) << 14;
|
|
235
|
-
if (b < 128)
|
|
236
|
-
return val;
|
|
237
|
-
b = buf[this.pos++];
|
|
238
|
-
val |= (b & 127) << 21;
|
|
239
|
-
if (b < 128)
|
|
240
|
-
return val;
|
|
241
|
-
b = buf[this.pos];
|
|
242
|
-
val |= (b & 15) << 28;
|
|
243
|
-
return readVarintRemainder(val, isSigned, this);
|
|
244
|
-
},
|
|
245
|
-
readVarint64: function() {
|
|
246
|
-
return this.readVarint(true);
|
|
247
|
-
},
|
|
248
|
-
readSVarint: function() {
|
|
249
|
-
var num = this.readVarint();
|
|
250
|
-
return num % 2 === 1 ? (num + 1) / -2 : num / 2;
|
|
251
|
-
},
|
|
252
|
-
readBoolean: function() {
|
|
253
|
-
return Boolean(this.readVarint());
|
|
254
|
-
},
|
|
255
|
-
readString: function() {
|
|
256
|
-
var end = this.readVarint() + this.pos;
|
|
257
|
-
var pos = this.pos;
|
|
258
|
-
this.pos = end;
|
|
259
|
-
if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {
|
|
260
|
-
return readUtf8TextDecoder(this.buf, pos, end);
|
|
261
|
-
}
|
|
262
|
-
return readUtf8(this.buf, pos, end);
|
|
263
|
-
},
|
|
264
|
-
readBytes: function() {
|
|
265
|
-
var end = this.readVarint() + this.pos, buffer = this.buf.subarray(this.pos, end);
|
|
266
|
-
this.pos = end;
|
|
267
|
-
return buffer;
|
|
268
|
-
},
|
|
269
|
-
readPackedVarint: function(arr, isSigned) {
|
|
270
|
-
if (this.type !== Pbf.Bytes)
|
|
271
|
-
return arr.push(this.readVarint(isSigned));
|
|
272
|
-
var end = readPackedEnd(this);
|
|
273
|
-
arr = arr || [];
|
|
274
|
-
while (this.pos < end)
|
|
275
|
-
arr.push(this.readVarint(isSigned));
|
|
276
|
-
return arr;
|
|
277
|
-
},
|
|
278
|
-
readPackedSVarint: function(arr) {
|
|
279
|
-
if (this.type !== Pbf.Bytes)
|
|
280
|
-
return arr.push(this.readSVarint());
|
|
281
|
-
var end = readPackedEnd(this);
|
|
282
|
-
arr = arr || [];
|
|
283
|
-
while (this.pos < end)
|
|
284
|
-
arr.push(this.readSVarint());
|
|
285
|
-
return arr;
|
|
286
|
-
},
|
|
287
|
-
readPackedBoolean: function(arr) {
|
|
288
|
-
if (this.type !== Pbf.Bytes)
|
|
289
|
-
return arr.push(this.readBoolean());
|
|
290
|
-
var end = readPackedEnd(this);
|
|
291
|
-
arr = arr || [];
|
|
292
|
-
while (this.pos < end)
|
|
293
|
-
arr.push(this.readBoolean());
|
|
294
|
-
return arr;
|
|
295
|
-
},
|
|
296
|
-
readPackedFloat: function(arr) {
|
|
297
|
-
if (this.type !== Pbf.Bytes)
|
|
298
|
-
return arr.push(this.readFloat());
|
|
299
|
-
var end = readPackedEnd(this);
|
|
300
|
-
arr = arr || [];
|
|
301
|
-
while (this.pos < end)
|
|
302
|
-
arr.push(this.readFloat());
|
|
303
|
-
return arr;
|
|
304
|
-
},
|
|
305
|
-
readPackedDouble: function(arr) {
|
|
306
|
-
if (this.type !== Pbf.Bytes)
|
|
307
|
-
return arr.push(this.readDouble());
|
|
308
|
-
var end = readPackedEnd(this);
|
|
309
|
-
arr = arr || [];
|
|
310
|
-
while (this.pos < end)
|
|
311
|
-
arr.push(this.readDouble());
|
|
312
|
-
return arr;
|
|
313
|
-
},
|
|
314
|
-
readPackedFixed32: function(arr) {
|
|
315
|
-
if (this.type !== Pbf.Bytes)
|
|
316
|
-
return arr.push(this.readFixed32());
|
|
317
|
-
var end = readPackedEnd(this);
|
|
318
|
-
arr = arr || [];
|
|
319
|
-
while (this.pos < end)
|
|
320
|
-
arr.push(this.readFixed32());
|
|
321
|
-
return arr;
|
|
322
|
-
},
|
|
323
|
-
readPackedSFixed32: function(arr) {
|
|
324
|
-
if (this.type !== Pbf.Bytes)
|
|
325
|
-
return arr.push(this.readSFixed32());
|
|
326
|
-
var end = readPackedEnd(this);
|
|
327
|
-
arr = arr || [];
|
|
328
|
-
while (this.pos < end)
|
|
329
|
-
arr.push(this.readSFixed32());
|
|
330
|
-
return arr;
|
|
331
|
-
},
|
|
332
|
-
readPackedFixed64: function(arr) {
|
|
333
|
-
if (this.type !== Pbf.Bytes)
|
|
334
|
-
return arr.push(this.readFixed64());
|
|
335
|
-
var end = readPackedEnd(this);
|
|
336
|
-
arr = arr || [];
|
|
337
|
-
while (this.pos < end)
|
|
338
|
-
arr.push(this.readFixed64());
|
|
339
|
-
return arr;
|
|
340
|
-
},
|
|
341
|
-
readPackedSFixed64: function(arr) {
|
|
342
|
-
if (this.type !== Pbf.Bytes)
|
|
343
|
-
return arr.push(this.readSFixed64());
|
|
344
|
-
var end = readPackedEnd(this);
|
|
345
|
-
arr = arr || [];
|
|
346
|
-
while (this.pos < end)
|
|
347
|
-
arr.push(this.readSFixed64());
|
|
348
|
-
return arr;
|
|
349
|
-
},
|
|
350
|
-
skip: function(val) {
|
|
351
|
-
var type = val & 7;
|
|
352
|
-
if (type === Pbf.Varint)
|
|
353
|
-
while (this.buf[this.pos++] > 127) {
|
|
354
|
-
}
|
|
355
|
-
else if (type === Pbf.Bytes)
|
|
356
|
-
this.pos = this.readVarint() + this.pos;
|
|
357
|
-
else if (type === Pbf.Fixed32)
|
|
358
|
-
this.pos += 4;
|
|
359
|
-
else if (type === Pbf.Fixed64)
|
|
360
|
-
this.pos += 8;
|
|
361
|
-
else
|
|
362
|
-
throw new Error("Unimplemented type: " + type);
|
|
363
|
-
},
|
|
364
|
-
writeTag: function(tag, type) {
|
|
365
|
-
this.writeVarint(tag << 3 | type);
|
|
366
|
-
},
|
|
367
|
-
realloc: function(min2) {
|
|
368
|
-
var length = this.length || 16;
|
|
369
|
-
while (length < this.pos + min2)
|
|
370
|
-
length *= 2;
|
|
371
|
-
if (length !== this.length) {
|
|
372
|
-
var buf = new Uint8Array(length);
|
|
373
|
-
buf.set(this.buf);
|
|
374
|
-
this.buf = buf;
|
|
375
|
-
this.length = length;
|
|
376
|
-
}
|
|
377
|
-
},
|
|
378
|
-
finish: function() {
|
|
379
|
-
this.length = this.pos;
|
|
380
|
-
this.pos = 0;
|
|
381
|
-
return this.buf.subarray(0, this.length);
|
|
382
|
-
},
|
|
383
|
-
writeFixed32: function(val) {
|
|
384
|
-
this.realloc(4);
|
|
385
|
-
writeInt32(this.buf, val, this.pos);
|
|
386
|
-
this.pos += 4;
|
|
387
|
-
},
|
|
388
|
-
writeSFixed32: function(val) {
|
|
389
|
-
this.realloc(4);
|
|
390
|
-
writeInt32(this.buf, val, this.pos);
|
|
391
|
-
this.pos += 4;
|
|
392
|
-
},
|
|
393
|
-
writeFixed64: function(val) {
|
|
394
|
-
this.realloc(8);
|
|
395
|
-
writeInt32(this.buf, val & -1, this.pos);
|
|
396
|
-
writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
|
|
397
|
-
this.pos += 8;
|
|
398
|
-
},
|
|
399
|
-
writeSFixed64: function(val) {
|
|
400
|
-
this.realloc(8);
|
|
401
|
-
writeInt32(this.buf, val & -1, this.pos);
|
|
402
|
-
writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
|
|
403
|
-
this.pos += 8;
|
|
404
|
-
},
|
|
405
|
-
writeVarint: function(val) {
|
|
406
|
-
val = +val || 0;
|
|
407
|
-
if (val > 268435455 || val < 0) {
|
|
408
|
-
writeBigVarint(val, this);
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
this.realloc(4);
|
|
412
|
-
this.buf[this.pos++] = val & 127 | (val > 127 ? 128 : 0);
|
|
413
|
-
if (val <= 127)
|
|
414
|
-
return;
|
|
415
|
-
this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
|
|
416
|
-
if (val <= 127)
|
|
417
|
-
return;
|
|
418
|
-
this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
|
|
419
|
-
if (val <= 127)
|
|
420
|
-
return;
|
|
421
|
-
this.buf[this.pos++] = val >>> 7 & 127;
|
|
422
|
-
},
|
|
423
|
-
writeSVarint: function(val) {
|
|
424
|
-
this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
|
|
425
|
-
},
|
|
426
|
-
writeBoolean: function(val) {
|
|
427
|
-
this.writeVarint(Boolean(val));
|
|
428
|
-
},
|
|
429
|
-
writeString: function(str) {
|
|
430
|
-
str = String(str);
|
|
431
|
-
this.realloc(str.length * 4);
|
|
432
|
-
this.pos++;
|
|
433
|
-
var startPos = this.pos;
|
|
434
|
-
this.pos = writeUtf8(this.buf, str, this.pos);
|
|
435
|
-
var len = this.pos - startPos;
|
|
436
|
-
if (len >= 128)
|
|
437
|
-
makeRoomForExtraLength(startPos, len, this);
|
|
438
|
-
this.pos = startPos - 1;
|
|
439
|
-
this.writeVarint(len);
|
|
440
|
-
this.pos += len;
|
|
441
|
-
},
|
|
442
|
-
writeFloat: function(val) {
|
|
443
|
-
this.realloc(4);
|
|
444
|
-
ieee754.write(this.buf, val, this.pos, true, 23, 4);
|
|
445
|
-
this.pos += 4;
|
|
446
|
-
},
|
|
447
|
-
writeDouble: function(val) {
|
|
448
|
-
this.realloc(8);
|
|
449
|
-
ieee754.write(this.buf, val, this.pos, true, 52, 8);
|
|
450
|
-
this.pos += 8;
|
|
451
|
-
},
|
|
452
|
-
writeBytes: function(buffer) {
|
|
453
|
-
var len = buffer.length;
|
|
454
|
-
this.writeVarint(len);
|
|
455
|
-
this.realloc(len);
|
|
456
|
-
for (var i = 0; i < len; i++)
|
|
457
|
-
this.buf[this.pos++] = buffer[i];
|
|
458
|
-
},
|
|
459
|
-
writeRawMessage: function(fn, obj) {
|
|
460
|
-
this.pos++;
|
|
461
|
-
var startPos = this.pos;
|
|
462
|
-
fn(obj, this);
|
|
463
|
-
var len = this.pos - startPos;
|
|
464
|
-
if (len >= 128)
|
|
465
|
-
makeRoomForExtraLength(startPos, len, this);
|
|
466
|
-
this.pos = startPos - 1;
|
|
467
|
-
this.writeVarint(len);
|
|
468
|
-
this.pos += len;
|
|
469
|
-
},
|
|
470
|
-
writeMessage: function(tag, fn, obj) {
|
|
471
|
-
this.writeTag(tag, Pbf.Bytes);
|
|
472
|
-
this.writeRawMessage(fn, obj);
|
|
473
|
-
},
|
|
474
|
-
writePackedVarint: function(tag, arr) {
|
|
475
|
-
if (arr.length)
|
|
476
|
-
this.writeMessage(tag, writePackedVarint, arr);
|
|
477
|
-
},
|
|
478
|
-
writePackedSVarint: function(tag, arr) {
|
|
479
|
-
if (arr.length)
|
|
480
|
-
this.writeMessage(tag, writePackedSVarint, arr);
|
|
481
|
-
},
|
|
482
|
-
writePackedBoolean: function(tag, arr) {
|
|
483
|
-
if (arr.length)
|
|
484
|
-
this.writeMessage(tag, writePackedBoolean, arr);
|
|
485
|
-
},
|
|
486
|
-
writePackedFloat: function(tag, arr) {
|
|
487
|
-
if (arr.length)
|
|
488
|
-
this.writeMessage(tag, writePackedFloat, arr);
|
|
489
|
-
},
|
|
490
|
-
writePackedDouble: function(tag, arr) {
|
|
491
|
-
if (arr.length)
|
|
492
|
-
this.writeMessage(tag, writePackedDouble, arr);
|
|
493
|
-
},
|
|
494
|
-
writePackedFixed32: function(tag, arr) {
|
|
495
|
-
if (arr.length)
|
|
496
|
-
this.writeMessage(tag, writePackedFixed32, arr);
|
|
497
|
-
},
|
|
498
|
-
writePackedSFixed32: function(tag, arr) {
|
|
499
|
-
if (arr.length)
|
|
500
|
-
this.writeMessage(tag, writePackedSFixed32, arr);
|
|
501
|
-
},
|
|
502
|
-
writePackedFixed64: function(tag, arr) {
|
|
503
|
-
if (arr.length)
|
|
504
|
-
this.writeMessage(tag, writePackedFixed64, arr);
|
|
505
|
-
},
|
|
506
|
-
writePackedSFixed64: function(tag, arr) {
|
|
507
|
-
if (arr.length)
|
|
508
|
-
this.writeMessage(tag, writePackedSFixed64, arr);
|
|
509
|
-
},
|
|
510
|
-
writeBytesField: function(tag, buffer) {
|
|
511
|
-
this.writeTag(tag, Pbf.Bytes);
|
|
512
|
-
this.writeBytes(buffer);
|
|
513
|
-
},
|
|
514
|
-
writeFixed32Field: function(tag, val) {
|
|
515
|
-
this.writeTag(tag, Pbf.Fixed32);
|
|
516
|
-
this.writeFixed32(val);
|
|
517
|
-
},
|
|
518
|
-
writeSFixed32Field: function(tag, val) {
|
|
519
|
-
this.writeTag(tag, Pbf.Fixed32);
|
|
520
|
-
this.writeSFixed32(val);
|
|
521
|
-
},
|
|
522
|
-
writeFixed64Field: function(tag, val) {
|
|
523
|
-
this.writeTag(tag, Pbf.Fixed64);
|
|
524
|
-
this.writeFixed64(val);
|
|
525
|
-
},
|
|
526
|
-
writeSFixed64Field: function(tag, val) {
|
|
527
|
-
this.writeTag(tag, Pbf.Fixed64);
|
|
528
|
-
this.writeSFixed64(val);
|
|
529
|
-
},
|
|
530
|
-
writeVarintField: function(tag, val) {
|
|
531
|
-
this.writeTag(tag, Pbf.Varint);
|
|
532
|
-
this.writeVarint(val);
|
|
533
|
-
},
|
|
534
|
-
writeSVarintField: function(tag, val) {
|
|
535
|
-
this.writeTag(tag, Pbf.Varint);
|
|
536
|
-
this.writeSVarint(val);
|
|
537
|
-
},
|
|
538
|
-
writeStringField: function(tag, str) {
|
|
539
|
-
this.writeTag(tag, Pbf.Bytes);
|
|
540
|
-
this.writeString(str);
|
|
541
|
-
},
|
|
542
|
-
writeFloatField: function(tag, val) {
|
|
543
|
-
this.writeTag(tag, Pbf.Fixed32);
|
|
544
|
-
this.writeFloat(val);
|
|
545
|
-
},
|
|
546
|
-
writeDoubleField: function(tag, val) {
|
|
547
|
-
this.writeTag(tag, Pbf.Fixed64);
|
|
548
|
-
this.writeDouble(val);
|
|
549
|
-
},
|
|
550
|
-
writeBooleanField: function(tag, val) {
|
|
551
|
-
this.writeVarintField(tag, Boolean(val));
|
|
552
|
-
}
|
|
232
|
+
// ../../node_modules/@mapbox/tile-cover/index.js
|
|
233
|
+
var require_tile_cover = __commonJS({
|
|
234
|
+
"../../node_modules/@mapbox/tile-cover/index.js"(exports) {
|
|
235
|
+
var tilebelt = require_tilebelt();
|
|
236
|
+
exports.geojson = function(geom, limits) {
|
|
237
|
+
return {
|
|
238
|
+
type: "FeatureCollection",
|
|
239
|
+
features: getTiles(geom, limits).map(tileToFeature)
|
|
240
|
+
};
|
|
553
241
|
};
|
|
554
|
-
function
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
b = buf[p.pos++];
|
|
561
|
-
h |= (b & 127) << 3;
|
|
562
|
-
if (b < 128)
|
|
563
|
-
return toNum(l, h, s);
|
|
564
|
-
b = buf[p.pos++];
|
|
565
|
-
h |= (b & 127) << 10;
|
|
566
|
-
if (b < 128)
|
|
567
|
-
return toNum(l, h, s);
|
|
568
|
-
b = buf[p.pos++];
|
|
569
|
-
h |= (b & 127) << 17;
|
|
570
|
-
if (b < 128)
|
|
571
|
-
return toNum(l, h, s);
|
|
572
|
-
b = buf[p.pos++];
|
|
573
|
-
h |= (b & 127) << 24;
|
|
574
|
-
if (b < 128)
|
|
575
|
-
return toNum(l, h, s);
|
|
576
|
-
b = buf[p.pos++];
|
|
577
|
-
h |= (b & 1) << 31;
|
|
578
|
-
if (b < 128)
|
|
579
|
-
return toNum(l, h, s);
|
|
580
|
-
throw new Error("Expected varint not more than 10 bytes");
|
|
581
|
-
}
|
|
582
|
-
function readPackedEnd(pbf) {
|
|
583
|
-
return pbf.type === Pbf.Bytes ? pbf.readVarint() + pbf.pos : pbf.pos + 1;
|
|
584
|
-
}
|
|
585
|
-
function toNum(low, high, isSigned) {
|
|
586
|
-
if (isSigned) {
|
|
587
|
-
return high * 4294967296 + (low >>> 0);
|
|
588
|
-
}
|
|
589
|
-
return (high >>> 0) * 4294967296 + (low >>> 0);
|
|
242
|
+
function tileToFeature(t) {
|
|
243
|
+
return {
|
|
244
|
+
type: "Feature",
|
|
245
|
+
geometry: tilebelt.tileToGeoJSON(t),
|
|
246
|
+
properties: {}
|
|
247
|
+
};
|
|
590
248
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
high = high + 1 | 0;
|
|
249
|
+
exports.tiles = getTiles;
|
|
250
|
+
exports.indexes = function(geom, limits) {
|
|
251
|
+
return getTiles(geom, limits).map(tilebelt.tileToQuadkey);
|
|
252
|
+
};
|
|
253
|
+
function getTiles(geom, limits) {
|
|
254
|
+
var i, tile, coords = geom.coordinates, maxZoom = limits.max_zoom, tileHash = {}, tiles2 = [];
|
|
255
|
+
if (geom.type === "Point") {
|
|
256
|
+
return [tilebelt.pointToTile(coords[0], coords[1], maxZoom)];
|
|
257
|
+
} else if (geom.type === "MultiPoint") {
|
|
258
|
+
for (i = 0; i < coords.length; i++) {
|
|
259
|
+
tile = tilebelt.pointToTile(coords[i][0], coords[i][1], maxZoom);
|
|
260
|
+
tileHash[toID(tile[0], tile[1], tile[2])] = true;
|
|
604
261
|
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
return;
|
|
632
|
-
pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
|
|
633
|
-
if (!high)
|
|
634
|
-
return;
|
|
635
|
-
pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
|
|
636
|
-
if (!high)
|
|
637
|
-
return;
|
|
638
|
-
pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
|
|
639
|
-
if (!high)
|
|
640
|
-
return;
|
|
641
|
-
pbf.buf[pbf.pos++] = high & 127;
|
|
642
|
-
}
|
|
643
|
-
function makeRoomForExtraLength(startPos, len, pbf) {
|
|
644
|
-
var extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
|
|
645
|
-
pbf.realloc(extraLen);
|
|
646
|
-
for (var i = pbf.pos - 1; i >= startPos; i--)
|
|
647
|
-
pbf.buf[i + extraLen] = pbf.buf[i];
|
|
648
|
-
}
|
|
649
|
-
function writePackedVarint(arr, pbf) {
|
|
650
|
-
for (var i = 0; i < arr.length; i++)
|
|
651
|
-
pbf.writeVarint(arr[i]);
|
|
652
|
-
}
|
|
653
|
-
function writePackedSVarint(arr, pbf) {
|
|
654
|
-
for (var i = 0; i < arr.length; i++)
|
|
655
|
-
pbf.writeSVarint(arr[i]);
|
|
656
|
-
}
|
|
657
|
-
function writePackedFloat(arr, pbf) {
|
|
658
|
-
for (var i = 0; i < arr.length; i++)
|
|
659
|
-
pbf.writeFloat(arr[i]);
|
|
660
|
-
}
|
|
661
|
-
function writePackedDouble(arr, pbf) {
|
|
662
|
-
for (var i = 0; i < arr.length; i++)
|
|
663
|
-
pbf.writeDouble(arr[i]);
|
|
664
|
-
}
|
|
665
|
-
function writePackedBoolean(arr, pbf) {
|
|
666
|
-
for (var i = 0; i < arr.length; i++)
|
|
667
|
-
pbf.writeBoolean(arr[i]);
|
|
262
|
+
} else if (geom.type === "LineString") {
|
|
263
|
+
lineCover(tileHash, coords, maxZoom);
|
|
264
|
+
} else if (geom.type === "MultiLineString") {
|
|
265
|
+
for (i = 0; i < coords.length; i++) {
|
|
266
|
+
lineCover(tileHash, coords[i], maxZoom);
|
|
267
|
+
}
|
|
268
|
+
} else if (geom.type === "Polygon") {
|
|
269
|
+
polygonCover(tileHash, tiles2, coords, maxZoom);
|
|
270
|
+
} else if (geom.type === "MultiPolygon") {
|
|
271
|
+
for (i = 0; i < coords.length; i++) {
|
|
272
|
+
polygonCover(tileHash, tiles2, coords[i], maxZoom);
|
|
273
|
+
}
|
|
274
|
+
} else {
|
|
275
|
+
throw new Error("Geometry type not implemented");
|
|
276
|
+
}
|
|
277
|
+
if (limits.min_zoom !== maxZoom) {
|
|
278
|
+
var len = tiles2.length;
|
|
279
|
+
appendHashTiles(tileHash, tiles2);
|
|
280
|
+
for (i = 0; i < len; i++) {
|
|
281
|
+
var t = tiles2[i];
|
|
282
|
+
tileHash[toID(t[0], t[1], t[2])] = true;
|
|
283
|
+
}
|
|
284
|
+
return mergeTiles(tileHash, tiles2, limits);
|
|
285
|
+
}
|
|
286
|
+
appendHashTiles(tileHash, tiles2);
|
|
287
|
+
return tiles2;
|
|
668
288
|
}
|
|
669
|
-
function
|
|
670
|
-
|
|
671
|
-
|
|
289
|
+
function mergeTiles(tileHash, tiles2, limits) {
|
|
290
|
+
var mergedTiles = [];
|
|
291
|
+
for (var z = limits.max_zoom; z > limits.min_zoom; z--) {
|
|
292
|
+
var parentTileHash = {};
|
|
293
|
+
var parentTiles = [];
|
|
294
|
+
for (var i = 0; i < tiles2.length; i++) {
|
|
295
|
+
var t = tiles2[i];
|
|
296
|
+
if (t[0] % 2 === 0 && t[1] % 2 === 0) {
|
|
297
|
+
var id22 = toID(t[0] + 1, t[1], z), id32 = toID(t[0], t[1] + 1, z), id4 = toID(t[0] + 1, t[1] + 1, z);
|
|
298
|
+
if (tileHash[id22] && tileHash[id32] && tileHash[id4]) {
|
|
299
|
+
tileHash[toID(t[0], t[1], t[2])] = false;
|
|
300
|
+
tileHash[id22] = false;
|
|
301
|
+
tileHash[id32] = false;
|
|
302
|
+
tileHash[id4] = false;
|
|
303
|
+
var parentTile = [t[0] / 2, t[1] / 2, z - 1];
|
|
304
|
+
if (z - 1 === limits.min_zoom)
|
|
305
|
+
mergedTiles.push(parentTile);
|
|
306
|
+
else {
|
|
307
|
+
parentTileHash[toID(t[0] / 2, t[1] / 2, z - 1)] = true;
|
|
308
|
+
parentTiles.push(parentTile);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
for (i = 0; i < tiles2.length; i++) {
|
|
314
|
+
t = tiles2[i];
|
|
315
|
+
if (tileHash[toID(t[0], t[1], t[2])])
|
|
316
|
+
mergedTiles.push(t);
|
|
317
|
+
}
|
|
318
|
+
tileHash = parentTileHash;
|
|
319
|
+
tiles2 = parentTiles;
|
|
320
|
+
}
|
|
321
|
+
return mergedTiles;
|
|
672
322
|
}
|
|
673
|
-
function
|
|
674
|
-
|
|
675
|
-
|
|
323
|
+
function polygonCover(tileHash, tileArray, geom, zoom) {
|
|
324
|
+
var intersections = [];
|
|
325
|
+
for (var i = 0; i < geom.length; i++) {
|
|
326
|
+
var ring = [];
|
|
327
|
+
lineCover(tileHash, geom[i], zoom, ring);
|
|
328
|
+
for (var j = 0, len = ring.length, k = len - 1; j < len; k = j++) {
|
|
329
|
+
var m = (j + 1) % len;
|
|
330
|
+
var y = ring[j][1];
|
|
331
|
+
if ((y > ring[k][1] || y > ring[m][1]) && (y < ring[k][1] || y < ring[m][1]) && y !== ring[m][1])
|
|
332
|
+
intersections.push(ring[j]);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
intersections.sort(compareTiles);
|
|
336
|
+
for (i = 0; i < intersections.length; i += 2) {
|
|
337
|
+
y = intersections[i][1];
|
|
338
|
+
for (var x = intersections[i][0] + 1; x < intersections[i + 1][0]; x++) {
|
|
339
|
+
var id4 = toID(x, y, zoom);
|
|
340
|
+
if (!tileHash[id4]) {
|
|
341
|
+
tileArray.push([x, y, zoom]);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
676
345
|
}
|
|
677
|
-
function
|
|
678
|
-
|
|
679
|
-
pbf.writeFixed64(arr[i]);
|
|
346
|
+
function compareTiles(a, b) {
|
|
347
|
+
return a[1] - b[1] || a[0] - b[0];
|
|
680
348
|
}
|
|
681
|
-
function
|
|
682
|
-
|
|
683
|
-
|
|
349
|
+
function lineCover(tileHash, coords, maxZoom, ring) {
|
|
350
|
+
var prevX, prevY;
|
|
351
|
+
for (var i = 0; i < coords.length - 1; i++) {
|
|
352
|
+
var start = tilebelt.pointToTileFraction(coords[i][0], coords[i][1], maxZoom), stop = tilebelt.pointToTileFraction(coords[i + 1][0], coords[i + 1][1], maxZoom), x0 = start[0], y0 = start[1], x1 = stop[0], y1 = stop[1], dx = x1 - x0, dy = y1 - y0;
|
|
353
|
+
if (dy === 0 && dx === 0)
|
|
354
|
+
continue;
|
|
355
|
+
var sx = dx > 0 ? 1 : -1, sy = dy > 0 ? 1 : -1, x = Math.floor(x0), y = Math.floor(y0), tMaxX = dx === 0 ? Infinity : Math.abs(((dx > 0 ? 1 : 0) + x - x0) / dx), tMaxY = dy === 0 ? Infinity : Math.abs(((dy > 0 ? 1 : 0) + y - y0) / dy), tdx = Math.abs(sx / dx), tdy = Math.abs(sy / dy);
|
|
356
|
+
if (x !== prevX || y !== prevY) {
|
|
357
|
+
tileHash[toID(x, y, maxZoom)] = true;
|
|
358
|
+
if (ring && y !== prevY)
|
|
359
|
+
ring.push([x, y]);
|
|
360
|
+
prevX = x;
|
|
361
|
+
prevY = y;
|
|
362
|
+
}
|
|
363
|
+
while (tMaxX < 1 || tMaxY < 1) {
|
|
364
|
+
if (tMaxX < tMaxY) {
|
|
365
|
+
tMaxX += tdx;
|
|
366
|
+
x += sx;
|
|
367
|
+
} else {
|
|
368
|
+
tMaxY += tdy;
|
|
369
|
+
y += sy;
|
|
370
|
+
}
|
|
371
|
+
tileHash[toID(x, y, maxZoom)] = true;
|
|
372
|
+
if (ring && y !== prevY)
|
|
373
|
+
ring.push([x, y]);
|
|
374
|
+
prevX = x;
|
|
375
|
+
prevY = y;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
if (ring && y === ring[0][1])
|
|
379
|
+
ring.pop();
|
|
684
380
|
}
|
|
685
|
-
function
|
|
686
|
-
|
|
381
|
+
function appendHashTiles(hash, tiles2) {
|
|
382
|
+
var keys = Object.keys(hash);
|
|
383
|
+
for (var i = 0; i < keys.length; i++) {
|
|
384
|
+
tiles2.push(fromID(+keys[i]));
|
|
385
|
+
}
|
|
687
386
|
}
|
|
688
|
-
function
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
buf[pos + 2] = val >>> 16;
|
|
692
|
-
buf[pos + 3] = val >>> 24;
|
|
387
|
+
function toID(x, y, z) {
|
|
388
|
+
var dim = 2 * (1 << z);
|
|
389
|
+
return (dim * y + x) * 32 + z;
|
|
693
390
|
}
|
|
694
|
-
function
|
|
695
|
-
|
|
391
|
+
function fromID(id4) {
|
|
392
|
+
var z = id4 % 32, dim = 2 * (1 << z), xy = (id4 - z) / 32, x = xy % dim, y = (xy - x) / dim % dim;
|
|
393
|
+
return [x, y, z];
|
|
696
394
|
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
// ../../node_modules/ieee754/index.js
|
|
399
|
+
var require_ieee754 = __commonJS({
|
|
400
|
+
"../../node_modules/ieee754/index.js"(exports) {
|
|
401
|
+
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
|
|
402
|
+
var e, m;
|
|
403
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
404
|
+
var eMax = (1 << eLen) - 1;
|
|
405
|
+
var eBias = eMax >> 1;
|
|
406
|
+
var nBits = -7;
|
|
407
|
+
var i = isLE ? nBytes - 1 : 0;
|
|
408
|
+
var d = isLE ? -1 : 1;
|
|
409
|
+
var s = buffer[offset + i];
|
|
410
|
+
i += d;
|
|
411
|
+
e = s & (1 << -nBits) - 1;
|
|
412
|
+
s >>= -nBits;
|
|
413
|
+
nBits += eLen;
|
|
414
|
+
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
415
|
+
}
|
|
416
|
+
m = e & (1 << -nBits) - 1;
|
|
417
|
+
e >>= -nBits;
|
|
418
|
+
nBits += mLen;
|
|
419
|
+
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
420
|
+
}
|
|
421
|
+
if (e === 0) {
|
|
422
|
+
e = 1 - eBias;
|
|
423
|
+
} else if (e === eMax) {
|
|
424
|
+
return m ? NaN : (s ? -1 : 1) * Infinity;
|
|
425
|
+
} else {
|
|
426
|
+
m = m + Math.pow(2, mLen);
|
|
427
|
+
e = e - eBias;
|
|
428
|
+
}
|
|
429
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
430
|
+
};
|
|
431
|
+
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
|
|
432
|
+
var e, m, c;
|
|
433
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
434
|
+
var eMax = (1 << eLen) - 1;
|
|
435
|
+
var eBias = eMax >> 1;
|
|
436
|
+
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
|
|
437
|
+
var i = isLE ? 0 : nBytes - 1;
|
|
438
|
+
var d = isLE ? 1 : -1;
|
|
439
|
+
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
|
440
|
+
value = Math.abs(value);
|
|
441
|
+
if (isNaN(value) || value === Infinity) {
|
|
442
|
+
m = isNaN(value) ? 1 : 0;
|
|
443
|
+
e = eMax;
|
|
444
|
+
} else {
|
|
445
|
+
e = Math.floor(Math.log(value) / Math.LN2);
|
|
446
|
+
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
447
|
+
e--;
|
|
448
|
+
c *= 2;
|
|
738
449
|
}
|
|
739
|
-
if (
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
450
|
+
if (e + eBias >= 1) {
|
|
451
|
+
value += rt / c;
|
|
452
|
+
} else {
|
|
453
|
+
value += rt * Math.pow(2, 1 - eBias);
|
|
454
|
+
}
|
|
455
|
+
if (value * c >= 2) {
|
|
456
|
+
e++;
|
|
457
|
+
c /= 2;
|
|
458
|
+
}
|
|
459
|
+
if (e + eBias >= eMax) {
|
|
460
|
+
m = 0;
|
|
461
|
+
e = eMax;
|
|
462
|
+
} else if (e + eBias >= 1) {
|
|
463
|
+
m = (value * c - 1) * Math.pow(2, mLen);
|
|
464
|
+
e = e + eBias;
|
|
465
|
+
} else {
|
|
466
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
467
|
+
e = 0;
|
|
746
468
|
}
|
|
747
|
-
str += String.fromCharCode(c);
|
|
748
|
-
i += bytesPerSequence;
|
|
749
469
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
470
|
+
for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
|
|
471
|
+
}
|
|
472
|
+
e = e << mLen | m;
|
|
473
|
+
eLen += mLen;
|
|
474
|
+
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
|
|
475
|
+
}
|
|
476
|
+
buffer[offset + i - d] |= s * 128;
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
// ../../node_modules/pbf/index.js
|
|
482
|
+
var require_pbf = __commonJS({
|
|
483
|
+
"../../node_modules/pbf/index.js"(exports, module) {
|
|
484
|
+
"use strict";
|
|
485
|
+
module.exports = Pbf;
|
|
486
|
+
var ieee754 = require_ieee754();
|
|
487
|
+
function Pbf(buf) {
|
|
488
|
+
this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);
|
|
489
|
+
this.pos = 0;
|
|
490
|
+
this.type = 0;
|
|
491
|
+
this.length = this.buf.length;
|
|
754
492
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
493
|
+
Pbf.Varint = 0;
|
|
494
|
+
Pbf.Fixed64 = 1;
|
|
495
|
+
Pbf.Bytes = 2;
|
|
496
|
+
Pbf.Fixed32 = 5;
|
|
497
|
+
var SHIFT_LEFT_32 = (1 << 16) * (1 << 16);
|
|
498
|
+
var SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
|
|
499
|
+
var TEXT_DECODER_MIN_LENGTH = 12;
|
|
500
|
+
var utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf8");
|
|
501
|
+
Pbf.prototype = {
|
|
502
|
+
destroy: function() {
|
|
503
|
+
this.buf = null;
|
|
504
|
+
},
|
|
505
|
+
readFields: function(readField, result, end) {
|
|
506
|
+
end = end || this.length;
|
|
507
|
+
while (this.pos < end) {
|
|
508
|
+
var val = this.readVarint(), tag = val >> 3, startPos = this.pos;
|
|
509
|
+
this.type = val & 7;
|
|
510
|
+
readField(tag, result, this);
|
|
511
|
+
if (this.pos === startPos)
|
|
512
|
+
this.skip(val);
|
|
513
|
+
}
|
|
514
|
+
return result;
|
|
515
|
+
},
|
|
516
|
+
readMessage: function(readField, result) {
|
|
517
|
+
return this.readFields(readField, result, this.readVarint() + this.pos);
|
|
518
|
+
},
|
|
519
|
+
readFixed32: function() {
|
|
520
|
+
var val = readUInt32(this.buf, this.pos);
|
|
521
|
+
this.pos += 4;
|
|
522
|
+
return val;
|
|
523
|
+
},
|
|
524
|
+
readSFixed32: function() {
|
|
525
|
+
var val = readInt32(this.buf, this.pos);
|
|
526
|
+
this.pos += 4;
|
|
527
|
+
return val;
|
|
528
|
+
},
|
|
529
|
+
readFixed64: function() {
|
|
530
|
+
var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
|
|
531
|
+
this.pos += 8;
|
|
532
|
+
return val;
|
|
533
|
+
},
|
|
534
|
+
readSFixed64: function() {
|
|
535
|
+
var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
|
|
536
|
+
this.pos += 8;
|
|
537
|
+
return val;
|
|
538
|
+
},
|
|
539
|
+
readFloat: function() {
|
|
540
|
+
var val = ieee754.read(this.buf, this.pos, true, 23, 4);
|
|
541
|
+
this.pos += 4;
|
|
542
|
+
return val;
|
|
543
|
+
},
|
|
544
|
+
readDouble: function() {
|
|
545
|
+
var val = ieee754.read(this.buf, this.pos, true, 52, 8);
|
|
546
|
+
this.pos += 8;
|
|
547
|
+
return val;
|
|
548
|
+
},
|
|
549
|
+
readVarint: function(isSigned) {
|
|
550
|
+
var buf = this.buf, val, b;
|
|
551
|
+
b = buf[this.pos++];
|
|
552
|
+
val = b & 127;
|
|
553
|
+
if (b < 128)
|
|
554
|
+
return val;
|
|
555
|
+
b = buf[this.pos++];
|
|
556
|
+
val |= (b & 127) << 7;
|
|
557
|
+
if (b < 128)
|
|
558
|
+
return val;
|
|
559
|
+
b = buf[this.pos++];
|
|
560
|
+
val |= (b & 127) << 14;
|
|
561
|
+
if (b < 128)
|
|
562
|
+
return val;
|
|
563
|
+
b = buf[this.pos++];
|
|
564
|
+
val |= (b & 127) << 21;
|
|
565
|
+
if (b < 128)
|
|
566
|
+
return val;
|
|
567
|
+
b = buf[this.pos];
|
|
568
|
+
val |= (b & 15) << 28;
|
|
569
|
+
return readVarintRemainder(val, isSigned, this);
|
|
570
|
+
},
|
|
571
|
+
readVarint64: function() {
|
|
572
|
+
return this.readVarint(true);
|
|
573
|
+
},
|
|
574
|
+
readSVarint: function() {
|
|
575
|
+
var num = this.readVarint();
|
|
576
|
+
return num % 2 === 1 ? (num + 1) / -2 : num / 2;
|
|
577
|
+
},
|
|
578
|
+
readBoolean: function() {
|
|
579
|
+
return Boolean(this.readVarint());
|
|
580
|
+
},
|
|
581
|
+
readString: function() {
|
|
582
|
+
var end = this.readVarint() + this.pos;
|
|
583
|
+
var pos = this.pos;
|
|
584
|
+
this.pos = end;
|
|
585
|
+
if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {
|
|
586
|
+
return readUtf8TextDecoder(this.buf, pos, end);
|
|
587
|
+
}
|
|
588
|
+
return readUtf8(this.buf, pos, end);
|
|
589
|
+
},
|
|
590
|
+
readBytes: function() {
|
|
591
|
+
var end = this.readVarint() + this.pos, buffer = this.buf.subarray(this.pos, end);
|
|
592
|
+
this.pos = end;
|
|
593
|
+
return buffer;
|
|
594
|
+
},
|
|
595
|
+
readPackedVarint: function(arr, isSigned) {
|
|
596
|
+
if (this.type !== Pbf.Bytes)
|
|
597
|
+
return arr.push(this.readVarint(isSigned));
|
|
598
|
+
var end = readPackedEnd(this);
|
|
599
|
+
arr = arr || [];
|
|
600
|
+
while (this.pos < end)
|
|
601
|
+
arr.push(this.readVarint(isSigned));
|
|
602
|
+
return arr;
|
|
603
|
+
},
|
|
604
|
+
readPackedSVarint: function(arr) {
|
|
605
|
+
if (this.type !== Pbf.Bytes)
|
|
606
|
+
return arr.push(this.readSVarint());
|
|
607
|
+
var end = readPackedEnd(this);
|
|
608
|
+
arr = arr || [];
|
|
609
|
+
while (this.pos < end)
|
|
610
|
+
arr.push(this.readSVarint());
|
|
611
|
+
return arr;
|
|
612
|
+
},
|
|
613
|
+
readPackedBoolean: function(arr) {
|
|
614
|
+
if (this.type !== Pbf.Bytes)
|
|
615
|
+
return arr.push(this.readBoolean());
|
|
616
|
+
var end = readPackedEnd(this);
|
|
617
|
+
arr = arr || [];
|
|
618
|
+
while (this.pos < end)
|
|
619
|
+
arr.push(this.readBoolean());
|
|
620
|
+
return arr;
|
|
621
|
+
},
|
|
622
|
+
readPackedFloat: function(arr) {
|
|
623
|
+
if (this.type !== Pbf.Bytes)
|
|
624
|
+
return arr.push(this.readFloat());
|
|
625
|
+
var end = readPackedEnd(this);
|
|
626
|
+
arr = arr || [];
|
|
627
|
+
while (this.pos < end)
|
|
628
|
+
arr.push(this.readFloat());
|
|
629
|
+
return arr;
|
|
630
|
+
},
|
|
631
|
+
readPackedDouble: function(arr) {
|
|
632
|
+
if (this.type !== Pbf.Bytes)
|
|
633
|
+
return arr.push(this.readDouble());
|
|
634
|
+
var end = readPackedEnd(this);
|
|
635
|
+
arr = arr || [];
|
|
636
|
+
while (this.pos < end)
|
|
637
|
+
arr.push(this.readDouble());
|
|
638
|
+
return arr;
|
|
639
|
+
},
|
|
640
|
+
readPackedFixed32: function(arr) {
|
|
641
|
+
if (this.type !== Pbf.Bytes)
|
|
642
|
+
return arr.push(this.readFixed32());
|
|
643
|
+
var end = readPackedEnd(this);
|
|
644
|
+
arr = arr || [];
|
|
645
|
+
while (this.pos < end)
|
|
646
|
+
arr.push(this.readFixed32());
|
|
647
|
+
return arr;
|
|
648
|
+
},
|
|
649
|
+
readPackedSFixed32: function(arr) {
|
|
650
|
+
if (this.type !== Pbf.Bytes)
|
|
651
|
+
return arr.push(this.readSFixed32());
|
|
652
|
+
var end = readPackedEnd(this);
|
|
653
|
+
arr = arr || [];
|
|
654
|
+
while (this.pos < end)
|
|
655
|
+
arr.push(this.readSFixed32());
|
|
656
|
+
return arr;
|
|
657
|
+
},
|
|
658
|
+
readPackedFixed64: function(arr) {
|
|
659
|
+
if (this.type !== Pbf.Bytes)
|
|
660
|
+
return arr.push(this.readFixed64());
|
|
661
|
+
var end = readPackedEnd(this);
|
|
662
|
+
arr = arr || [];
|
|
663
|
+
while (this.pos < end)
|
|
664
|
+
arr.push(this.readFixed64());
|
|
665
|
+
return arr;
|
|
666
|
+
},
|
|
667
|
+
readPackedSFixed64: function(arr) {
|
|
668
|
+
if (this.type !== Pbf.Bytes)
|
|
669
|
+
return arr.push(this.readSFixed64());
|
|
670
|
+
var end = readPackedEnd(this);
|
|
671
|
+
arr = arr || [];
|
|
672
|
+
while (this.pos < end)
|
|
673
|
+
arr.push(this.readSFixed64());
|
|
674
|
+
return arr;
|
|
675
|
+
},
|
|
676
|
+
skip: function(val) {
|
|
677
|
+
var type = val & 7;
|
|
678
|
+
if (type === Pbf.Varint)
|
|
679
|
+
while (this.buf[this.pos++] > 127) {
|
|
779
680
|
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
681
|
+
else if (type === Pbf.Bytes)
|
|
682
|
+
this.pos = this.readVarint() + this.pos;
|
|
683
|
+
else if (type === Pbf.Fixed32)
|
|
684
|
+
this.pos += 4;
|
|
685
|
+
else if (type === Pbf.Fixed64)
|
|
686
|
+
this.pos += 8;
|
|
687
|
+
else
|
|
688
|
+
throw new Error("Unimplemented type: " + type);
|
|
689
|
+
},
|
|
690
|
+
writeTag: function(tag, type) {
|
|
691
|
+
this.writeVarint(tag << 3 | type);
|
|
692
|
+
},
|
|
693
|
+
realloc: function(min2) {
|
|
694
|
+
var length = this.length || 16;
|
|
695
|
+
while (length < this.pos + min2)
|
|
696
|
+
length *= 2;
|
|
697
|
+
if (length !== this.length) {
|
|
698
|
+
var buf = new Uint8Array(length);
|
|
699
|
+
buf.set(this.buf);
|
|
700
|
+
this.buf = buf;
|
|
701
|
+
this.length = length;
|
|
785
702
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
703
|
+
},
|
|
704
|
+
finish: function() {
|
|
705
|
+
this.length = this.pos;
|
|
706
|
+
this.pos = 0;
|
|
707
|
+
return this.buf.subarray(0, this.length);
|
|
708
|
+
},
|
|
709
|
+
writeFixed32: function(val) {
|
|
710
|
+
this.realloc(4);
|
|
711
|
+
writeInt32(this.buf, val, this.pos);
|
|
712
|
+
this.pos += 4;
|
|
713
|
+
},
|
|
714
|
+
writeSFixed32: function(val) {
|
|
715
|
+
this.realloc(4);
|
|
716
|
+
writeInt32(this.buf, val, this.pos);
|
|
717
|
+
this.pos += 4;
|
|
718
|
+
},
|
|
719
|
+
writeFixed64: function(val) {
|
|
720
|
+
this.realloc(8);
|
|
721
|
+
writeInt32(this.buf, val & -1, this.pos);
|
|
722
|
+
writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
|
|
723
|
+
this.pos += 8;
|
|
724
|
+
},
|
|
725
|
+
writeSFixed64: function(val) {
|
|
726
|
+
this.realloc(8);
|
|
727
|
+
writeInt32(this.buf, val & -1, this.pos);
|
|
728
|
+
writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
|
|
729
|
+
this.pos += 8;
|
|
730
|
+
},
|
|
731
|
+
writeVarint: function(val) {
|
|
732
|
+
val = +val || 0;
|
|
733
|
+
if (val > 268435455 || val < 0) {
|
|
734
|
+
writeBigVarint(val, this);
|
|
735
|
+
return;
|
|
801
736
|
}
|
|
737
|
+
this.realloc(4);
|
|
738
|
+
this.buf[this.pos++] = val & 127 | (val > 127 ? 128 : 0);
|
|
739
|
+
if (val <= 127)
|
|
740
|
+
return;
|
|
741
|
+
this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
|
|
742
|
+
if (val <= 127)
|
|
743
|
+
return;
|
|
744
|
+
this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
|
|
745
|
+
if (val <= 127)
|
|
746
|
+
return;
|
|
747
|
+
this.buf[this.pos++] = val >>> 7 & 127;
|
|
748
|
+
},
|
|
749
|
+
writeSVarint: function(val) {
|
|
750
|
+
this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
|
|
751
|
+
},
|
|
752
|
+
writeBoolean: function(val) {
|
|
753
|
+
this.writeVarint(Boolean(val));
|
|
754
|
+
},
|
|
755
|
+
writeString: function(str) {
|
|
756
|
+
str = String(str);
|
|
757
|
+
this.realloc(str.length * 4);
|
|
758
|
+
this.pos++;
|
|
759
|
+
var startPos = this.pos;
|
|
760
|
+
this.pos = writeUtf8(this.buf, str, this.pos);
|
|
761
|
+
var len = this.pos - startPos;
|
|
762
|
+
if (len >= 128)
|
|
763
|
+
makeRoomForExtraLength(startPos, len, this);
|
|
764
|
+
this.pos = startPos - 1;
|
|
765
|
+
this.writeVarint(len);
|
|
766
|
+
this.pos += len;
|
|
767
|
+
},
|
|
768
|
+
writeFloat: function(val) {
|
|
769
|
+
this.realloc(4);
|
|
770
|
+
ieee754.write(this.buf, val, this.pos, true, 23, 4);
|
|
771
|
+
this.pos += 4;
|
|
772
|
+
},
|
|
773
|
+
writeDouble: function(val) {
|
|
774
|
+
this.realloc(8);
|
|
775
|
+
ieee754.write(this.buf, val, this.pos, true, 52, 8);
|
|
776
|
+
this.pos += 8;
|
|
777
|
+
},
|
|
778
|
+
writeBytes: function(buffer) {
|
|
779
|
+
var len = buffer.length;
|
|
780
|
+
this.writeVarint(len);
|
|
781
|
+
this.realloc(len);
|
|
782
|
+
for (var i = 0; i < len; i++)
|
|
783
|
+
this.buf[this.pos++] = buffer[i];
|
|
784
|
+
},
|
|
785
|
+
writeRawMessage: function(fn, obj) {
|
|
786
|
+
this.pos++;
|
|
787
|
+
var startPos = this.pos;
|
|
788
|
+
fn(obj, this);
|
|
789
|
+
var len = this.pos - startPos;
|
|
790
|
+
if (len >= 128)
|
|
791
|
+
makeRoomForExtraLength(startPos, len, this);
|
|
792
|
+
this.pos = startPos - 1;
|
|
793
|
+
this.writeVarint(len);
|
|
794
|
+
this.pos += len;
|
|
795
|
+
},
|
|
796
|
+
writeMessage: function(tag, fn, obj) {
|
|
797
|
+
this.writeTag(tag, Pbf.Bytes);
|
|
798
|
+
this.writeRawMessage(fn, obj);
|
|
799
|
+
},
|
|
800
|
+
writePackedVarint: function(tag, arr) {
|
|
801
|
+
if (arr.length)
|
|
802
|
+
this.writeMessage(tag, writePackedVarint, arr);
|
|
803
|
+
},
|
|
804
|
+
writePackedSVarint: function(tag, arr) {
|
|
805
|
+
if (arr.length)
|
|
806
|
+
this.writeMessage(tag, writePackedSVarint, arr);
|
|
807
|
+
},
|
|
808
|
+
writePackedBoolean: function(tag, arr) {
|
|
809
|
+
if (arr.length)
|
|
810
|
+
this.writeMessage(tag, writePackedBoolean, arr);
|
|
811
|
+
},
|
|
812
|
+
writePackedFloat: function(tag, arr) {
|
|
813
|
+
if (arr.length)
|
|
814
|
+
this.writeMessage(tag, writePackedFloat, arr);
|
|
815
|
+
},
|
|
816
|
+
writePackedDouble: function(tag, arr) {
|
|
817
|
+
if (arr.length)
|
|
818
|
+
this.writeMessage(tag, writePackedDouble, arr);
|
|
819
|
+
},
|
|
820
|
+
writePackedFixed32: function(tag, arr) {
|
|
821
|
+
if (arr.length)
|
|
822
|
+
this.writeMessage(tag, writePackedFixed32, arr);
|
|
823
|
+
},
|
|
824
|
+
writePackedSFixed32: function(tag, arr) {
|
|
825
|
+
if (arr.length)
|
|
826
|
+
this.writeMessage(tag, writePackedSFixed32, arr);
|
|
827
|
+
},
|
|
828
|
+
writePackedFixed64: function(tag, arr) {
|
|
829
|
+
if (arr.length)
|
|
830
|
+
this.writeMessage(tag, writePackedFixed64, arr);
|
|
831
|
+
},
|
|
832
|
+
writePackedSFixed64: function(tag, arr) {
|
|
833
|
+
if (arr.length)
|
|
834
|
+
this.writeMessage(tag, writePackedSFixed64, arr);
|
|
835
|
+
},
|
|
836
|
+
writeBytesField: function(tag, buffer) {
|
|
837
|
+
this.writeTag(tag, Pbf.Bytes);
|
|
838
|
+
this.writeBytes(buffer);
|
|
839
|
+
},
|
|
840
|
+
writeFixed32Field: function(tag, val) {
|
|
841
|
+
this.writeTag(tag, Pbf.Fixed32);
|
|
842
|
+
this.writeFixed32(val);
|
|
843
|
+
},
|
|
844
|
+
writeSFixed32Field: function(tag, val) {
|
|
845
|
+
this.writeTag(tag, Pbf.Fixed32);
|
|
846
|
+
this.writeSFixed32(val);
|
|
847
|
+
},
|
|
848
|
+
writeFixed64Field: function(tag, val) {
|
|
849
|
+
this.writeTag(tag, Pbf.Fixed64);
|
|
850
|
+
this.writeFixed64(val);
|
|
851
|
+
},
|
|
852
|
+
writeSFixed64Field: function(tag, val) {
|
|
853
|
+
this.writeTag(tag, Pbf.Fixed64);
|
|
854
|
+
this.writeSFixed64(val);
|
|
855
|
+
},
|
|
856
|
+
writeVarintField: function(tag, val) {
|
|
857
|
+
this.writeTag(tag, Pbf.Varint);
|
|
858
|
+
this.writeVarint(val);
|
|
859
|
+
},
|
|
860
|
+
writeSVarintField: function(tag, val) {
|
|
861
|
+
this.writeTag(tag, Pbf.Varint);
|
|
862
|
+
this.writeSVarint(val);
|
|
863
|
+
},
|
|
864
|
+
writeStringField: function(tag, str) {
|
|
865
|
+
this.writeTag(tag, Pbf.Bytes);
|
|
866
|
+
this.writeString(str);
|
|
867
|
+
},
|
|
868
|
+
writeFloatField: function(tag, val) {
|
|
869
|
+
this.writeTag(tag, Pbf.Fixed32);
|
|
870
|
+
this.writeFloat(val);
|
|
871
|
+
},
|
|
872
|
+
writeDoubleField: function(tag, val) {
|
|
873
|
+
this.writeTag(tag, Pbf.Fixed64);
|
|
874
|
+
this.writeDouble(val);
|
|
875
|
+
},
|
|
876
|
+
writeBooleanField: function(tag, val) {
|
|
877
|
+
this.writeVarintField(tag, Boolean(val));
|
|
802
878
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
]
|
|
832
|
-
]
|
|
833
|
-
};
|
|
834
|
-
return poly;
|
|
835
|
-
}
|
|
836
|
-
function tile2lon(x, z) {
|
|
837
|
-
return x / Math.pow(2, z) * 360 - 180;
|
|
838
|
-
}
|
|
839
|
-
function tile2lat(y, z) {
|
|
840
|
-
var n = Math.PI - 2 * Math.PI * y / Math.pow(2, z);
|
|
841
|
-
return r2d * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
|
|
879
|
+
};
|
|
880
|
+
function readVarintRemainder(l, s, p) {
|
|
881
|
+
var buf = p.buf, h, b;
|
|
882
|
+
b = buf[p.pos++];
|
|
883
|
+
h = (b & 112) >> 4;
|
|
884
|
+
if (b < 128)
|
|
885
|
+
return toNum(l, h, s);
|
|
886
|
+
b = buf[p.pos++];
|
|
887
|
+
h |= (b & 127) << 3;
|
|
888
|
+
if (b < 128)
|
|
889
|
+
return toNum(l, h, s);
|
|
890
|
+
b = buf[p.pos++];
|
|
891
|
+
h |= (b & 127) << 10;
|
|
892
|
+
if (b < 128)
|
|
893
|
+
return toNum(l, h, s);
|
|
894
|
+
b = buf[p.pos++];
|
|
895
|
+
h |= (b & 127) << 17;
|
|
896
|
+
if (b < 128)
|
|
897
|
+
return toNum(l, h, s);
|
|
898
|
+
b = buf[p.pos++];
|
|
899
|
+
h |= (b & 127) << 24;
|
|
900
|
+
if (b < 128)
|
|
901
|
+
return toNum(l, h, s);
|
|
902
|
+
b = buf[p.pos++];
|
|
903
|
+
h |= (b & 1) << 31;
|
|
904
|
+
if (b < 128)
|
|
905
|
+
return toNum(l, h, s);
|
|
906
|
+
throw new Error("Expected varint not more than 10 bytes");
|
|
842
907
|
}
|
|
843
|
-
function
|
|
844
|
-
|
|
845
|
-
tile[0] = Math.floor(tile[0]);
|
|
846
|
-
tile[1] = Math.floor(tile[1]);
|
|
847
|
-
return tile;
|
|
908
|
+
function readPackedEnd(pbf) {
|
|
909
|
+
return pbf.type === Pbf.Bytes ? pbf.readVarint() + pbf.pos : pbf.pos + 1;
|
|
848
910
|
}
|
|
849
|
-
function
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
[tile[0] * 2, tile[1] * 2 + 1, tile[2] + 1]
|
|
855
|
-
];
|
|
911
|
+
function toNum(low, high, isSigned) {
|
|
912
|
+
if (isSigned) {
|
|
913
|
+
return high * 4294967296 + (low >>> 0);
|
|
914
|
+
}
|
|
915
|
+
return (high >>> 0) * 4294967296 + (low >>> 0);
|
|
856
916
|
}
|
|
857
|
-
function
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
} else if (!tile[0] % 2 === 0 && tile[1] % 2 === 0) {
|
|
863
|
-
return [(tile[0] - 1) / 2, tile[1] / 2, tile[2] - 1];
|
|
917
|
+
function writeBigVarint(val, pbf) {
|
|
918
|
+
var low, high;
|
|
919
|
+
if (val >= 0) {
|
|
920
|
+
low = val % 4294967296 | 0;
|
|
921
|
+
high = val / 4294967296 | 0;
|
|
864
922
|
} else {
|
|
865
|
-
|
|
923
|
+
low = ~(-val % 4294967296);
|
|
924
|
+
high = ~(-val / 4294967296);
|
|
925
|
+
if (low ^ 4294967295) {
|
|
926
|
+
low = low + 1 | 0;
|
|
927
|
+
} else {
|
|
928
|
+
low = 0;
|
|
929
|
+
high = high + 1 | 0;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
if (val >= 18446744073709552e3 || val < -18446744073709552e3) {
|
|
933
|
+
throw new Error("Given varint doesn't fit into 10 bytes");
|
|
866
934
|
}
|
|
935
|
+
pbf.realloc(10);
|
|
936
|
+
writeBigVarintLow(low, high, pbf);
|
|
937
|
+
writeBigVarintHigh(high, pbf);
|
|
867
938
|
}
|
|
868
|
-
function
|
|
869
|
-
|
|
939
|
+
function writeBigVarintLow(low, high, pbf) {
|
|
940
|
+
pbf.buf[pbf.pos++] = low & 127 | 128;
|
|
941
|
+
low >>>= 7;
|
|
942
|
+
pbf.buf[pbf.pos++] = low & 127 | 128;
|
|
943
|
+
low >>>= 7;
|
|
944
|
+
pbf.buf[pbf.pos++] = low & 127 | 128;
|
|
945
|
+
low >>>= 7;
|
|
946
|
+
pbf.buf[pbf.pos++] = low & 127 | 128;
|
|
947
|
+
low >>>= 7;
|
|
948
|
+
pbf.buf[pbf.pos] = low & 127;
|
|
870
949
|
}
|
|
871
|
-
function
|
|
872
|
-
var
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
950
|
+
function writeBigVarintHigh(high, pbf) {
|
|
951
|
+
var lsb = (high & 7) << 4;
|
|
952
|
+
pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 128 : 0);
|
|
953
|
+
if (!high)
|
|
954
|
+
return;
|
|
955
|
+
pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
|
|
956
|
+
if (!high)
|
|
957
|
+
return;
|
|
958
|
+
pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
|
|
959
|
+
if (!high)
|
|
960
|
+
return;
|
|
961
|
+
pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
|
|
962
|
+
if (!high)
|
|
963
|
+
return;
|
|
964
|
+
pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
|
|
965
|
+
if (!high)
|
|
966
|
+
return;
|
|
967
|
+
pbf.buf[pbf.pos++] = high & 127;
|
|
878
968
|
}
|
|
879
|
-
function
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
return false;
|
|
969
|
+
function makeRoomForExtraLength(startPos, len, pbf) {
|
|
970
|
+
var extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
|
|
971
|
+
pbf.realloc(extraLen);
|
|
972
|
+
for (var i = pbf.pos - 1; i >= startPos; i--)
|
|
973
|
+
pbf.buf[i + extraLen] = pbf.buf[i];
|
|
885
974
|
}
|
|
886
|
-
function
|
|
887
|
-
|
|
975
|
+
function writePackedVarint(arr, pbf) {
|
|
976
|
+
for (var i = 0; i < arr.length; i++)
|
|
977
|
+
pbf.writeVarint(arr[i]);
|
|
888
978
|
}
|
|
889
|
-
function
|
|
890
|
-
var
|
|
891
|
-
|
|
892
|
-
var b = 0;
|
|
893
|
-
var mask = 1 << z - 1;
|
|
894
|
-
if ((tile[0] & mask) !== 0)
|
|
895
|
-
b++;
|
|
896
|
-
if ((tile[1] & mask) !== 0)
|
|
897
|
-
b += 2;
|
|
898
|
-
index2 += b.toString();
|
|
899
|
-
}
|
|
900
|
-
return index2;
|
|
979
|
+
function writePackedSVarint(arr, pbf) {
|
|
980
|
+
for (var i = 0; i < arr.length; i++)
|
|
981
|
+
pbf.writeSVarint(arr[i]);
|
|
901
982
|
}
|
|
902
|
-
function
|
|
903
|
-
var
|
|
904
|
-
|
|
905
|
-
var z = quadkey.length;
|
|
906
|
-
for (var i = z; i > 0; i--) {
|
|
907
|
-
var mask = 1 << i - 1;
|
|
908
|
-
switch (quadkey[z - i]) {
|
|
909
|
-
case "0":
|
|
910
|
-
break;
|
|
911
|
-
case "1":
|
|
912
|
-
x |= mask;
|
|
913
|
-
break;
|
|
914
|
-
case "2":
|
|
915
|
-
y |= mask;
|
|
916
|
-
break;
|
|
917
|
-
case "3":
|
|
918
|
-
x |= mask;
|
|
919
|
-
y |= mask;
|
|
920
|
-
break;
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
return [x, y, z];
|
|
983
|
+
function writePackedFloat(arr, pbf) {
|
|
984
|
+
for (var i = 0; i < arr.length; i++)
|
|
985
|
+
pbf.writeFloat(arr[i]);
|
|
924
986
|
}
|
|
925
|
-
function
|
|
926
|
-
var
|
|
927
|
-
|
|
928
|
-
var bbox = [min2[0], min2[1], max2[0], max2[1]];
|
|
929
|
-
var z = getBboxZoom(bbox);
|
|
930
|
-
if (z === 0)
|
|
931
|
-
return [0, 0, 0];
|
|
932
|
-
var x = bbox[0] >>> 32 - z;
|
|
933
|
-
var y = bbox[1] >>> 32 - z;
|
|
934
|
-
return [x, y, z];
|
|
987
|
+
function writePackedDouble(arr, pbf) {
|
|
988
|
+
for (var i = 0; i < arr.length; i++)
|
|
989
|
+
pbf.writeDouble(arr[i]);
|
|
935
990
|
}
|
|
936
|
-
function
|
|
937
|
-
var
|
|
938
|
-
|
|
939
|
-
var mask = 1 << 32 - (z + 1);
|
|
940
|
-
if ((bbox[0] & mask) != (bbox[2] & mask) || (bbox[1] & mask) != (bbox[3] & mask)) {
|
|
941
|
-
return z;
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
return MAX_ZOOM;
|
|
991
|
+
function writePackedBoolean(arr, pbf) {
|
|
992
|
+
for (var i = 0; i < arr.length; i++)
|
|
993
|
+
pbf.writeBoolean(arr[i]);
|
|
945
994
|
}
|
|
946
|
-
function
|
|
947
|
-
|
|
948
|
-
|
|
995
|
+
function writePackedFixed32(arr, pbf) {
|
|
996
|
+
for (var i = 0; i < arr.length; i++)
|
|
997
|
+
pbf.writeFixed32(arr[i]);
|
|
949
998
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
getChildren,
|
|
954
|
-
getParent,
|
|
955
|
-
getSiblings,
|
|
956
|
-
hasTile,
|
|
957
|
-
hasSiblings,
|
|
958
|
-
tilesEqual,
|
|
959
|
-
tileToQuadkey,
|
|
960
|
-
quadkeyToTile,
|
|
961
|
-
pointToTile,
|
|
962
|
-
bboxToTile,
|
|
963
|
-
pointToTileFraction
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
});
|
|
967
|
-
|
|
968
|
-
// ../../node_modules/@mapbox/tile-cover/index.js
|
|
969
|
-
var require_tile_cover = __commonJS({
|
|
970
|
-
"../../node_modules/@mapbox/tile-cover/index.js"(exports) {
|
|
971
|
-
var tilebelt = require_tilebelt();
|
|
972
|
-
exports.geojson = function(geom, limits) {
|
|
973
|
-
return {
|
|
974
|
-
type: "FeatureCollection",
|
|
975
|
-
features: getTiles(geom, limits).map(tileToFeature)
|
|
976
|
-
};
|
|
977
|
-
};
|
|
978
|
-
function tileToFeature(t) {
|
|
979
|
-
return {
|
|
980
|
-
type: "Feature",
|
|
981
|
-
geometry: tilebelt.tileToGeoJSON(t),
|
|
982
|
-
properties: {}
|
|
983
|
-
};
|
|
999
|
+
function writePackedSFixed32(arr, pbf) {
|
|
1000
|
+
for (var i = 0; i < arr.length; i++)
|
|
1001
|
+
pbf.writeSFixed32(arr[i]);
|
|
984
1002
|
}
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
};
|
|
989
|
-
function getTiles(geom, limits) {
|
|
990
|
-
var i, tile, coords = geom.coordinates, maxZoom = limits.max_zoom, tileHash = {}, tiles2 = [];
|
|
991
|
-
if (geom.type === "Point") {
|
|
992
|
-
return [tilebelt.pointToTile(coords[0], coords[1], maxZoom)];
|
|
993
|
-
} else if (geom.type === "MultiPoint") {
|
|
994
|
-
for (i = 0; i < coords.length; i++) {
|
|
995
|
-
tile = tilebelt.pointToTile(coords[i][0], coords[i][1], maxZoom);
|
|
996
|
-
tileHash[toID(tile[0], tile[1], tile[2])] = true;
|
|
997
|
-
}
|
|
998
|
-
} else if (geom.type === "LineString") {
|
|
999
|
-
lineCover(tileHash, coords, maxZoom);
|
|
1000
|
-
} else if (geom.type === "MultiLineString") {
|
|
1001
|
-
for (i = 0; i < coords.length; i++) {
|
|
1002
|
-
lineCover(tileHash, coords[i], maxZoom);
|
|
1003
|
-
}
|
|
1004
|
-
} else if (geom.type === "Polygon") {
|
|
1005
|
-
polygonCover(tileHash, tiles2, coords, maxZoom);
|
|
1006
|
-
} else if (geom.type === "MultiPolygon") {
|
|
1007
|
-
for (i = 0; i < coords.length; i++) {
|
|
1008
|
-
polygonCover(tileHash, tiles2, coords[i], maxZoom);
|
|
1009
|
-
}
|
|
1010
|
-
} else {
|
|
1011
|
-
throw new Error("Geometry type not implemented");
|
|
1012
|
-
}
|
|
1013
|
-
if (limits.min_zoom !== maxZoom) {
|
|
1014
|
-
var len = tiles2.length;
|
|
1015
|
-
appendHashTiles(tileHash, tiles2);
|
|
1016
|
-
for (i = 0; i < len; i++) {
|
|
1017
|
-
var t = tiles2[i];
|
|
1018
|
-
tileHash[toID(t[0], t[1], t[2])] = true;
|
|
1019
|
-
}
|
|
1020
|
-
return mergeTiles(tileHash, tiles2, limits);
|
|
1021
|
-
}
|
|
1022
|
-
appendHashTiles(tileHash, tiles2);
|
|
1023
|
-
return tiles2;
|
|
1003
|
+
function writePackedFixed64(arr, pbf) {
|
|
1004
|
+
for (var i = 0; i < arr.length; i++)
|
|
1005
|
+
pbf.writeFixed64(arr[i]);
|
|
1024
1006
|
}
|
|
1025
|
-
function
|
|
1026
|
-
var
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1007
|
+
function writePackedSFixed64(arr, pbf) {
|
|
1008
|
+
for (var i = 0; i < arr.length; i++)
|
|
1009
|
+
pbf.writeSFixed64(arr[i]);
|
|
1010
|
+
}
|
|
1011
|
+
function readUInt32(buf, pos) {
|
|
1012
|
+
return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + buf[pos + 3] * 16777216;
|
|
1013
|
+
}
|
|
1014
|
+
function writeInt32(buf, val, pos) {
|
|
1015
|
+
buf[pos] = val;
|
|
1016
|
+
buf[pos + 1] = val >>> 8;
|
|
1017
|
+
buf[pos + 2] = val >>> 16;
|
|
1018
|
+
buf[pos + 3] = val >>> 24;
|
|
1019
|
+
}
|
|
1020
|
+
function readInt32(buf, pos) {
|
|
1021
|
+
return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + (buf[pos + 3] << 24);
|
|
1022
|
+
}
|
|
1023
|
+
function readUtf8(buf, pos, end) {
|
|
1024
|
+
var str = "";
|
|
1025
|
+
var i = pos;
|
|
1026
|
+
while (i < end) {
|
|
1027
|
+
var b0 = buf[i];
|
|
1028
|
+
var c = null;
|
|
1029
|
+
var bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;
|
|
1030
|
+
if (i + bytesPerSequence > end)
|
|
1031
|
+
break;
|
|
1032
|
+
var b1, b2, b3;
|
|
1033
|
+
if (bytesPerSequence === 1) {
|
|
1034
|
+
if (b0 < 128) {
|
|
1035
|
+
c = b0;
|
|
1036
|
+
}
|
|
1037
|
+
} else if (bytesPerSequence === 2) {
|
|
1038
|
+
b1 = buf[i + 1];
|
|
1039
|
+
if ((b1 & 192) === 128) {
|
|
1040
|
+
c = (b0 & 31) << 6 | b1 & 63;
|
|
1041
|
+
if (c <= 127) {
|
|
1042
|
+
c = null;
|
|
1046
1043
|
}
|
|
1047
1044
|
}
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
if (
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
var y = ring[j][1];
|
|
1067
|
-
if ((y > ring[k][1] || y > ring[m][1]) && (y < ring[k][1] || y < ring[m][1]) && y !== ring[m][1])
|
|
1068
|
-
intersections.push(ring[j]);
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
intersections.sort(compareTiles);
|
|
1072
|
-
for (i = 0; i < intersections.length; i += 2) {
|
|
1073
|
-
y = intersections[i][1];
|
|
1074
|
-
for (var x = intersections[i][0] + 1; x < intersections[i + 1][0]; x++) {
|
|
1075
|
-
var id4 = toID(x, y, zoom);
|
|
1076
|
-
if (!tileHash[id4]) {
|
|
1077
|
-
tileArray.push([x, y, zoom]);
|
|
1045
|
+
} else if (bytesPerSequence === 3) {
|
|
1046
|
+
b1 = buf[i + 1];
|
|
1047
|
+
b2 = buf[i + 2];
|
|
1048
|
+
if ((b1 & 192) === 128 && (b2 & 192) === 128) {
|
|
1049
|
+
c = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;
|
|
1050
|
+
if (c <= 2047 || c >= 55296 && c <= 57343) {
|
|
1051
|
+
c = null;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
} else if (bytesPerSequence === 4) {
|
|
1055
|
+
b1 = buf[i + 1];
|
|
1056
|
+
b2 = buf[i + 2];
|
|
1057
|
+
b3 = buf[i + 3];
|
|
1058
|
+
if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {
|
|
1059
|
+
c = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;
|
|
1060
|
+
if (c <= 65535 || c >= 1114112) {
|
|
1061
|
+
c = null;
|
|
1062
|
+
}
|
|
1078
1063
|
}
|
|
1079
1064
|
}
|
|
1065
|
+
if (c === null) {
|
|
1066
|
+
c = 65533;
|
|
1067
|
+
bytesPerSequence = 1;
|
|
1068
|
+
} else if (c > 65535) {
|
|
1069
|
+
c -= 65536;
|
|
1070
|
+
str += String.fromCharCode(c >>> 10 & 1023 | 55296);
|
|
1071
|
+
c = 56320 | c & 1023;
|
|
1072
|
+
}
|
|
1073
|
+
str += String.fromCharCode(c);
|
|
1074
|
+
i += bytesPerSequence;
|
|
1080
1075
|
}
|
|
1076
|
+
return str;
|
|
1081
1077
|
}
|
|
1082
|
-
function
|
|
1083
|
-
return
|
|
1078
|
+
function readUtf8TextDecoder(buf, pos, end) {
|
|
1079
|
+
return utf8TextDecoder.decode(buf.subarray(pos, end));
|
|
1084
1080
|
}
|
|
1085
|
-
function
|
|
1086
|
-
var
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1081
|
+
function writeUtf8(buf, str, pos) {
|
|
1082
|
+
for (var i = 0, c, lead; i < str.length; i++) {
|
|
1083
|
+
c = str.charCodeAt(i);
|
|
1084
|
+
if (c > 55295 && c < 57344) {
|
|
1085
|
+
if (lead) {
|
|
1086
|
+
if (c < 56320) {
|
|
1087
|
+
buf[pos++] = 239;
|
|
1088
|
+
buf[pos++] = 191;
|
|
1089
|
+
buf[pos++] = 189;
|
|
1090
|
+
lead = c;
|
|
1091
|
+
continue;
|
|
1092
|
+
} else {
|
|
1093
|
+
c = lead - 55296 << 10 | c - 56320 | 65536;
|
|
1094
|
+
lead = null;
|
|
1095
|
+
}
|
|
1096
|
+
} else {
|
|
1097
|
+
if (c > 56319 || i + 1 === str.length) {
|
|
1098
|
+
buf[pos++] = 239;
|
|
1099
|
+
buf[pos++] = 191;
|
|
1100
|
+
buf[pos++] = 189;
|
|
1101
|
+
} else {
|
|
1102
|
+
lead = c;
|
|
1103
|
+
}
|
|
1104
|
+
continue;
|
|
1105
|
+
}
|
|
1106
|
+
} else if (lead) {
|
|
1107
|
+
buf[pos++] = 239;
|
|
1108
|
+
buf[pos++] = 191;
|
|
1109
|
+
buf[pos++] = 189;
|
|
1110
|
+
lead = null;
|
|
1098
1111
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1112
|
+
if (c < 128) {
|
|
1113
|
+
buf[pos++] = c;
|
|
1114
|
+
} else {
|
|
1115
|
+
if (c < 2048) {
|
|
1116
|
+
buf[pos++] = c >> 6 | 192;
|
|
1103
1117
|
} else {
|
|
1104
|
-
|
|
1105
|
-
|
|
1118
|
+
if (c < 65536) {
|
|
1119
|
+
buf[pos++] = c >> 12 | 224;
|
|
1120
|
+
} else {
|
|
1121
|
+
buf[pos++] = c >> 18 | 240;
|
|
1122
|
+
buf[pos++] = c >> 12 & 63 | 128;
|
|
1123
|
+
}
|
|
1124
|
+
buf[pos++] = c >> 6 & 63 | 128;
|
|
1106
1125
|
}
|
|
1107
|
-
|
|
1108
|
-
if (ring && y !== prevY)
|
|
1109
|
-
ring.push([x, y]);
|
|
1110
|
-
prevX = x;
|
|
1111
|
-
prevY = y;
|
|
1126
|
+
buf[pos++] = c & 63 | 128;
|
|
1112
1127
|
}
|
|
1113
1128
|
}
|
|
1114
|
-
|
|
1115
|
-
ring.pop();
|
|
1116
|
-
}
|
|
1117
|
-
function appendHashTiles(hash, tiles2) {
|
|
1118
|
-
var keys = Object.keys(hash);
|
|
1119
|
-
for (var i = 0; i < keys.length; i++) {
|
|
1120
|
-
tiles2.push(fromID(+keys[i]));
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
function toID(x, y, z) {
|
|
1124
|
-
var dim = 2 * (1 << z);
|
|
1125
|
-
return (dim * y + x) * 32 + z;
|
|
1126
|
-
}
|
|
1127
|
-
function fromID(id4) {
|
|
1128
|
-
var z = id4 % 32, dim = 2 * (1 << z), xy = (id4 - z) / 32, x = xy % dim, y = (xy - x) / dim % dim;
|
|
1129
|
-
return [x, y, z];
|
|
1129
|
+
return pos;
|
|
1130
1130
|
}
|
|
1131
1131
|
}
|
|
1132
1132
|
});
|
|
1133
1133
|
|
|
1134
|
-
// external-global-plugin
|
|
1135
|
-
var
|
|
1136
|
-
"external-global-plugin
|
|
1137
|
-
module.exports = globalThis.
|
|
1134
|
+
// external-global-plugin:h3-js
|
|
1135
|
+
var require_h3_js = __commonJS({
|
|
1136
|
+
"external-global-plugin:h3-js"(exports, module) {
|
|
1137
|
+
module.exports = globalThis.h3 || {};
|
|
1138
1138
|
}
|
|
1139
1139
|
});
|
|
1140
1140
|
|
|
@@ -6992,6 +6992,7 @@ var __exports__ = (() => {
|
|
|
6992
6992
|
CARTO_LAYERS: () => CARTO_LAYERS,
|
|
6993
6993
|
CARTO_SOURCES: () => CARTO_SOURCES,
|
|
6994
6994
|
CartoAPIError: () => CartoAPIError,
|
|
6995
|
+
ClusterTileLayer: () => ClusterTileLayer,
|
|
6995
6996
|
H3TileLayer: () => H3TileLayer,
|
|
6996
6997
|
HeatmapTileLayer: () => heatmap_tile_layer_default,
|
|
6997
6998
|
QuadbinTileLayer: () => QuadbinTileLayer,
|
|
@@ -7015,261 +7016,429 @@ var __exports__ = (() => {
|
|
|
7015
7016
|
h3TableSource: () => h3TableSource,
|
|
7016
7017
|
h3TilesetSource: () => h3TilesetSource,
|
|
7017
7018
|
quadbinQuerySource: () => quadbinQuerySource,
|
|
7018
|
-
quadbinTableSource: () => quadbinTableSource,
|
|
7019
|
-
quadbinTilesetSource: () => quadbinTilesetSource,
|
|
7020
|
-
query: () => query,
|
|
7021
|
-
rasterSource: () => rasterSource,
|
|
7022
|
-
vectorQuerySource: () => vectorQuerySource,
|
|
7023
|
-
vectorTableSource: () => vectorTableSource,
|
|
7024
|
-
vectorTilesetSource: () => vectorTilesetSource
|
|
7025
|
-
});
|
|
7026
|
-
|
|
7027
|
-
// src/layers/
|
|
7028
|
-
var
|
|
7029
|
-
var
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
const nSegments = Math.ceil(longitudeSpan / 180);
|
|
7059
|
-
let h3Indices = [];
|
|
7060
|
-
for (let s = 0; s < nSegments; s++) {
|
|
7061
|
-
const segmentWest = west + s * 180;
|
|
7062
|
-
const segmentEast = Math.min(segmentWest + 179.9999999, east);
|
|
7063
|
-
h3Indices = h3Indices.concat(
|
|
7064
|
-
getHexagonsInBoundingBox({ west: segmentWest, north, east: segmentEast, south }, resolution)
|
|
7065
|
-
);
|
|
7019
|
+
quadbinTableSource: () => quadbinTableSource,
|
|
7020
|
+
quadbinTilesetSource: () => quadbinTilesetSource,
|
|
7021
|
+
query: () => query,
|
|
7022
|
+
rasterSource: () => rasterSource,
|
|
7023
|
+
vectorQuerySource: () => vectorQuerySource,
|
|
7024
|
+
vectorTableSource: () => vectorTableSource,
|
|
7025
|
+
vectorTilesetSource: () => vectorTilesetSource
|
|
7026
|
+
});
|
|
7027
|
+
|
|
7028
|
+
// src/layers/cluster-tile-layer.ts
|
|
7029
|
+
var import_layers = __toESM(require_layers(), 1);
|
|
7030
|
+
var import_geo_layers2 = __toESM(require_geo_layers(), 1);
|
|
7031
|
+
var import_core4 = __toESM(require_core(), 1);
|
|
7032
|
+
|
|
7033
|
+
// ../../node_modules/@loaders.gl/gis/dist/lib/binary-features/binary-to-geojson.js
|
|
7034
|
+
function binaryToGeojson(data, options) {
|
|
7035
|
+
const globalFeatureId = options?.globalFeatureId;
|
|
7036
|
+
if (globalFeatureId !== void 0) {
|
|
7037
|
+
return getSingleFeature(data, globalFeatureId);
|
|
7038
|
+
}
|
|
7039
|
+
return parseFeatures(data, options?.type);
|
|
7040
|
+
}
|
|
7041
|
+
function getSingleFeature(data, globalFeatureId) {
|
|
7042
|
+
const dataArray = normalizeInput(data);
|
|
7043
|
+
for (const data2 of dataArray) {
|
|
7044
|
+
let lastIndex = 0;
|
|
7045
|
+
let lastValue = data2.featureIds.value[0];
|
|
7046
|
+
for (let i = 0; i < data2.featureIds.value.length; i++) {
|
|
7047
|
+
const currValue = data2.featureIds.value[i];
|
|
7048
|
+
if (currValue === lastValue) {
|
|
7049
|
+
continue;
|
|
7050
|
+
}
|
|
7051
|
+
if (globalFeatureId === data2.globalFeatureIds.value[lastIndex]) {
|
|
7052
|
+
return parseFeature(data2, lastIndex, i);
|
|
7053
|
+
}
|
|
7054
|
+
lastIndex = i;
|
|
7055
|
+
lastValue = currValue;
|
|
7056
|
+
}
|
|
7057
|
+
if (globalFeatureId === data2.globalFeatureIds.value[lastIndex]) {
|
|
7058
|
+
return parseFeature(data2, lastIndex, data2.featureIds.value.length);
|
|
7066
7059
|
}
|
|
7067
|
-
return [...new Set(h3Indices)];
|
|
7068
7060
|
}
|
|
7069
|
-
|
|
7070
|
-
[north, east],
|
|
7071
|
-
[south, east],
|
|
7072
|
-
[south, west],
|
|
7073
|
-
[north, west],
|
|
7074
|
-
[north, east]
|
|
7075
|
-
];
|
|
7076
|
-
return (0, import_h3_js.polygonToCells)(polygon, resolution);
|
|
7061
|
+
throw new Error(`featureId:${globalFeatureId} not found`);
|
|
7077
7062
|
}
|
|
7078
|
-
function
|
|
7079
|
-
const
|
|
7080
|
-
|
|
7081
|
-
const longitudes = coordinates.map((c) => c[1]);
|
|
7082
|
-
const west = Math.min(...longitudes);
|
|
7083
|
-
const south = Math.min(...latitudes);
|
|
7084
|
-
const east = Math.max(...longitudes);
|
|
7085
|
-
const north = Math.max(...latitudes);
|
|
7086
|
-
return { west, south, east, north };
|
|
7063
|
+
function parseFeatures(data, type) {
|
|
7064
|
+
const dataArray = normalizeInput(data, type);
|
|
7065
|
+
return parseFeatureCollection(dataArray);
|
|
7087
7066
|
}
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7067
|
+
function binaryToGeometry(data, startIndex, endIndex) {
|
|
7068
|
+
switch (data.type) {
|
|
7069
|
+
case "Point":
|
|
7070
|
+
return pointToGeoJson(data, startIndex, endIndex);
|
|
7071
|
+
case "LineString":
|
|
7072
|
+
return lineStringToGeoJson(data, startIndex, endIndex);
|
|
7073
|
+
case "Polygon":
|
|
7074
|
+
return polygonToGeoJson(data, startIndex, endIndex);
|
|
7075
|
+
default:
|
|
7076
|
+
const unexpectedInput = data;
|
|
7077
|
+
throw new Error(`Unsupported geometry type: ${unexpectedInput?.type}`);
|
|
7078
|
+
}
|
|
7094
7079
|
}
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7080
|
+
function normalizeInput(data, type) {
|
|
7081
|
+
const features = [];
|
|
7082
|
+
if (data.points) {
|
|
7083
|
+
data.points.type = "Point";
|
|
7084
|
+
features.push(data.points);
|
|
7085
|
+
}
|
|
7086
|
+
if (data.lines) {
|
|
7087
|
+
data.lines.type = "LineString";
|
|
7088
|
+
features.push(data.lines);
|
|
7089
|
+
}
|
|
7090
|
+
if (data.polygons) {
|
|
7091
|
+
data.polygons.type = "Polygon";
|
|
7092
|
+
features.push(data.polygons);
|
|
7093
|
+
}
|
|
7094
|
+
return features;
|
|
7095
|
+
}
|
|
7096
|
+
function parseFeatureCollection(dataArray) {
|
|
7097
|
+
const features = [];
|
|
7098
|
+
for (const data of dataArray) {
|
|
7099
|
+
if (data.featureIds.value.length === 0) {
|
|
7100
|
+
continue;
|
|
7105
7101
|
}
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7102
|
+
let lastIndex = 0;
|
|
7103
|
+
let lastValue = data.featureIds.value[0];
|
|
7104
|
+
for (let i = 0; i < data.featureIds.value.length; i++) {
|
|
7105
|
+
const currValue = data.featureIds.value[i];
|
|
7106
|
+
if (currValue === lastValue) {
|
|
7107
|
+
continue;
|
|
7108
|
+
}
|
|
7109
|
+
features.push(parseFeature(data, lastIndex, i));
|
|
7110
|
+
lastIndex = i;
|
|
7111
|
+
lastValue = currValue;
|
|
7113
7112
|
}
|
|
7114
|
-
|
|
7113
|
+
features.push(parseFeature(data, lastIndex, data.featureIds.value.length));
|
|
7115
7114
|
}
|
|
7116
|
-
|
|
7117
|
-
|
|
7115
|
+
return features;
|
|
7116
|
+
}
|
|
7117
|
+
function parseFeature(data, startIndex, endIndex) {
|
|
7118
|
+
const geometry = binaryToGeometry(data, startIndex, endIndex);
|
|
7119
|
+
const properties = parseProperties(data, startIndex, endIndex);
|
|
7120
|
+
const fields = parseFields(data, startIndex, endIndex);
|
|
7121
|
+
return { type: "Feature", geometry, properties, ...fields };
|
|
7122
|
+
}
|
|
7123
|
+
function parseFields(data, startIndex = 0, endIndex) {
|
|
7124
|
+
return data.fields && data.fields[data.featureIds.value[startIndex]];
|
|
7125
|
+
}
|
|
7126
|
+
function parseProperties(data, startIndex = 0, endIndex) {
|
|
7127
|
+
const properties = Object.assign({}, data.properties[data.featureIds.value[startIndex]]);
|
|
7128
|
+
for (const key in data.numericProps) {
|
|
7129
|
+
properties[key] = data.numericProps[key].value[startIndex];
|
|
7118
7130
|
}
|
|
7119
|
-
|
|
7120
|
-
|
|
7131
|
+
return properties;
|
|
7132
|
+
}
|
|
7133
|
+
function polygonToGeoJson(data, startIndex = -Infinity, endIndex = Infinity) {
|
|
7134
|
+
const { positions } = data;
|
|
7135
|
+
const polygonIndices = data.polygonIndices.value.filter((x) => x >= startIndex && x <= endIndex);
|
|
7136
|
+
const primitivePolygonIndices = data.primitivePolygonIndices.value.filter((x) => x >= startIndex && x <= endIndex);
|
|
7137
|
+
const multi = polygonIndices.length > 2;
|
|
7138
|
+
if (!multi) {
|
|
7139
|
+
const coordinates2 = [];
|
|
7140
|
+
for (let i = 0; i < primitivePolygonIndices.length - 1; i++) {
|
|
7141
|
+
const startRingIndex = primitivePolygonIndices[i];
|
|
7142
|
+
const endRingIndex = primitivePolygonIndices[i + 1];
|
|
7143
|
+
const ringCoordinates = ringToGeoJson(positions, startRingIndex, endRingIndex);
|
|
7144
|
+
coordinates2.push(ringCoordinates);
|
|
7145
|
+
}
|
|
7146
|
+
return { type: "Polygon", coordinates: coordinates2 };
|
|
7121
7147
|
}
|
|
7122
|
-
|
|
7123
|
-
|
|
7148
|
+
const coordinates = [];
|
|
7149
|
+
for (let i = 0; i < polygonIndices.length - 1; i++) {
|
|
7150
|
+
const startPolygonIndex = polygonIndices[i];
|
|
7151
|
+
const endPolygonIndex = polygonIndices[i + 1];
|
|
7152
|
+
const polygonCoordinates = polygonToGeoJson(data, startPolygonIndex, endPolygonIndex).coordinates;
|
|
7153
|
+
coordinates.push(polygonCoordinates);
|
|
7124
7154
|
}
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7155
|
+
return { type: "MultiPolygon", coordinates };
|
|
7156
|
+
}
|
|
7157
|
+
function lineStringToGeoJson(data, startIndex = -Infinity, endIndex = Infinity) {
|
|
7158
|
+
const { positions } = data;
|
|
7159
|
+
const pathIndices = data.pathIndices.value.filter((x) => x >= startIndex && x <= endIndex);
|
|
7160
|
+
const multi = pathIndices.length > 2;
|
|
7161
|
+
if (!multi) {
|
|
7162
|
+
const coordinates2 = ringToGeoJson(positions, pathIndices[0], pathIndices[1]);
|
|
7163
|
+
return { type: "LineString", coordinates: coordinates2 };
|
|
7129
7164
|
}
|
|
7130
|
-
|
|
7165
|
+
const coordinates = [];
|
|
7166
|
+
for (let i = 0; i < pathIndices.length - 1; i++) {
|
|
7167
|
+
const ringCoordinates = ringToGeoJson(positions, pathIndices[i], pathIndices[i + 1]);
|
|
7168
|
+
coordinates.push(ringCoordinates);
|
|
7169
|
+
}
|
|
7170
|
+
return { type: "MultiLineString", coordinates };
|
|
7171
|
+
}
|
|
7172
|
+
function pointToGeoJson(data, startIndex, endIndex) {
|
|
7173
|
+
const { positions } = data;
|
|
7174
|
+
const coordinates = ringToGeoJson(positions, startIndex, endIndex);
|
|
7175
|
+
const multi = coordinates.length > 1;
|
|
7176
|
+
if (multi) {
|
|
7177
|
+
return { type: "MultiPoint", coordinates };
|
|
7178
|
+
}
|
|
7179
|
+
return { type: "Point", coordinates: coordinates[0] };
|
|
7180
|
+
}
|
|
7181
|
+
function ringToGeoJson(positions, startIndex, endIndex) {
|
|
7182
|
+
startIndex = startIndex || 0;
|
|
7183
|
+
endIndex = endIndex || positions.value.length / positions.size;
|
|
7184
|
+
const ringCoordinates = [];
|
|
7185
|
+
for (let j = startIndex; j < endIndex; j++) {
|
|
7186
|
+
const coord = Array();
|
|
7187
|
+
for (let k = j * positions.size; k < (j + 1) * positions.size; k++) {
|
|
7188
|
+
coord.push(Number(positions.value[k]));
|
|
7189
|
+
}
|
|
7190
|
+
ringCoordinates.push(coord);
|
|
7191
|
+
}
|
|
7192
|
+
return ringCoordinates;
|
|
7193
|
+
}
|
|
7131
7194
|
|
|
7132
|
-
// src/layers/
|
|
7133
|
-
var
|
|
7195
|
+
// src/layers/cluster-tile-layer.ts
|
|
7196
|
+
var import_core5 = __toESM(require_core2(), 1);
|
|
7134
7197
|
|
|
7135
|
-
//
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7198
|
+
// ../../node_modules/quadbin/dist/esm/index.js
|
|
7199
|
+
var import_tile_cover = __toESM(require_tile_cover(), 1);
|
|
7200
|
+
var B = [
|
|
7201
|
+
0x5555555555555555n,
|
|
7202
|
+
0x3333333333333333n,
|
|
7203
|
+
0x0f0f0f0f0f0f0f0fn,
|
|
7204
|
+
0x00ff00ff00ff00ffn,
|
|
7205
|
+
0x0000ffff0000ffffn,
|
|
7206
|
+
0x00000000ffffffffn
|
|
7207
|
+
];
|
|
7208
|
+
var S = [0n, 1n, 2n, 4n, 8n, 16n];
|
|
7209
|
+
function hexToBigInt(hex2) {
|
|
7210
|
+
return BigInt(`0x${hex2}`);
|
|
7141
7211
|
}
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
uint64: BigUint64Array,
|
|
7149
|
-
int8: Int8Array,
|
|
7150
|
-
int16: Int16Array,
|
|
7151
|
-
int32: Int32Array,
|
|
7152
|
-
int64: BigInt64Array,
|
|
7153
|
-
float32: Float32Array,
|
|
7154
|
-
float64: Float64Array
|
|
7155
|
-
};
|
|
7156
|
-
var BandReader = class {
|
|
7157
|
-
static read(pbf, end) {
|
|
7158
|
-
return pbf.readFields(BandReader._readField, { name: "", type: "", data: null }, end);
|
|
7212
|
+
function bigIntToHex(index2) {
|
|
7213
|
+
return index2.toString(16);
|
|
7214
|
+
}
|
|
7215
|
+
function tileToCell(tile) {
|
|
7216
|
+
if (tile.z < 0 || tile.z > 26) {
|
|
7217
|
+
throw new Error("Wrong zoom");
|
|
7159
7218
|
}
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
throw Error(`Invalid data type: ${obj.type}`);
|
|
7169
|
-
}
|
|
7170
|
-
obj.data = {};
|
|
7171
|
-
readPackedTypedArray(TypedArray, pbf, obj.data);
|
|
7172
|
-
}
|
|
7219
|
+
const z = BigInt(tile.z);
|
|
7220
|
+
let x = BigInt(tile.x) << 32n - z;
|
|
7221
|
+
let y = BigInt(tile.y) << 32n - z;
|
|
7222
|
+
for (let i = 0; i < 5; i++) {
|
|
7223
|
+
const s = S[5 - i];
|
|
7224
|
+
const b = B[4 - i];
|
|
7225
|
+
x = (x | x << s) & b;
|
|
7226
|
+
y = (y | y << s) & b;
|
|
7173
7227
|
}
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7228
|
+
const quadbin = 0x4000000000000000n | 1n << 59n | z << 52n | (x | y << 1n) >> 12n | 0xfffffffffffffn >> z * 2n;
|
|
7229
|
+
return quadbin;
|
|
7230
|
+
}
|
|
7231
|
+
function cellToTile(quadbin) {
|
|
7232
|
+
const mode = quadbin >> 59n & 7n;
|
|
7233
|
+
const modeDep = quadbin >> 57n & 3n;
|
|
7234
|
+
const z = quadbin >> 52n & 0x1fn;
|
|
7235
|
+
const q = (quadbin & 0xfffffffffffffn) << 12n;
|
|
7236
|
+
if (mode !== 1n && modeDep !== 0n) {
|
|
7237
|
+
throw new Error("Wrong mode");
|
|
7178
7238
|
}
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7239
|
+
let x = q;
|
|
7240
|
+
let y = q >> 1n;
|
|
7241
|
+
for (let i = 0; i < 6; i++) {
|
|
7242
|
+
const s = S[i];
|
|
7243
|
+
const b = B[i];
|
|
7244
|
+
x = (x | x >> s) & b;
|
|
7245
|
+
y = (y | y >> s) & b;
|
|
7184
7246
|
}
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
function
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7247
|
+
x = x >> 32n - z;
|
|
7248
|
+
y = y >> 32n - z;
|
|
7249
|
+
return { z: Number(z), x: Number(x), y: Number(y) };
|
|
7250
|
+
}
|
|
7251
|
+
function getResolution(quadbin) {
|
|
7252
|
+
return quadbin >> 52n & 0x1fn;
|
|
7253
|
+
}
|
|
7254
|
+
function cellToParent(quadbin) {
|
|
7255
|
+
const zparent = getResolution(quadbin) - 1n;
|
|
7256
|
+
const parent = quadbin & ~(0x1fn << 52n) | zparent << 52n | 0xfffffffffffffn >> zparent * 2n;
|
|
7257
|
+
return parent;
|
|
7193
7258
|
}
|
|
7194
7259
|
|
|
7195
|
-
// src/utils.ts
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7260
|
+
// src/layers/cluster-utils.ts
|
|
7261
|
+
function aggregateTile(tile, aggregationLevels, properties = [], getPosition, getWeight) {
|
|
7262
|
+
if (!tile.content)
|
|
7263
|
+
return;
|
|
7264
|
+
if (!tile.userData)
|
|
7265
|
+
tile.userData = {};
|
|
7266
|
+
if (tile.userData[aggregationLevels])
|
|
7267
|
+
return;
|
|
7268
|
+
const out = {};
|
|
7269
|
+
for (const cell of tile.content) {
|
|
7270
|
+
let id4 = cell.id;
|
|
7271
|
+
const position = typeof getPosition === "function" ? getPosition(cell, {}) : getPosition;
|
|
7272
|
+
for (let i = 0; i < aggregationLevels - 1; i++) {
|
|
7273
|
+
id4 = cellToParent(id4);
|
|
7274
|
+
}
|
|
7275
|
+
const parentId = Number(id4);
|
|
7276
|
+
if (!(parentId in out)) {
|
|
7277
|
+
out[parentId] = { id: id4, count: 0, position: [0, 0] };
|
|
7278
|
+
for (const { name, aggregation } of properties) {
|
|
7279
|
+
if (aggregation === "any") {
|
|
7280
|
+
out[parentId][name] = cell.properties[name];
|
|
7281
|
+
} else {
|
|
7282
|
+
out[parentId][name] = 0;
|
|
7283
|
+
}
|
|
7284
|
+
}
|
|
7285
|
+
}
|
|
7286
|
+
const prevTotalW = out[parentId].count;
|
|
7287
|
+
out[parentId].count += typeof getWeight === "function" ? getWeight(cell, {}) : getWeight;
|
|
7288
|
+
const totalW = out[parentId].count;
|
|
7289
|
+
const W = totalW - prevTotalW;
|
|
7290
|
+
out[parentId].position[0] = (prevTotalW * out[parentId].position[0] + W * position[0]) / totalW;
|
|
7291
|
+
out[parentId].position[1] = (prevTotalW * out[parentId].position[1] + W * position[1]) / totalW;
|
|
7292
|
+
for (const { name, aggregation } of properties) {
|
|
7293
|
+
const prevValue = out[parentId][name];
|
|
7294
|
+
const value = cell.properties[name];
|
|
7295
|
+
if (aggregation === "average") {
|
|
7296
|
+
out[parentId][name] = (prevTotalW * prevValue + W * value) / totalW;
|
|
7297
|
+
} else if (aggregation === "count" || aggregation === "sum") {
|
|
7298
|
+
out[parentId][name] = prevValue + value;
|
|
7299
|
+
} else if (aggregation === "max") {
|
|
7300
|
+
out[parentId][name] = Math.max(prevValue, value);
|
|
7301
|
+
} else if (aggregation === "min") {
|
|
7302
|
+
out[parentId][name] = Math.min(prevValue, value);
|
|
7303
|
+
}
|
|
7304
|
+
}
|
|
7305
|
+
}
|
|
7306
|
+
tile.userData[aggregationLevels] = Object.values(out);
|
|
7199
7307
|
}
|
|
7200
|
-
function
|
|
7201
|
-
const
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7308
|
+
function extractAggregationProperties(tile) {
|
|
7309
|
+
const properties = [];
|
|
7310
|
+
const validAggregations = ["any", "average", "count", "min", "max", "sum"];
|
|
7311
|
+
for (const name of Object.keys(tile.content[0].properties)) {
|
|
7312
|
+
let aggregation = name.split("_").pop().toLowerCase();
|
|
7313
|
+
if (!validAggregations.includes(aggregation)) {
|
|
7314
|
+
aggregation = "any";
|
|
7315
|
+
}
|
|
7316
|
+
properties.push({ name, aggregation });
|
|
7317
|
+
}
|
|
7318
|
+
return properties;
|
|
7319
|
+
}
|
|
7320
|
+
function computeAggregationStats(data, properties) {
|
|
7321
|
+
const stats = {};
|
|
7322
|
+
for (const { name, aggregation } of properties) {
|
|
7323
|
+
stats[name] = { min: Infinity, max: -Infinity };
|
|
7324
|
+
if (aggregation !== "any") {
|
|
7325
|
+
for (const d of data) {
|
|
7326
|
+
stats[name].min = Math.min(stats[name].min, d[name]);
|
|
7327
|
+
stats[name].max = Math.max(stats[name].max, d[name]);
|
|
7206
7328
|
}
|
|
7207
|
-
|
|
7329
|
+
}
|
|
7330
|
+
}
|
|
7331
|
+
return stats;
|
|
7332
|
+
}
|
|
7333
|
+
var EMPTY_UINT16ARRAY = new Uint16Array();
|
|
7334
|
+
var EMPTY_BINARY_PROPS = {
|
|
7335
|
+
positions: { value: new Float32Array(), size: 2 },
|
|
7336
|
+
properties: [],
|
|
7337
|
+
numericProps: {},
|
|
7338
|
+
featureIds: { value: EMPTY_UINT16ARRAY, size: 1 },
|
|
7339
|
+
globalFeatureIds: { value: EMPTY_UINT16ARRAY, size: 1 }
|
|
7340
|
+
};
|
|
7341
|
+
function clustersToBinary(data) {
|
|
7342
|
+
const positions = new Float32Array(data.length * 2);
|
|
7343
|
+
const featureIds = new Uint16Array(data.length);
|
|
7344
|
+
for (let i = 0; i < data.length; i++) {
|
|
7345
|
+
positions.set(data[i].position, 2 * i);
|
|
7346
|
+
featureIds[i] = i;
|
|
7347
|
+
}
|
|
7348
|
+
return {
|
|
7349
|
+
shape: "binary-feature-collection",
|
|
7350
|
+
points: {
|
|
7351
|
+
type: "Point",
|
|
7352
|
+
positions: { value: positions, size: 2 },
|
|
7353
|
+
properties: data,
|
|
7354
|
+
numericProps: {},
|
|
7355
|
+
featureIds: { value: featureIds, size: 1 },
|
|
7356
|
+
globalFeatureIds: { value: featureIds, size: 1 }
|
|
7208
7357
|
},
|
|
7209
|
-
|
|
7210
|
-
|
|
7358
|
+
lines: {
|
|
7359
|
+
type: "LineString",
|
|
7360
|
+
pathIndices: { value: EMPTY_UINT16ARRAY, size: 1 },
|
|
7361
|
+
...EMPTY_BINARY_PROPS
|
|
7362
|
+
},
|
|
7363
|
+
polygons: {
|
|
7364
|
+
type: "Polygon",
|
|
7365
|
+
polygonIndices: { value: EMPTY_UINT16ARRAY, size: 1 },
|
|
7366
|
+
primitivePolygonIndices: { value: EMPTY_UINT16ARRAY, size: 1 },
|
|
7367
|
+
...EMPTY_BINARY_PROPS
|
|
7211
7368
|
}
|
|
7212
|
-
}
|
|
7369
|
+
};
|
|
7370
|
+
}
|
|
7371
|
+
|
|
7372
|
+
// src/constants.ts
|
|
7373
|
+
var DEFAULT_TILE_SIZE = 512;
|
|
7374
|
+
var DEFAULT_TILE_RESOLUTION = 0.5;
|
|
7375
|
+
var DEFAULT_AGGREGATION_RES_LEVEL_H3 = 4;
|
|
7376
|
+
var DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = 6;
|
|
7377
|
+
|
|
7378
|
+
// src/layers/quadbin-tileset-2d.ts
|
|
7379
|
+
var import_geo_layers = __toESM(require_geo_layers(), 1);
|
|
7380
|
+
var QuadbinTileset2D = class extends import_geo_layers._Tileset2D {
|
|
7381
|
+
getTileIndices(opts) {
|
|
7382
|
+
return super.getTileIndices(opts).map(tileToCell).map((q) => ({ q, i: bigIntToHex(q) }));
|
|
7383
|
+
}
|
|
7384
|
+
getTileId({ q, i }) {
|
|
7385
|
+
return i || bigIntToHex(q);
|
|
7386
|
+
}
|
|
7387
|
+
getTileMetadata({ q }) {
|
|
7388
|
+
return super.getTileMetadata(cellToTile(q));
|
|
7389
|
+
}
|
|
7390
|
+
getTileZoom({ q }) {
|
|
7391
|
+
return Number(getResolution(q));
|
|
7392
|
+
}
|
|
7393
|
+
getParentIndex({ q }) {
|
|
7394
|
+
return { q: cellToParent(q) };
|
|
7395
|
+
}
|
|
7396
|
+
};
|
|
7397
|
+
|
|
7398
|
+
// ../../node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
7399
|
+
var PI = Math.PI;
|
|
7400
|
+
var PI_4 = PI / 4;
|
|
7401
|
+
var DEGREES_TO_RADIANS = PI / 180;
|
|
7402
|
+
var RADIANS_TO_DEGREES = 180 / PI;
|
|
7403
|
+
var TILE_SIZE = 512;
|
|
7404
|
+
function worldToLngLat(xy) {
|
|
7405
|
+
const [x, y] = xy;
|
|
7406
|
+
const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
|
|
7407
|
+
const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
|
|
7408
|
+
return [lambda2 * RADIANS_TO_DEGREES, phi2 * RADIANS_TO_DEGREES];
|
|
7213
7409
|
}
|
|
7214
|
-
|
|
7215
|
-
|
|
7410
|
+
|
|
7411
|
+
// ../../node_modules/@math.gl/web-mercator/dist/get-bounds.js
|
|
7412
|
+
var DEGREES_TO_RADIANS2 = Math.PI / 180;
|
|
7413
|
+
|
|
7414
|
+
// src/layers/quadbin-utils.ts
|
|
7415
|
+
var TILE_SIZE2 = 512;
|
|
7416
|
+
function quadbinToOffset(quadbin) {
|
|
7417
|
+
const { x, y, z } = cellToTile(quadbin);
|
|
7418
|
+
const scale = TILE_SIZE2 / (1 << z);
|
|
7419
|
+
return [x * scale, TILE_SIZE2 - y * scale, scale];
|
|
7216
7420
|
}
|
|
7217
|
-
function
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
};
|
|
7230
|
-
scale.copy = () => {
|
|
7231
|
-
const scaleCopy = scaleIdentity();
|
|
7232
|
-
scaleCopy.unknown(unknown);
|
|
7233
|
-
return scaleCopy;
|
|
7234
|
-
};
|
|
7235
|
-
return scale;
|
|
7421
|
+
function quadbinToWorldBounds(quadbin, coverage) {
|
|
7422
|
+
const [xOffset, yOffset, scale] = quadbinToOffset(quadbin);
|
|
7423
|
+
return [
|
|
7424
|
+
[xOffset, yOffset],
|
|
7425
|
+
[xOffset + coverage * scale, yOffset - coverage * scale]
|
|
7426
|
+
];
|
|
7427
|
+
}
|
|
7428
|
+
function getQuadbinPolygon(quadbin, coverage = 1) {
|
|
7429
|
+
const [topLeft, bottomRight] = quadbinToWorldBounds(quadbin, coverage);
|
|
7430
|
+
const [w, n] = worldToLngLat(topLeft);
|
|
7431
|
+
const [e, s] = worldToLngLat(bottomRight);
|
|
7432
|
+
return [e, n, e, s, w, s, w, n, e, n];
|
|
7236
7433
|
}
|
|
7237
|
-
var isObject = (x) => x !== null && typeof x === "object";
|
|
7238
|
-
var isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
|
|
7239
7434
|
|
|
7240
|
-
// src/layers/schema/
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
}
|
|
7247
|
-
};
|
|
7248
|
-
var CartoRasterTileLoader = {
|
|
7249
|
-
name: "CARTO Raster Tile",
|
|
7250
|
-
version: VERSION,
|
|
7251
|
-
id,
|
|
7252
|
-
module: "carto",
|
|
7253
|
-
extensions: ["pbf"],
|
|
7254
|
-
mimeTypes: ["application/vnd.carto-raster-tile"],
|
|
7255
|
-
category: "geometry",
|
|
7256
|
-
parse: async (arrayBuffer, options) => parseCartoRasterTile(arrayBuffer, options),
|
|
7257
|
-
parseSync: parseCartoRasterTile,
|
|
7258
|
-
worker: true,
|
|
7259
|
-
options: DEFAULT_OPTIONS
|
|
7260
|
-
};
|
|
7261
|
-
function parseCartoRasterTile(arrayBuffer, options) {
|
|
7262
|
-
if (!arrayBuffer)
|
|
7263
|
-
return null;
|
|
7264
|
-
const { bands, blockSize } = parsePbf(arrayBuffer, TileReader);
|
|
7265
|
-
const numericProps = {};
|
|
7266
|
-
for (let i = 0; i < bands.length; i++) {
|
|
7267
|
-
const { name, data } = bands[i];
|
|
7268
|
-
numericProps[name] = data;
|
|
7269
|
-
}
|
|
7270
|
-
return { blockSize, cells: { numericProps, properties: [] } };
|
|
7435
|
+
// src/layers/schema/fast-pbf.ts
|
|
7436
|
+
function readPackedTypedArray(TypedArray, pbf, obj) {
|
|
7437
|
+
const end = pbf.type === 2 ? pbf.readVarint() + pbf.pos : pbf.pos + 1;
|
|
7438
|
+
obj.value = new TypedArray(pbf.buf.buffer.slice(pbf.pos, end));
|
|
7439
|
+
pbf.pos = end;
|
|
7440
|
+
return obj.value;
|
|
7271
7441
|
}
|
|
7272
|
-
var carto_raster_tile_loader_default = CartoRasterTileLoader;
|
|
7273
7442
|
|
|
7274
7443
|
// src/layers/schema/carto-tile.ts
|
|
7275
7444
|
var KeyValueObjectReader = class {
|
|
@@ -7452,9 +7621,9 @@ var __exports__ = (() => {
|
|
|
7452
7621
|
obj.fields.push(FieldsReader.read(pbf, pbf.readVarint() + pbf.pos));
|
|
7453
7622
|
}
|
|
7454
7623
|
};
|
|
7455
|
-
var
|
|
7624
|
+
var TileReader = class {
|
|
7456
7625
|
static read(pbf, end) {
|
|
7457
|
-
return pbf.readFields(
|
|
7626
|
+
return pbf.readFields(TileReader._readField, { points: null, lines: null, polygons: null }, end);
|
|
7458
7627
|
}
|
|
7459
7628
|
static _readField(tag, obj, pbf) {
|
|
7460
7629
|
if (tag === 1)
|
|
@@ -7466,176 +7635,513 @@ var __exports__ = (() => {
|
|
|
7466
7635
|
}
|
|
7467
7636
|
};
|
|
7468
7637
|
|
|
7469
|
-
// src/layers/schema/carto-spatial-tile.ts
|
|
7470
|
-
var IndicesReader = class {
|
|
7471
|
-
static read(pbf, end) {
|
|
7472
|
-
return pbf.readFields(IndicesReader._readField, { value: [] }, end);
|
|
7473
|
-
}
|
|
7474
|
-
static _readField(tag, obj, pbf) {
|
|
7475
|
-
if (tag === 1)
|
|
7476
|
-
readPackedTypedArray(BigUint64Array, pbf, obj);
|
|
7477
|
-
}
|
|
7638
|
+
// src/layers/schema/carto-spatial-tile.ts
|
|
7639
|
+
var IndicesReader = class {
|
|
7640
|
+
static read(pbf, end) {
|
|
7641
|
+
return pbf.readFields(IndicesReader._readField, { value: [] }, end);
|
|
7642
|
+
}
|
|
7643
|
+
static _readField(tag, obj, pbf) {
|
|
7644
|
+
if (tag === 1)
|
|
7645
|
+
readPackedTypedArray(BigUint64Array, pbf, obj);
|
|
7646
|
+
}
|
|
7647
|
+
};
|
|
7648
|
+
var CellsReader = class {
|
|
7649
|
+
static read(pbf, end) {
|
|
7650
|
+
return pbf.readFields(
|
|
7651
|
+
CellsReader._readField,
|
|
7652
|
+
{ indices: null, properties: [], numericProps: {} },
|
|
7653
|
+
end
|
|
7654
|
+
);
|
|
7655
|
+
}
|
|
7656
|
+
static _readField(tag, obj, pbf) {
|
|
7657
|
+
if (tag === 1)
|
|
7658
|
+
obj.indices = IndicesReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
7659
|
+
else if (tag === 2)
|
|
7660
|
+
obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));
|
|
7661
|
+
else if (tag === 3) {
|
|
7662
|
+
const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
7663
|
+
obj.numericProps[entry.key] = entry.value;
|
|
7664
|
+
}
|
|
7665
|
+
}
|
|
7666
|
+
};
|
|
7667
|
+
var TileReader2 = class {
|
|
7668
|
+
static read(pbf, end) {
|
|
7669
|
+
return pbf.readFields(TileReader2._readField, { scheme: 0, cells: null }, end);
|
|
7670
|
+
}
|
|
7671
|
+
static _readField(tag, obj, pbf) {
|
|
7672
|
+
if (tag === 1)
|
|
7673
|
+
obj.scheme = pbf.readVarint();
|
|
7674
|
+
else if (tag === 2)
|
|
7675
|
+
obj.cells = CellsReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
7676
|
+
}
|
|
7677
|
+
};
|
|
7678
|
+
|
|
7679
|
+
// src/layers/schema/tile-loader-utils.ts
|
|
7680
|
+
var import_pbf = __toESM(require_pbf(), 1);
|
|
7681
|
+
function parsePbf(buffer, TileReader5) {
|
|
7682
|
+
const pbf = new import_pbf.default(buffer);
|
|
7683
|
+
const tile = TileReader5.read(pbf);
|
|
7684
|
+
return tile;
|
|
7685
|
+
}
|
|
7686
|
+
|
|
7687
|
+
// src/utils.ts
|
|
7688
|
+
var import_core = __toESM(require_core2(), 1);
|
|
7689
|
+
function assert2(condition, message) {
|
|
7690
|
+
import_core.log.assert(condition, message);
|
|
7691
|
+
}
|
|
7692
|
+
function createBinaryProxy(data, index2) {
|
|
7693
|
+
const { properties, numericProps } = data;
|
|
7694
|
+
return new Proxy(properties[index2] || {}, {
|
|
7695
|
+
get(target, property) {
|
|
7696
|
+
if (property in numericProps) {
|
|
7697
|
+
return numericProps[property].value[index2];
|
|
7698
|
+
}
|
|
7699
|
+
return target[property];
|
|
7700
|
+
},
|
|
7701
|
+
has(target, property) {
|
|
7702
|
+
return property in numericProps || property in target;
|
|
7703
|
+
}
|
|
7704
|
+
});
|
|
7705
|
+
}
|
|
7706
|
+
function getWorkerUrl(id4, version) {
|
|
7707
|
+
return `https://unpkg.com/@deck.gl/carto@${version}/dist/${id4}-worker.js`;
|
|
7708
|
+
}
|
|
7709
|
+
function scaleIdentity() {
|
|
7710
|
+
let unknown;
|
|
7711
|
+
function scale(x) {
|
|
7712
|
+
return x === null ? unknown : x;
|
|
7713
|
+
}
|
|
7714
|
+
scale.invert = scale;
|
|
7715
|
+
scale.domain = scale.range = (d) => d;
|
|
7716
|
+
scale.unknown = (u) => {
|
|
7717
|
+
if (u) {
|
|
7718
|
+
unknown = u;
|
|
7719
|
+
}
|
|
7720
|
+
return unknown;
|
|
7721
|
+
};
|
|
7722
|
+
scale.copy = () => {
|
|
7723
|
+
const scaleCopy = scaleIdentity();
|
|
7724
|
+
scaleCopy.unknown(unknown);
|
|
7725
|
+
return scaleCopy;
|
|
7726
|
+
};
|
|
7727
|
+
return scale;
|
|
7728
|
+
}
|
|
7729
|
+
var isObject = (x) => x !== null && typeof x === "object";
|
|
7730
|
+
var isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
|
|
7731
|
+
|
|
7732
|
+
// src/layers/schema/spatialjson-utils.ts
|
|
7733
|
+
function binaryToSpatialjson(binary) {
|
|
7734
|
+
const { cells, scheme } = binary;
|
|
7735
|
+
const count = cells.indices.value.length;
|
|
7736
|
+
const spatial = [];
|
|
7737
|
+
for (let i = 0; i < count; i++) {
|
|
7738
|
+
const id4 = scheme === "h3" ? bigIntToHex(cells.indices.value[i]) : cells.indices.value[i];
|
|
7739
|
+
const properties = { ...cells.properties[i] };
|
|
7740
|
+
for (const key of Object.keys(cells.numericProps)) {
|
|
7741
|
+
properties[key] = cells.numericProps[key].value[i];
|
|
7742
|
+
}
|
|
7743
|
+
spatial.push({ id: id4, properties });
|
|
7744
|
+
}
|
|
7745
|
+
return spatial;
|
|
7746
|
+
}
|
|
7747
|
+
|
|
7748
|
+
// src/layers/schema/carto-spatial-tile-loader.ts
|
|
7749
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
7750
|
+
var id = "cartoSpatialTile";
|
|
7751
|
+
var DEFAULT_OPTIONS = {
|
|
7752
|
+
cartoSpatialTile: {
|
|
7753
|
+
scheme: "quadbin",
|
|
7754
|
+
workerUrl: getWorkerUrl(id, VERSION)
|
|
7755
|
+
}
|
|
7756
|
+
};
|
|
7757
|
+
var CartoSpatialTileLoader = {
|
|
7758
|
+
name: "CARTO Spatial Tile",
|
|
7759
|
+
version: VERSION,
|
|
7760
|
+
id,
|
|
7761
|
+
module: "carto",
|
|
7762
|
+
extensions: ["pbf"],
|
|
7763
|
+
mimeTypes: ["application/vnd.carto-spatial-tile"],
|
|
7764
|
+
category: "geometry",
|
|
7765
|
+
parse: async (arrayBuffer, options) => parseCartoSpatialTile(arrayBuffer, options),
|
|
7766
|
+
parseSync: parseCartoSpatialTile,
|
|
7767
|
+
worker: true,
|
|
7768
|
+
options: DEFAULT_OPTIONS
|
|
7769
|
+
};
|
|
7770
|
+
function parseCartoSpatialTile(arrayBuffer, options) {
|
|
7771
|
+
if (!arrayBuffer)
|
|
7772
|
+
return null;
|
|
7773
|
+
const tile = parsePbf(arrayBuffer, TileReader2);
|
|
7774
|
+
const { cells } = tile;
|
|
7775
|
+
const scheme = options?.cartoSpatialTile?.scheme;
|
|
7776
|
+
const data = { cells, scheme };
|
|
7777
|
+
return binaryToSpatialjson(data);
|
|
7778
|
+
}
|
|
7779
|
+
var carto_spatial_tile_loader_default = CartoSpatialTileLoader;
|
|
7780
|
+
|
|
7781
|
+
// src/layers/utils.ts
|
|
7782
|
+
var import_core2 = __toESM(require_core2(), 1);
|
|
7783
|
+
var import_core3 = __toESM(require_core2(), 1);
|
|
7784
|
+
function injectAccessToken(loadOptions, accessToken) {
|
|
7785
|
+
if (!loadOptions?.fetch?.headers?.Authorization) {
|
|
7786
|
+
loadOptions.fetch = {
|
|
7787
|
+
...loadOptions.fetch,
|
|
7788
|
+
headers: { ...loadOptions.fetch?.headers, Authorization: `Bearer ${accessToken}` }
|
|
7789
|
+
};
|
|
7790
|
+
}
|
|
7791
|
+
}
|
|
7792
|
+
function mergeBoundaryData(geometry, properties) {
|
|
7793
|
+
const mapping = {};
|
|
7794
|
+
for (const { geoid, ...rest } of properties.properties) {
|
|
7795
|
+
if (geoid in mapping) {
|
|
7796
|
+
import_core2.log.warn("Duplicate geoid key in boundary mapping, using first occurance")();
|
|
7797
|
+
} else {
|
|
7798
|
+
mapping[geoid] = rest;
|
|
7799
|
+
}
|
|
7800
|
+
}
|
|
7801
|
+
for (const type of ["points", "lines", "polygons"]) {
|
|
7802
|
+
const geom = geometry[type];
|
|
7803
|
+
if (geom.positions.value.length === 0) {
|
|
7804
|
+
continue;
|
|
7805
|
+
}
|
|
7806
|
+
geom.properties = geom.properties.map(({ geoid }) => mapping[geoid]);
|
|
7807
|
+
const { positions, globalFeatureIds } = geom;
|
|
7808
|
+
let indices = null;
|
|
7809
|
+
if (type === "lines")
|
|
7810
|
+
indices = geom.pathIndices.value;
|
|
7811
|
+
if (type === "polygons")
|
|
7812
|
+
indices = geom.polygonIndices.value;
|
|
7813
|
+
const length = positions.value.length / positions.size;
|
|
7814
|
+
for (const key in properties.numericProps) {
|
|
7815
|
+
const sourceProp = properties.numericProps[key].value;
|
|
7816
|
+
const TypedArray = sourceProp.constructor;
|
|
7817
|
+
const destProp = new TypedArray(length);
|
|
7818
|
+
geom.numericProps[key] = { value: destProp, size: 1 };
|
|
7819
|
+
if (!indices) {
|
|
7820
|
+
for (let i = 0; i < length; i++) {
|
|
7821
|
+
const featureId = globalFeatureIds.value[i];
|
|
7822
|
+
destProp[i] = sourceProp[featureId];
|
|
7823
|
+
}
|
|
7824
|
+
} else {
|
|
7825
|
+
for (let i = 0; i < indices.length - 1; i++) {
|
|
7826
|
+
const startIndex = indices[i];
|
|
7827
|
+
const endIndex = indices[i + 1];
|
|
7828
|
+
const featureId = globalFeatureIds.value[startIndex];
|
|
7829
|
+
destProp.fill(sourceProp[featureId], startIndex, endIndex);
|
|
7830
|
+
}
|
|
7831
|
+
}
|
|
7832
|
+
}
|
|
7833
|
+
}
|
|
7834
|
+
return geometry;
|
|
7835
|
+
}
|
|
7836
|
+
var TilejsonPropType = {
|
|
7837
|
+
type: "object",
|
|
7838
|
+
value: null,
|
|
7839
|
+
validate: (value, propType) => propType.optional && value === null || typeof value === "object" && Array.isArray(value.tiles) && value.tiles.every((url) => typeof url === "string"),
|
|
7840
|
+
equal: (value1, value2) => {
|
|
7841
|
+
return (0, import_core3._deepEqual)(value1, value2, 2);
|
|
7842
|
+
},
|
|
7843
|
+
async: true
|
|
7844
|
+
};
|
|
7845
|
+
|
|
7846
|
+
// src/layers/cluster-tile-layer.ts
|
|
7847
|
+
(0, import_core4.registerLoaders)([carto_spatial_tile_loader_default]);
|
|
7848
|
+
var defaultProps = {
|
|
7849
|
+
data: TilejsonPropType,
|
|
7850
|
+
clusterLevel: { type: "number", value: 5, min: 1 },
|
|
7851
|
+
getPosition: {
|
|
7852
|
+
type: "accessor",
|
|
7853
|
+
value: ({ id: id4 }) => getQuadbinPolygon(id4, 0.5).slice(2, 4)
|
|
7854
|
+
},
|
|
7855
|
+
getWeight: { type: "accessor", value: 1 },
|
|
7856
|
+
refinementStrategy: "no-overlap",
|
|
7857
|
+
tileSize: DEFAULT_TILE_SIZE
|
|
7478
7858
|
};
|
|
7479
|
-
var
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7859
|
+
var ClusterGeoJsonLayer = class extends import_geo_layers2.TileLayer {
|
|
7860
|
+
renderLayers() {
|
|
7861
|
+
const visibleTiles = this.state.tileset?.tiles.filter((tile) => {
|
|
7862
|
+
return tile.isLoaded && tile.content && this.state.tileset.isTileVisible(tile);
|
|
7863
|
+
});
|
|
7864
|
+
if (!visibleTiles?.length) {
|
|
7865
|
+
return null;
|
|
7866
|
+
}
|
|
7867
|
+
visibleTiles.sort((a, b) => b.zoom - a.zoom);
|
|
7868
|
+
const { zoom } = this.context.viewport;
|
|
7869
|
+
const { clusterLevel, getPosition, getWeight } = this.props;
|
|
7870
|
+
const properties = extractAggregationProperties(visibleTiles[0]);
|
|
7871
|
+
const data = [];
|
|
7872
|
+
for (const tile of visibleTiles) {
|
|
7873
|
+
const overZoom = Math.round(zoom - tile.zoom);
|
|
7874
|
+
const aggregationLevels = Math.round(clusterLevel) - overZoom;
|
|
7875
|
+
aggregateTile(tile, aggregationLevels, properties, getPosition, getWeight);
|
|
7876
|
+
data.push(...tile.userData[aggregationLevels]);
|
|
7877
|
+
}
|
|
7878
|
+
data.sort((a, b) => Number(b.count - a.count));
|
|
7879
|
+
const clusterIds = data?.map((tile) => tile.id);
|
|
7880
|
+
const needsUpdate = !(0, import_core5._deepEqual)(clusterIds, this.state.clusterIds, 1);
|
|
7881
|
+
this.setState({ clusterIds });
|
|
7882
|
+
if (needsUpdate) {
|
|
7883
|
+
const stats = computeAggregationStats(data, properties);
|
|
7884
|
+
for (const d of data) {
|
|
7885
|
+
d.stats = stats;
|
|
7886
|
+
}
|
|
7887
|
+
this.setState({ data: clustersToBinary(data) });
|
|
7888
|
+
}
|
|
7889
|
+
const props = {
|
|
7890
|
+
...this.props,
|
|
7891
|
+
id: "clusters",
|
|
7892
|
+
data: this.state.data,
|
|
7893
|
+
dataComparator: (data2, oldData) => {
|
|
7894
|
+
const newIds = data2?.points?.properties?.map((tile) => tile.id);
|
|
7895
|
+
const oldIds = oldData?.points?.properties?.map((tile) => tile.id);
|
|
7896
|
+
return (0, import_core5._deepEqual)(newIds, oldIds, 1);
|
|
7897
|
+
}
|
|
7898
|
+
};
|
|
7899
|
+
return new import_layers.GeoJsonLayer(this.getSubLayerProps(props));
|
|
7900
|
+
}
|
|
7901
|
+
getPickingInfo(params) {
|
|
7902
|
+
const info = params.info;
|
|
7903
|
+
if (info.index !== -1) {
|
|
7904
|
+
const { data } = params.sourceLayer.props;
|
|
7905
|
+
info.object = binaryToGeojson(data, {
|
|
7906
|
+
globalFeatureId: info.index
|
|
7907
|
+
});
|
|
7908
|
+
}
|
|
7909
|
+
return info;
|
|
7486
7910
|
}
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
else if (tag === 2)
|
|
7491
|
-
obj.properties.push(PropertiesReader.read(pbf, pbf.readVarint() + pbf.pos));
|
|
7492
|
-
else if (tag === 3) {
|
|
7493
|
-
const entry = NumericPropKeyValueReader.read(pbf, pbf.readVarint() + pbf.pos);
|
|
7494
|
-
obj.numericProps[entry.key] = entry.value;
|
|
7911
|
+
_updateAutoHighlight(info) {
|
|
7912
|
+
for (const layer of this.getSubLayers()) {
|
|
7913
|
+
layer.updateAutoHighlight(info);
|
|
7495
7914
|
}
|
|
7496
7915
|
}
|
|
7916
|
+
filterSubLayer() {
|
|
7917
|
+
return true;
|
|
7918
|
+
}
|
|
7497
7919
|
};
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7920
|
+
ClusterGeoJsonLayer.layerName = "ClusterGeoJsonLayer";
|
|
7921
|
+
ClusterGeoJsonLayer.defaultProps = defaultProps;
|
|
7922
|
+
var ClusterTileLayer = class extends import_core5.CompositeLayer {
|
|
7923
|
+
getLoadOptions() {
|
|
7924
|
+
const loadOptions = super.getLoadOptions() || {};
|
|
7925
|
+
const tileJSON = this.props.data;
|
|
7926
|
+
injectAccessToken(loadOptions, tileJSON.accessToken);
|
|
7927
|
+
loadOptions.cartoSpatialTile = { ...loadOptions.cartoSpatialTile, scheme: "quadbin" };
|
|
7928
|
+
return loadOptions;
|
|
7501
7929
|
}
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7930
|
+
renderLayers() {
|
|
7931
|
+
const tileJSON = this.props.data;
|
|
7932
|
+
if (!tileJSON)
|
|
7933
|
+
return null;
|
|
7934
|
+
const { tiles: data, maxresolution: maxZoom } = tileJSON;
|
|
7935
|
+
return [
|
|
7936
|
+
new ClusterGeoJsonLayer(this.props, {
|
|
7937
|
+
id: `cluster-geojson-layer-${this.props.id}`,
|
|
7938
|
+
data,
|
|
7939
|
+
TilesetClass: QuadbinTileset2D,
|
|
7940
|
+
maxZoom,
|
|
7941
|
+
loadOptions: this.getLoadOptions()
|
|
7942
|
+
})
|
|
7943
|
+
];
|
|
7507
7944
|
}
|
|
7508
7945
|
};
|
|
7946
|
+
ClusterTileLayer.layerName = "ClusterTileLayer";
|
|
7947
|
+
ClusterTileLayer.defaultProps = defaultProps;
|
|
7509
7948
|
|
|
7510
|
-
//
|
|
7511
|
-
var
|
|
7512
|
-
var
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7949
|
+
// src/layers/h3-tile-layer.ts
|
|
7950
|
+
var import_core7 = __toESM(require_core2(), 1);
|
|
7951
|
+
var import_geo_layers5 = __toESM(require_geo_layers(), 1);
|
|
7952
|
+
|
|
7953
|
+
// src/layers/h3-tileset-2d.ts
|
|
7954
|
+
var import_geo_layers3 = __toESM(require_geo_layers(), 1);
|
|
7955
|
+
var import_h3_js = __toESM(require_h3_js(), 1);
|
|
7956
|
+
var MAX_LATITUDE2 = 85.051128;
|
|
7957
|
+
function padBoundingBox({ west, north, east, south }, resolution) {
|
|
7958
|
+
const corners = [
|
|
7959
|
+
[north, east],
|
|
7960
|
+
[south, east],
|
|
7961
|
+
[south, west],
|
|
7962
|
+
[north, west]
|
|
7963
|
+
];
|
|
7964
|
+
const cornerCells = corners.map((c) => (0, import_h3_js.latLngToCell)(c[0], c[1], resolution));
|
|
7965
|
+
const cornerEdgeLengths = cornerCells.map(
|
|
7966
|
+
(c) => Math.max(...(0, import_h3_js.originToDirectedEdges)(c).map((e) => (0, import_h3_js.edgeLength)(e, import_h3_js.UNITS.rads))) * 180 / Math.PI
|
|
7967
|
+
);
|
|
7968
|
+
const bufferLat = Math.max(...cornerEdgeLengths);
|
|
7969
|
+
const bufferLon = Math.min(180, bufferLat / Math.cos((north + south) / 2 * Math.PI / 180));
|
|
7970
|
+
return {
|
|
7971
|
+
north: Math.min(north + bufferLat, MAX_LATITUDE2),
|
|
7972
|
+
east: east + bufferLon,
|
|
7973
|
+
south: Math.max(south - bufferLat, -MAX_LATITUDE2),
|
|
7974
|
+
west: west - bufferLon
|
|
7975
|
+
};
|
|
7523
7976
|
}
|
|
7524
|
-
function
|
|
7525
|
-
|
|
7977
|
+
function getHexagonsInBoundingBox({ west, north, east, south }, resolution) {
|
|
7978
|
+
const longitudeSpan = Math.abs(east - west);
|
|
7979
|
+
if (longitudeSpan > 180) {
|
|
7980
|
+
const nSegments = Math.ceil(longitudeSpan / 180);
|
|
7981
|
+
let h3Indices = [];
|
|
7982
|
+
for (let s = 0; s < nSegments; s++) {
|
|
7983
|
+
const segmentWest = west + s * 180;
|
|
7984
|
+
const segmentEast = Math.min(segmentWest + 179.9999999, east);
|
|
7985
|
+
h3Indices = h3Indices.concat(
|
|
7986
|
+
getHexagonsInBoundingBox({ west: segmentWest, north, east: segmentEast, south }, resolution)
|
|
7987
|
+
);
|
|
7988
|
+
}
|
|
7989
|
+
return [...new Set(h3Indices)];
|
|
7990
|
+
}
|
|
7991
|
+
const polygon = [
|
|
7992
|
+
[north, east],
|
|
7993
|
+
[south, east],
|
|
7994
|
+
[south, west],
|
|
7995
|
+
[north, west],
|
|
7996
|
+
[north, east]
|
|
7997
|
+
];
|
|
7998
|
+
return (0, import_h3_js.polygonToCells)(polygon, resolution);
|
|
7526
7999
|
}
|
|
7527
|
-
function
|
|
7528
|
-
|
|
7529
|
-
|
|
8000
|
+
function tileToBoundingBox(index2) {
|
|
8001
|
+
const coordinates = (0, import_h3_js.cellToBoundary)(index2);
|
|
8002
|
+
const latitudes = coordinates.map((c) => c[0]);
|
|
8003
|
+
const longitudes = coordinates.map((c) => c[1]);
|
|
8004
|
+
const west = Math.min(...longitudes);
|
|
8005
|
+
const south = Math.min(...latitudes);
|
|
8006
|
+
const east = Math.max(...longitudes);
|
|
8007
|
+
const north = Math.max(...latitudes);
|
|
8008
|
+
return { west, south, east, north };
|
|
8009
|
+
}
|
|
8010
|
+
var BIAS = 2;
|
|
8011
|
+
function getHexagonResolution(viewport, tileSize) {
|
|
8012
|
+
const zoomOffset = Math.log2(tileSize / 512);
|
|
8013
|
+
const hexagonScaleFactor = 2 / 3 * (viewport.zoom - zoomOffset);
|
|
8014
|
+
const latitudeScaleFactor = Math.log(1 / Math.cos(Math.PI * viewport.latitude / 180));
|
|
8015
|
+
return Math.max(0, Math.floor(hexagonScaleFactor + latitudeScaleFactor - BIAS));
|
|
8016
|
+
}
|
|
8017
|
+
var H3Tileset2D = class extends import_geo_layers3._Tileset2D {
|
|
8018
|
+
getTileIndices({ viewport, minZoom, maxZoom }) {
|
|
8019
|
+
if (viewport.latitude === void 0)
|
|
8020
|
+
return [];
|
|
8021
|
+
const [west, south, east, north] = viewport.getBounds();
|
|
8022
|
+
const { tileSize } = this.opts;
|
|
8023
|
+
let z = getHexagonResolution(viewport, tileSize);
|
|
8024
|
+
let indices;
|
|
8025
|
+
if (typeof minZoom === "number" && Number.isFinite(minZoom) && z < minZoom) {
|
|
8026
|
+
return [];
|
|
8027
|
+
}
|
|
8028
|
+
if (typeof maxZoom === "number" && Number.isFinite(maxZoom) && z > maxZoom) {
|
|
8029
|
+
z = maxZoom;
|
|
8030
|
+
const center = (0, import_h3_js.latLngToCell)(viewport.latitude, viewport.longitude, maxZoom);
|
|
8031
|
+
indices = (0, import_h3_js.gridDisk)(center, 1);
|
|
8032
|
+
} else {
|
|
8033
|
+
const paddedBounds = padBoundingBox({ west, north, east, south }, z);
|
|
8034
|
+
indices = getHexagonsInBoundingBox(paddedBounds, z);
|
|
8035
|
+
}
|
|
8036
|
+
return indices.map((i) => ({ i }));
|
|
7530
8037
|
}
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
let y = BigInt(tile.y) << 32n - z;
|
|
7534
|
-
for (let i = 0; i < 5; i++) {
|
|
7535
|
-
const s = S[5 - i];
|
|
7536
|
-
const b = B[4 - i];
|
|
7537
|
-
x = (x | x << s) & b;
|
|
7538
|
-
y = (y | y << s) & b;
|
|
8038
|
+
getTileId({ i }) {
|
|
8039
|
+
return i;
|
|
7539
8040
|
}
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
}
|
|
7543
|
-
function cellToTile(quadbin) {
|
|
7544
|
-
const mode = quadbin >> 59n & 7n;
|
|
7545
|
-
const modeDep = quadbin >> 57n & 3n;
|
|
7546
|
-
const z = quadbin >> 52n & 0x1fn;
|
|
7547
|
-
const q = (quadbin & 0xfffffffffffffn) << 12n;
|
|
7548
|
-
if (mode !== 1n && modeDep !== 0n) {
|
|
7549
|
-
throw new Error("Wrong mode");
|
|
8041
|
+
getTileMetadata({ i }) {
|
|
8042
|
+
return { bbox: tileToBoundingBox(i) };
|
|
7550
8043
|
}
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
const
|
|
7556
|
-
|
|
7557
|
-
|
|
8044
|
+
getTileZoom({ i }) {
|
|
8045
|
+
return (0, import_h3_js.getResolution)(i);
|
|
8046
|
+
}
|
|
8047
|
+
getParentIndex(index2) {
|
|
8048
|
+
const resolution = (0, import_h3_js.getResolution)(index2.i);
|
|
8049
|
+
const i = (0, import_h3_js.cellToParent)(index2.i, resolution - 1);
|
|
8050
|
+
return { i };
|
|
8051
|
+
}
|
|
8052
|
+
};
|
|
8053
|
+
|
|
8054
|
+
// src/layers/spatial-index-tile-layer.ts
|
|
8055
|
+
var import_core6 = __toESM(require_core(), 1);
|
|
8056
|
+
|
|
8057
|
+
// src/layers/schema/carto-raster-tile.ts
|
|
8058
|
+
var ARRAY_TYPES = {
|
|
8059
|
+
uint8: Uint8Array,
|
|
8060
|
+
uint16: Uint16Array,
|
|
8061
|
+
uint32: Uint32Array,
|
|
8062
|
+
uint64: BigUint64Array,
|
|
8063
|
+
int8: Int8Array,
|
|
8064
|
+
int16: Int16Array,
|
|
8065
|
+
int32: Int32Array,
|
|
8066
|
+
int64: BigInt64Array,
|
|
8067
|
+
float32: Float32Array,
|
|
8068
|
+
float64: Float64Array
|
|
8069
|
+
};
|
|
8070
|
+
var BandReader = class {
|
|
8071
|
+
static read(pbf, end) {
|
|
8072
|
+
return pbf.readFields(BandReader._readField, { name: "", type: "", data: null }, end);
|
|
7558
8073
|
}
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
// src/layers/schema/spatialjson-utils.ts
|
|
7573
|
-
function binaryToSpatialjson(binary) {
|
|
7574
|
-
const { cells, scheme } = binary;
|
|
7575
|
-
const count = cells.indices.value.length;
|
|
7576
|
-
const spatial = [];
|
|
7577
|
-
for (let i = 0; i < count; i++) {
|
|
7578
|
-
const id4 = scheme === "h3" ? bigIntToHex(cells.indices.value[i]) : cells.indices.value[i];
|
|
7579
|
-
const properties = { ...cells.properties[i] };
|
|
7580
|
-
for (const key of Object.keys(cells.numericProps)) {
|
|
7581
|
-
properties[key] = cells.numericProps[key].value[i];
|
|
8074
|
+
static _readField(tag, obj, pbf) {
|
|
8075
|
+
if (tag === 1)
|
|
8076
|
+
obj.name = pbf.readString();
|
|
8077
|
+
else if (tag === 2)
|
|
8078
|
+
obj.type = pbf.readString();
|
|
8079
|
+
else if (tag === 3) {
|
|
8080
|
+
const TypedArray = ARRAY_TYPES[obj.type];
|
|
8081
|
+
if (!TypedArray) {
|
|
8082
|
+
throw Error(`Invalid data type: ${obj.type}`);
|
|
8083
|
+
}
|
|
8084
|
+
obj.data = {};
|
|
8085
|
+
readPackedTypedArray(TypedArray, pbf, obj.data);
|
|
7582
8086
|
}
|
|
7583
|
-
spatial.push({ id: id4, properties });
|
|
7584
8087
|
}
|
|
7585
|
-
|
|
7586
|
-
|
|
8088
|
+
};
|
|
8089
|
+
var TileReader3 = class {
|
|
8090
|
+
static read(pbf, end) {
|
|
8091
|
+
return pbf.readFields(TileReader3._readField, { blockSize: 0, bands: [] }, end);
|
|
8092
|
+
}
|
|
8093
|
+
static _readField(tag, obj, pbf) {
|
|
8094
|
+
if (tag === 1)
|
|
8095
|
+
obj.blockSize = pbf.readVarint();
|
|
8096
|
+
else if (tag === 2)
|
|
8097
|
+
obj.bands.push(BandReader.read(pbf, pbf.readVarint() + pbf.pos));
|
|
8098
|
+
}
|
|
8099
|
+
};
|
|
7587
8100
|
|
|
7588
|
-
// src/layers/schema/carto-
|
|
8101
|
+
// src/layers/schema/carto-raster-tile-loader.ts
|
|
7589
8102
|
var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
7590
|
-
var id2 = "
|
|
8103
|
+
var id2 = "cartoRasterTile";
|
|
7591
8104
|
var DEFAULT_OPTIONS2 = {
|
|
7592
|
-
|
|
7593
|
-
scheme: "quadbin",
|
|
8105
|
+
cartoRasterTile: {
|
|
7594
8106
|
workerUrl: getWorkerUrl(id2, VERSION2)
|
|
7595
8107
|
}
|
|
7596
8108
|
};
|
|
7597
|
-
var
|
|
7598
|
-
name: "CARTO
|
|
8109
|
+
var CartoRasterTileLoader = {
|
|
8110
|
+
name: "CARTO Raster Tile",
|
|
7599
8111
|
version: VERSION2,
|
|
7600
8112
|
id: id2,
|
|
7601
8113
|
module: "carto",
|
|
7602
8114
|
extensions: ["pbf"],
|
|
7603
|
-
mimeTypes: ["application/vnd.carto-
|
|
8115
|
+
mimeTypes: ["application/vnd.carto-raster-tile"],
|
|
7604
8116
|
category: "geometry",
|
|
7605
|
-
parse: async (arrayBuffer, options) =>
|
|
7606
|
-
parseSync:
|
|
8117
|
+
parse: async (arrayBuffer, options) => parseCartoRasterTile(arrayBuffer, options),
|
|
8118
|
+
parseSync: parseCartoRasterTile,
|
|
7607
8119
|
worker: true,
|
|
7608
8120
|
options: DEFAULT_OPTIONS2
|
|
7609
8121
|
};
|
|
7610
|
-
function
|
|
8122
|
+
function parseCartoRasterTile(arrayBuffer, options) {
|
|
7611
8123
|
if (!arrayBuffer)
|
|
7612
8124
|
return null;
|
|
7613
|
-
const
|
|
7614
|
-
const
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
8125
|
+
const { bands, blockSize } = parsePbf(arrayBuffer, TileReader3);
|
|
8126
|
+
const numericProps = {};
|
|
8127
|
+
for (let i = 0; i < bands.length; i++) {
|
|
8128
|
+
const { name, data } = bands[i];
|
|
8129
|
+
numericProps[name] = data;
|
|
8130
|
+
}
|
|
8131
|
+
return { blockSize, cells: { numericProps, properties: [] } };
|
|
7618
8132
|
}
|
|
7619
|
-
var
|
|
7620
|
-
|
|
7621
|
-
// src/layers/spatial-index-tile-layer.ts
|
|
7622
|
-
var import_geo_layers2 = __toESM(require_geo_layers(), 1);
|
|
7623
|
-
|
|
7624
|
-
// src/constants.ts
|
|
7625
|
-
var DEFAULT_TILE_SIZE = 512;
|
|
7626
|
-
var DEFAULT_TILE_RESOLUTION = 0.5;
|
|
7627
|
-
var DEFAULT_AGGREGATION_RES_LEVEL_H3 = 4;
|
|
7628
|
-
var DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = 6;
|
|
8133
|
+
var carto_raster_tile_loader_default = CartoRasterTileLoader;
|
|
7629
8134
|
|
|
7630
8135
|
// src/layers/spatial-index-tile-layer.ts
|
|
7631
|
-
(
|
|
8136
|
+
var import_geo_layers4 = __toESM(require_geo_layers(), 1);
|
|
8137
|
+
(0, import_core6.registerLoaders)([carto_raster_tile_loader_default, carto_spatial_tile_loader_default]);
|
|
7632
8138
|
function isFeatureIdDefined(value) {
|
|
7633
8139
|
return value !== void 0 && value !== null && value !== "";
|
|
7634
8140
|
}
|
|
7635
|
-
var
|
|
8141
|
+
var defaultProps2 = {
|
|
7636
8142
|
tileSize: DEFAULT_TILE_SIZE
|
|
7637
8143
|
};
|
|
7638
|
-
var SpatialIndexTileLayer = class extends
|
|
8144
|
+
var SpatialIndexTileLayer = class extends import_geo_layers4.TileLayer {
|
|
7639
8145
|
_updateAutoHighlight(info) {
|
|
7640
8146
|
const { hoveredFeatureId } = this.state;
|
|
7641
8147
|
const hoveredFeature = info.object;
|
|
@@ -7683,72 +8189,7 @@ var __exports__ = (() => {
|
|
|
7683
8189
|
}
|
|
7684
8190
|
};
|
|
7685
8191
|
SpatialIndexTileLayer.layerName = "SpatialIndexTileLayer";
|
|
7686
|
-
SpatialIndexTileLayer.defaultProps =
|
|
7687
|
-
|
|
7688
|
-
// src/layers/utils.ts
|
|
7689
|
-
var import_core3 = __toESM(require_core(), 1);
|
|
7690
|
-
var import_core4 = __toESM(require_core(), 1);
|
|
7691
|
-
function injectAccessToken(loadOptions, accessToken) {
|
|
7692
|
-
if (!loadOptions?.fetch?.headers?.Authorization) {
|
|
7693
|
-
loadOptions.fetch = {
|
|
7694
|
-
...loadOptions.fetch,
|
|
7695
|
-
headers: { ...loadOptions.fetch?.headers, Authorization: `Bearer ${accessToken}` }
|
|
7696
|
-
};
|
|
7697
|
-
}
|
|
7698
|
-
}
|
|
7699
|
-
function mergeBoundaryData(geometry, properties) {
|
|
7700
|
-
const mapping = {};
|
|
7701
|
-
for (const { geoid, ...rest } of properties.properties) {
|
|
7702
|
-
if (geoid in mapping) {
|
|
7703
|
-
import_core3.log.warn("Duplicate geoid key in boundary mapping, using first occurance")();
|
|
7704
|
-
} else {
|
|
7705
|
-
mapping[geoid] = rest;
|
|
7706
|
-
}
|
|
7707
|
-
}
|
|
7708
|
-
for (const type of ["points", "lines", "polygons"]) {
|
|
7709
|
-
const geom = geometry[type];
|
|
7710
|
-
if (geom.positions.value.length === 0) {
|
|
7711
|
-
continue;
|
|
7712
|
-
}
|
|
7713
|
-
geom.properties = geom.properties.map(({ geoid }) => mapping[geoid]);
|
|
7714
|
-
const { positions, globalFeatureIds } = geom;
|
|
7715
|
-
let indices = null;
|
|
7716
|
-
if (type === "lines")
|
|
7717
|
-
indices = geom.pathIndices.value;
|
|
7718
|
-
if (type === "polygons")
|
|
7719
|
-
indices = geom.polygonIndices.value;
|
|
7720
|
-
const length = positions.value.length / positions.size;
|
|
7721
|
-
for (const key in properties.numericProps) {
|
|
7722
|
-
const sourceProp = properties.numericProps[key].value;
|
|
7723
|
-
const TypedArray = sourceProp.constructor;
|
|
7724
|
-
const destProp = new TypedArray(length);
|
|
7725
|
-
geom.numericProps[key] = { value: destProp, size: 1 };
|
|
7726
|
-
if (!indices) {
|
|
7727
|
-
for (let i = 0; i < length; i++) {
|
|
7728
|
-
const featureId = globalFeatureIds.value[i];
|
|
7729
|
-
destProp[i] = sourceProp[featureId];
|
|
7730
|
-
}
|
|
7731
|
-
} else {
|
|
7732
|
-
for (let i = 0; i < indices.length - 1; i++) {
|
|
7733
|
-
const startIndex = indices[i];
|
|
7734
|
-
const endIndex = indices[i + 1];
|
|
7735
|
-
const featureId = globalFeatureIds.value[startIndex];
|
|
7736
|
-
destProp.fill(sourceProp[featureId], startIndex, endIndex);
|
|
7737
|
-
}
|
|
7738
|
-
}
|
|
7739
|
-
}
|
|
7740
|
-
}
|
|
7741
|
-
return geometry;
|
|
7742
|
-
}
|
|
7743
|
-
var TilejsonPropType = {
|
|
7744
|
-
type: "object",
|
|
7745
|
-
value: null,
|
|
7746
|
-
validate: (value, propType) => propType.optional && value === null || typeof value === "object" && Array.isArray(value.tiles) && value.tiles.every((url) => typeof url === "string"),
|
|
7747
|
-
equal: (value1, value2) => {
|
|
7748
|
-
return (0, import_core4._deepEqual)(value1, value2, 2);
|
|
7749
|
-
},
|
|
7750
|
-
async: true
|
|
7751
|
-
};
|
|
8192
|
+
SpatialIndexTileLayer.defaultProps = defaultProps2;
|
|
7752
8193
|
|
|
7753
8194
|
// src/layers/h3-tile-layer.ts
|
|
7754
8195
|
var renderSubLayers = (props) => {
|
|
@@ -7756,19 +8197,19 @@ var __exports__ = (() => {
|
|
|
7756
8197
|
const { index: index2 } = props.tile;
|
|
7757
8198
|
if (!data || !data.length)
|
|
7758
8199
|
return null;
|
|
7759
|
-
return new
|
|
8200
|
+
return new import_geo_layers5.H3HexagonLayer(props, {
|
|
7760
8201
|
getHexagon: (d) => d.id,
|
|
7761
8202
|
centerHexagon: index2,
|
|
7762
8203
|
highPrecision: true
|
|
7763
8204
|
});
|
|
7764
8205
|
};
|
|
7765
|
-
var
|
|
8206
|
+
var defaultProps3 = {
|
|
7766
8207
|
data: TilejsonPropType,
|
|
7767
8208
|
tileSize: DEFAULT_TILE_SIZE
|
|
7768
8209
|
};
|
|
7769
|
-
var H3TileLayer = class extends
|
|
8210
|
+
var H3TileLayer = class extends import_core7.CompositeLayer {
|
|
7770
8211
|
initializeState() {
|
|
7771
|
-
|
|
8212
|
+
import_geo_layers5.H3HexagonLayer._checkH3Lib();
|
|
7772
8213
|
}
|
|
7773
8214
|
getLoadOptions() {
|
|
7774
8215
|
const loadOptions = super.getLoadOptions() || {};
|
|
@@ -7809,11 +8250,11 @@ var __exports__ = (() => {
|
|
|
7809
8250
|
}
|
|
7810
8251
|
};
|
|
7811
8252
|
H3TileLayer.layerName = "H3TileLayer";
|
|
7812
|
-
H3TileLayer.defaultProps =
|
|
8253
|
+
H3TileLayer.defaultProps = defaultProps3;
|
|
7813
8254
|
|
|
7814
8255
|
// src/layers/heatmap-tile-layer.ts
|
|
7815
|
-
var
|
|
7816
|
-
var
|
|
8256
|
+
var import_core10 = __toESM(require_core2(), 1);
|
|
8257
|
+
var import_layers2 = __toESM(require_layers(), 1);
|
|
7817
8258
|
|
|
7818
8259
|
// src/layers/heatmap.ts
|
|
7819
8260
|
var glsl = (s) => `${s}`;
|
|
@@ -7990,7 +8431,7 @@ vec4 heatmap_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
7990
8431
|
};
|
|
7991
8432
|
|
|
7992
8433
|
// src/layers/post-process-utils.ts
|
|
7993
|
-
var
|
|
8434
|
+
var import_core8 = __toESM(require_core2(), 1);
|
|
7994
8435
|
var TEXTURE_PROPS = {
|
|
7995
8436
|
format: "rgba8unorm",
|
|
7996
8437
|
mipmaps: false,
|
|
@@ -8007,7 +8448,7 @@ vec4 heatmap_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
8007
8448
|
}
|
|
8008
8449
|
return layer;
|
|
8009
8450
|
}
|
|
8010
|
-
var DrawCallbackLayer = class extends
|
|
8451
|
+
var DrawCallbackLayer = class extends import_core8.Layer {
|
|
8011
8452
|
initializeState() {
|
|
8012
8453
|
this.id = `draw-callback-${getPostProcessLayer(this).props.id}`;
|
|
8013
8454
|
}
|
|
@@ -8039,7 +8480,7 @@ vec4 heatmap_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
8039
8480
|
initializeState(context) {
|
|
8040
8481
|
super.initializeState(context);
|
|
8041
8482
|
this._createTextures();
|
|
8042
|
-
this.internalState.postProcess = new
|
|
8483
|
+
this.internalState.postProcess = new import_core8.PostProcessEffect(effect, this.props);
|
|
8043
8484
|
this.internalState.postProcess.setup(context);
|
|
8044
8485
|
}
|
|
8045
8486
|
updateState(params) {
|
|
@@ -8104,53 +8545,14 @@ vec4 heatmap_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
8104
8545
|
}
|
|
8105
8546
|
|
|
8106
8547
|
// src/layers/quadbin-tile-layer.ts
|
|
8107
|
-
var
|
|
8108
|
-
|
|
8109
|
-
// src/layers/quadbin-layer.ts
|
|
8110
|
-
var import_geo_layers4 = __toESM(require_geo_layers(), 1);
|
|
8111
|
-
|
|
8112
|
-
// ../../node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js
|
|
8113
|
-
var PI = Math.PI;
|
|
8114
|
-
var PI_4 = PI / 4;
|
|
8115
|
-
var DEGREES_TO_RADIANS = PI / 180;
|
|
8116
|
-
var RADIANS_TO_DEGREES = 180 / PI;
|
|
8117
|
-
var TILE_SIZE = 512;
|
|
8118
|
-
function worldToLngLat(xy) {
|
|
8119
|
-
const [x, y] = xy;
|
|
8120
|
-
const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
|
|
8121
|
-
const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
|
|
8122
|
-
return [lambda2 * RADIANS_TO_DEGREES, phi2 * RADIANS_TO_DEGREES];
|
|
8123
|
-
}
|
|
8124
|
-
|
|
8125
|
-
// ../../node_modules/@math.gl/web-mercator/dist/get-bounds.js
|
|
8126
|
-
var DEGREES_TO_RADIANS2 = Math.PI / 180;
|
|
8127
|
-
|
|
8128
|
-
// src/layers/quadbin-utils.ts
|
|
8129
|
-
var TILE_SIZE2 = 512;
|
|
8130
|
-
function quadbinToOffset(quadbin) {
|
|
8131
|
-
const { x, y, z } = cellToTile(quadbin);
|
|
8132
|
-
const scale = TILE_SIZE2 / (1 << z);
|
|
8133
|
-
return [x * scale, TILE_SIZE2 - y * scale, scale];
|
|
8134
|
-
}
|
|
8135
|
-
function quadbinToWorldBounds(quadbin, coverage) {
|
|
8136
|
-
const [xOffset, yOffset, scale] = quadbinToOffset(quadbin);
|
|
8137
|
-
return [
|
|
8138
|
-
[xOffset, yOffset],
|
|
8139
|
-
[xOffset + coverage * scale, yOffset - coverage * scale]
|
|
8140
|
-
];
|
|
8141
|
-
}
|
|
8142
|
-
function getQuadbinPolygon(quadbin, coverage = 1) {
|
|
8143
|
-
const [topLeft, bottomRight] = quadbinToWorldBounds(quadbin, coverage);
|
|
8144
|
-
const [w, n] = worldToLngLat(topLeft);
|
|
8145
|
-
const [e, s] = worldToLngLat(bottomRight);
|
|
8146
|
-
return [e, n, e, s, w, s, w, n, e, n];
|
|
8147
|
-
}
|
|
8548
|
+
var import_core9 = __toESM(require_core2(), 1);
|
|
8148
8549
|
|
|
8149
8550
|
// src/layers/quadbin-layer.ts
|
|
8150
|
-
var
|
|
8551
|
+
var import_geo_layers6 = __toESM(require_geo_layers(), 1);
|
|
8552
|
+
var defaultProps4 = {
|
|
8151
8553
|
getQuadbin: { type: "accessor", value: (d) => d.quadbin }
|
|
8152
8554
|
};
|
|
8153
|
-
var QuadbinLayer = class extends
|
|
8555
|
+
var QuadbinLayer = class extends import_geo_layers6._GeoCellLayer {
|
|
8154
8556
|
indexToBounds() {
|
|
8155
8557
|
const { data, extruded, getQuadbin } = this.props;
|
|
8156
8558
|
const coverage = extruded ? 0.99 : 1;
|
|
@@ -8164,27 +8566,7 @@ vec4 heatmap_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
8164
8566
|
}
|
|
8165
8567
|
};
|
|
8166
8568
|
QuadbinLayer.layerName = "QuadbinLayer";
|
|
8167
|
-
QuadbinLayer.defaultProps =
|
|
8168
|
-
|
|
8169
|
-
// src/layers/quadbin-tileset-2d.ts
|
|
8170
|
-
var import_geo_layers5 = __toESM(require_geo_layers(), 1);
|
|
8171
|
-
var QuadbinTileset2D = class extends import_geo_layers5._Tileset2D {
|
|
8172
|
-
getTileIndices(opts) {
|
|
8173
|
-
return super.getTileIndices(opts).map(tileToCell).map((q) => ({ q, i: bigIntToHex(q) }));
|
|
8174
|
-
}
|
|
8175
|
-
getTileId({ q, i }) {
|
|
8176
|
-
return i || bigIntToHex(q);
|
|
8177
|
-
}
|
|
8178
|
-
getTileMetadata({ q }) {
|
|
8179
|
-
return super.getTileMetadata(cellToTile(q));
|
|
8180
|
-
}
|
|
8181
|
-
getTileZoom({ q }) {
|
|
8182
|
-
return Number(getResolution2(q));
|
|
8183
|
-
}
|
|
8184
|
-
getParentIndex({ q }) {
|
|
8185
|
-
return { q: cellToParent2(q) };
|
|
8186
|
-
}
|
|
8187
|
-
};
|
|
8569
|
+
QuadbinLayer.defaultProps = defaultProps4;
|
|
8188
8570
|
|
|
8189
8571
|
// src/layers/quadbin-tile-layer.ts
|
|
8190
8572
|
var renderSubLayers2 = (props) => {
|
|
@@ -8196,11 +8578,11 @@ vec4 heatmap_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
8196
8578
|
getQuadbin: isBigInt ? (d) => d.id : (d) => hexToBigInt(d.id)
|
|
8197
8579
|
});
|
|
8198
8580
|
};
|
|
8199
|
-
var
|
|
8581
|
+
var defaultProps5 = {
|
|
8200
8582
|
data: TilejsonPropType,
|
|
8201
8583
|
tileSize: DEFAULT_TILE_SIZE
|
|
8202
8584
|
};
|
|
8203
|
-
var QuadbinTileLayer = class extends
|
|
8585
|
+
var QuadbinTileLayer = class extends import_core9.CompositeLayer {
|
|
8204
8586
|
getLoadOptions() {
|
|
8205
8587
|
const loadOptions = super.getLoadOptions() || {};
|
|
8206
8588
|
const tileJSON = this.props.data;
|
|
@@ -8226,14 +8608,14 @@ vec4 heatmap_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
8226
8608
|
}
|
|
8227
8609
|
};
|
|
8228
8610
|
QuadbinTileLayer.layerName = "QuadbinTileLayer";
|
|
8229
|
-
QuadbinTileLayer.defaultProps =
|
|
8611
|
+
QuadbinTileLayer.defaultProps = defaultProps5;
|
|
8230
8612
|
|
|
8231
8613
|
// src/layers/heatmap-tile-layer.ts
|
|
8232
8614
|
function unitDensityForCell(cell) {
|
|
8233
|
-
const cellResolution = Number(
|
|
8615
|
+
const cellResolution = Number(getResolution(cell));
|
|
8234
8616
|
return Math.pow(4, cellResolution);
|
|
8235
8617
|
}
|
|
8236
|
-
var RTTSolidPolygonLayer = class extends RTTModifier(
|
|
8618
|
+
var RTTSolidPolygonLayer = class extends RTTModifier(import_layers2.SolidPolygonLayer) {
|
|
8237
8619
|
getShaders(type) {
|
|
8238
8620
|
const shaders = super.getShaders(type);
|
|
8239
8621
|
shaders.inject = {
|
|
@@ -8273,7 +8655,7 @@ uniform float densityFactor;
|
|
|
8273
8655
|
};
|
|
8274
8656
|
RTTSolidPolygonLayer.layerName = "RTTSolidPolygonLayer";
|
|
8275
8657
|
var PostProcessQuadbinTileLayer = PostProcessModifier(QuadbinTileLayer, heatmap);
|
|
8276
|
-
var
|
|
8658
|
+
var defaultProps6 = {
|
|
8277
8659
|
data: TilejsonPropType,
|
|
8278
8660
|
getWeight: { type: "accessor", value: 1 },
|
|
8279
8661
|
onMaxDensityChange: { type: "function", optional: true, value: null },
|
|
@@ -8281,7 +8663,7 @@ uniform float densityFactor;
|
|
|
8281
8663
|
intensity: { type: "number", value: 1 },
|
|
8282
8664
|
radiusPixels: { type: "number", min: 0, max: 100, value: 20 }
|
|
8283
8665
|
};
|
|
8284
|
-
var HeatmapTileLayer = class extends
|
|
8666
|
+
var HeatmapTileLayer = class extends import_core10.CompositeLayer {
|
|
8285
8667
|
initializeState() {
|
|
8286
8668
|
this.state = {
|
|
8287
8669
|
isLoaded: false,
|
|
@@ -8390,14 +8772,14 @@ uniform float densityFactor;
|
|
|
8390
8772
|
}
|
|
8391
8773
|
};
|
|
8392
8774
|
HeatmapTileLayer.layerName = "HeatmapTileLayer";
|
|
8393
|
-
HeatmapTileLayer.defaultProps =
|
|
8775
|
+
HeatmapTileLayer.defaultProps = defaultProps6;
|
|
8394
8776
|
var heatmap_tile_layer_default = HeatmapTileLayer;
|
|
8395
8777
|
|
|
8396
8778
|
// src/layers/point-label-layer.ts
|
|
8397
|
-
var
|
|
8398
|
-
var
|
|
8779
|
+
var import_core11 = __toESM(require_core2(), 1);
|
|
8780
|
+
var import_layers3 = __toESM(require_layers(), 1);
|
|
8399
8781
|
var [LEFT, TOP, RIGHT, BOTTOM] = [0, 1, 2, 3];
|
|
8400
|
-
var EnhancedTextBackgroundLayer = class extends
|
|
8782
|
+
var EnhancedTextBackgroundLayer = class extends import_layers3._TextBackgroundLayer {
|
|
8401
8783
|
getShaders() {
|
|
8402
8784
|
const shaders = super.getShaders();
|
|
8403
8785
|
let vs = shaders.vs;
|
|
@@ -8410,7 +8792,7 @@ uniform float densityFactor;
|
|
|
8410
8792
|
}
|
|
8411
8793
|
};
|
|
8412
8794
|
EnhancedTextBackgroundLayer.layerName = "EnhancedTextBackgroundLayer";
|
|
8413
|
-
var EnhancedTextLayer = class extends
|
|
8795
|
+
var EnhancedTextLayer = class extends import_layers3.TextLayer {
|
|
8414
8796
|
filterSubLayer({ layer, renderPass }) {
|
|
8415
8797
|
const background = layer.id.includes("primary-background");
|
|
8416
8798
|
if (renderPass === "collision") {
|
|
@@ -8420,12 +8802,12 @@ uniform float densityFactor;
|
|
|
8420
8802
|
}
|
|
8421
8803
|
};
|
|
8422
8804
|
EnhancedTextLayer.layerName = "EnhancedTextLayer";
|
|
8423
|
-
var
|
|
8424
|
-
...
|
|
8805
|
+
var defaultProps7 = {
|
|
8806
|
+
...import_layers3.TextLayer.defaultProps,
|
|
8425
8807
|
getRadius: { type: "accessor", value: 1 },
|
|
8426
8808
|
radiusScale: { type: "number", min: 0, value: 1 }
|
|
8427
8809
|
};
|
|
8428
|
-
var PointLabelLayer = class extends
|
|
8810
|
+
var PointLabelLayer = class extends import_core11.CompositeLayer {
|
|
8429
8811
|
calculatePixelOffset(secondary) {
|
|
8430
8812
|
const {
|
|
8431
8813
|
getTextAnchor: anchor,
|
|
@@ -8561,14 +8943,14 @@ uniform float densityFactor;
|
|
|
8561
8943
|
}
|
|
8562
8944
|
};
|
|
8563
8945
|
PointLabelLayer.layerName = "PointLabelLayer";
|
|
8564
|
-
PointLabelLayer.defaultProps =
|
|
8946
|
+
PointLabelLayer.defaultProps = defaultProps7;
|
|
8565
8947
|
|
|
8566
8948
|
// src/layers/raster-tile-layer.ts
|
|
8567
|
-
var
|
|
8949
|
+
var import_core13 = __toESM(require_core2(), 1);
|
|
8568
8950
|
|
|
8569
8951
|
// src/layers/raster-layer.ts
|
|
8570
|
-
var
|
|
8571
|
-
var
|
|
8952
|
+
var import_core12 = __toESM(require_core2(), 1);
|
|
8953
|
+
var import_layers4 = __toESM(require_layers(), 1);
|
|
8572
8954
|
|
|
8573
8955
|
// src/layers/raster-layer-vertex.glsl.ts
|
|
8574
8956
|
var raster_layer_vertex_glsl_default = `#version 300 es
|
|
@@ -8670,8 +9052,8 @@ void main(void) {
|
|
|
8670
9052
|
`;
|
|
8671
9053
|
|
|
8672
9054
|
// src/layers/raster-layer.ts
|
|
8673
|
-
var
|
|
8674
|
-
...
|
|
9055
|
+
var defaultProps8 = {
|
|
9056
|
+
...import_layers4.ColumnLayer.defaultProps,
|
|
8675
9057
|
extruded: false,
|
|
8676
9058
|
diskResolution: 4,
|
|
8677
9059
|
vertices: [
|
|
@@ -8681,7 +9063,7 @@ void main(void) {
|
|
|
8681
9063
|
[-0.5, 0.5]
|
|
8682
9064
|
]
|
|
8683
9065
|
};
|
|
8684
|
-
var RasterColumnLayer = class extends
|
|
9066
|
+
var RasterColumnLayer = class extends import_layers4.ColumnLayer {
|
|
8685
9067
|
getShaders() {
|
|
8686
9068
|
const shaders = super.getShaders();
|
|
8687
9069
|
const data = this.props.data;
|
|
@@ -8714,7 +9096,7 @@ void main(void) {
|
|
|
8714
9096
|
}
|
|
8715
9097
|
};
|
|
8716
9098
|
RasterColumnLayer.layerName = "RasterColumnLayer";
|
|
8717
|
-
var RasterLayer = class extends
|
|
9099
|
+
var RasterLayer = class extends import_core12.CompositeLayer {
|
|
8718
9100
|
renderLayers() {
|
|
8719
9101
|
const {
|
|
8720
9102
|
data,
|
|
@@ -8763,7 +9145,7 @@ void main(void) {
|
|
|
8763
9145
|
}
|
|
8764
9146
|
};
|
|
8765
9147
|
RasterLayer.layerName = "RasterLayer";
|
|
8766
|
-
RasterLayer.defaultProps =
|
|
9148
|
+
RasterLayer.defaultProps = defaultProps8;
|
|
8767
9149
|
|
|
8768
9150
|
// src/layers/raster-tile-layer.ts
|
|
8769
9151
|
var renderSubLayers3 = (props) => {
|
|
@@ -8772,11 +9154,11 @@ void main(void) {
|
|
|
8772
9154
|
return null;
|
|
8773
9155
|
return new RasterLayer(props, { tileIndex });
|
|
8774
9156
|
};
|
|
8775
|
-
var
|
|
9157
|
+
var defaultProps9 = {
|
|
8776
9158
|
data: TilejsonPropType,
|
|
8777
9159
|
tileSize: DEFAULT_TILE_SIZE
|
|
8778
9160
|
};
|
|
8779
|
-
var RasterTileLayer = class extends
|
|
9161
|
+
var RasterTileLayer = class extends import_core13.CompositeLayer {
|
|
8780
9162
|
getLoadOptions() {
|
|
8781
9163
|
const loadOptions = super.getLoadOptions() || {};
|
|
8782
9164
|
const tileJSON = this.props.data;
|
|
@@ -8802,10 +9184,10 @@ void main(void) {
|
|
|
8802
9184
|
}
|
|
8803
9185
|
};
|
|
8804
9186
|
RasterTileLayer.layerName = "RasterTileLayer";
|
|
8805
|
-
RasterTileLayer.defaultProps =
|
|
9187
|
+
RasterTileLayer.defaultProps = defaultProps9;
|
|
8806
9188
|
|
|
8807
9189
|
// src/layers/vector-tile-layer.ts
|
|
8808
|
-
var
|
|
9190
|
+
var import_core14 = __toESM(require_core(), 1);
|
|
8809
9191
|
|
|
8810
9192
|
// src/layers/schema/carto-properties-tile.ts
|
|
8811
9193
|
var TileReader4 = class {
|
|
@@ -8897,7 +9279,7 @@ void main(void) {
|
|
|
8897
9279
|
function parseCartoVectorTile(arrayBuffer, options) {
|
|
8898
9280
|
if (!arrayBuffer)
|
|
8899
9281
|
return null;
|
|
8900
|
-
const tile = parsePbf(arrayBuffer,
|
|
9282
|
+
const tile = parsePbf(arrayBuffer, TileReader);
|
|
8901
9283
|
if (tile.polygons && !tile.polygons.triangles) {
|
|
8902
9284
|
triangulate(tile.polygons);
|
|
8903
9285
|
}
|
|
@@ -8907,16 +9289,16 @@ void main(void) {
|
|
|
8907
9289
|
|
|
8908
9290
|
// src/layers/vector-tile-layer.ts
|
|
8909
9291
|
var import_extensions = __toESM(require_extensions(), 1);
|
|
8910
|
-
var
|
|
8911
|
-
var
|
|
8912
|
-
(0,
|
|
8913
|
-
var
|
|
8914
|
-
...
|
|
9292
|
+
var import_geo_layers7 = __toESM(require_geo_layers(), 1);
|
|
9293
|
+
var import_layers5 = __toESM(require_layers(), 1);
|
|
9294
|
+
(0, import_core14.registerLoaders)([carto_properties_tile_loader_default, carto_vector_tile_loader_default]);
|
|
9295
|
+
var defaultProps10 = {
|
|
9296
|
+
...import_geo_layers7.MVTLayer.defaultProps,
|
|
8915
9297
|
data: TilejsonPropType,
|
|
8916
9298
|
dataComparator: TilejsonPropType.equal,
|
|
8917
9299
|
tileSize: DEFAULT_TILE_SIZE
|
|
8918
9300
|
};
|
|
8919
|
-
var VectorTileLayer = class extends
|
|
9301
|
+
var VectorTileLayer = class extends import_geo_layers7.MVTLayer {
|
|
8920
9302
|
constructor(...propObjects) {
|
|
8921
9303
|
super(...propObjects);
|
|
8922
9304
|
}
|
|
@@ -8943,7 +9325,7 @@ void main(void) {
|
|
|
8943
9325
|
async getTileData(tile) {
|
|
8944
9326
|
const tileJSON = this.props.data;
|
|
8945
9327
|
const { tiles: tiles2, properties_tiles } = tileJSON;
|
|
8946
|
-
const url = (0,
|
|
9328
|
+
const url = (0, import_geo_layers7._getURLFromTemplate)(tiles2, tile);
|
|
8947
9329
|
if (!url) {
|
|
8948
9330
|
return Promise.reject("Invalid URL");
|
|
8949
9331
|
}
|
|
@@ -8954,7 +9336,7 @@ void main(void) {
|
|
|
8954
9336
|
if (!properties_tiles) {
|
|
8955
9337
|
return await geometryFetch;
|
|
8956
9338
|
}
|
|
8957
|
-
const propertiesUrl = (0,
|
|
9339
|
+
const propertiesUrl = (0, import_geo_layers7._getURLFromTemplate)(properties_tiles, tile);
|
|
8958
9340
|
if (!propertiesUrl) {
|
|
8959
9341
|
return Promise.reject("Invalid properties URL");
|
|
8960
9342
|
}
|
|
@@ -8984,7 +9366,7 @@ void main(void) {
|
|
|
8984
9366
|
extensions: [new import_extensions.ClipExtension(), ...props.extensions || []],
|
|
8985
9367
|
clipBounds: [west, south, east, north]
|
|
8986
9368
|
};
|
|
8987
|
-
const subLayer = new
|
|
9369
|
+
const subLayer = new import_layers5.GeoJsonLayer(subLayerProps);
|
|
8988
9370
|
return subLayer;
|
|
8989
9371
|
}
|
|
8990
9372
|
_isWGS84() {
|
|
@@ -8994,7 +9376,7 @@ void main(void) {
|
|
|
8994
9376
|
}
|
|
8995
9377
|
};
|
|
8996
9378
|
VectorTileLayer.layerName = "VectorTileLayer";
|
|
8997
|
-
VectorTileLayer.defaultProps =
|
|
9379
|
+
VectorTileLayer.defaultProps = defaultProps10;
|
|
8998
9380
|
|
|
8999
9381
|
// src/api/carto-api-error.ts
|
|
9000
9382
|
var CartoAPIError = class extends Error {
|
|
@@ -10893,9 +11275,9 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
10893
11275
|
};
|
|
10894
11276
|
return scale;
|
|
10895
11277
|
}
|
|
10896
|
-
function
|
|
11278
|
+
function log4() {
|
|
10897
11279
|
const scale = loggish(transformer()).domain([1, 10]);
|
|
10898
|
-
scale.copy = () => copy(scale,
|
|
11280
|
+
scale.copy = () => copy(scale, log4()).base(scale.base());
|
|
10899
11281
|
initRange.apply(scale, arguments);
|
|
10900
11282
|
return scale;
|
|
10901
11283
|
}
|
|
@@ -12435,7 +12817,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
12435
12817
|
function getPalette(name, numCategories) {
|
|
12436
12818
|
const palette = cartocolor_exports[name];
|
|
12437
12819
|
let paletteIndex = numCategories;
|
|
12438
|
-
|
|
12820
|
+
assert2(palette, `Palette "${name}" not found. Expected a CARTOColors string`);
|
|
12439
12821
|
const palettesColorVariants = Object.keys(palette).filter((p) => p !== "tags").map(Number);
|
|
12440
12822
|
const longestPaletteIndex = Math.max(...palettesColorVariants);
|
|
12441
12823
|
const smallestPaletteIndex = Math.min(...palettesColorVariants);
|
|
@@ -12474,7 +12856,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
12474
12856
|
return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16), 255];
|
|
12475
12857
|
}
|
|
12476
12858
|
result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex2);
|
|
12477
|
-
|
|
12859
|
+
assert2(result, `Hexadecimal color "${hex2}" was not parsed correctly`);
|
|
12478
12860
|
return [
|
|
12479
12861
|
parseInt(result[1], 16),
|
|
12480
12862
|
parseInt(result[2], 16),
|
|
@@ -12486,8 +12868,8 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
12486
12868
|
// src/style/utils.ts
|
|
12487
12869
|
var ALLOWED_ATTR_TYPES = Object.freeze(["function", "string"]);
|
|
12488
12870
|
function getAttrValue(attr, d) {
|
|
12489
|
-
|
|
12490
|
-
|
|
12871
|
+
assert2(typeof d === "object", 'Expected "data" to be an object');
|
|
12872
|
+
assert2(ALLOWED_ATTR_TYPES.includes(typeof attr), 'Expected "attr" to be a function or string');
|
|
12491
12873
|
if (typeof attr === "function") {
|
|
12492
12874
|
return attr(d);
|
|
12493
12875
|
}
|
|
@@ -12501,7 +12883,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
12501
12883
|
colors = DEFAULT_PALETTE,
|
|
12502
12884
|
nullColor = NULL_COLOR
|
|
12503
12885
|
}) {
|
|
12504
|
-
|
|
12886
|
+
assert2(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
|
|
12505
12887
|
const palette = typeof colors === "string" ? getPalette(colors, domain.length + 1) : colors;
|
|
12506
12888
|
const color2 = threshold().domain(domain).range(palette);
|
|
12507
12889
|
return (d) => {
|
|
@@ -12518,7 +12900,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
12518
12900
|
nullColor = NULL_COLOR,
|
|
12519
12901
|
othersColor = OTHERS_COLOR
|
|
12520
12902
|
}) {
|
|
12521
|
-
|
|
12903
|
+
assert2(Array.isArray(domain), 'Expected "domain" to be an array of numbers or strings');
|
|
12522
12904
|
const colorsByCategory = {};
|
|
12523
12905
|
const palette = typeof colors === "string" ? getPalette(colors, domain.length) : colors;
|
|
12524
12906
|
for (const [i, c] of domain.entries()) {
|
|
@@ -12537,7 +12919,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
12537
12919
|
colors = DEFAULT_PALETTE,
|
|
12538
12920
|
nullColor = NULL_COLOR
|
|
12539
12921
|
}) {
|
|
12540
|
-
|
|
12922
|
+
assert2(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
|
|
12541
12923
|
const palette = typeof colors === "string" ? getPalette(colors, domain.length) : colors;
|
|
12542
12924
|
const color2 = linear2().domain(domain).range(palette);
|
|
12543
12925
|
return (d) => {
|
|
@@ -12592,10 +12974,10 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
12592
12974
|
}
|
|
12593
12975
|
|
|
12594
12976
|
// src/api/request-with-parameters.ts
|
|
12595
|
-
var
|
|
12977
|
+
var import_core15 = __toESM(require_core2(), 1);
|
|
12596
12978
|
var DEFAULT_PARAMETERS = {
|
|
12597
12979
|
v: V3_MINOR_VERSION,
|
|
12598
|
-
deckglVersion:
|
|
12980
|
+
deckglVersion: import_core15.VERSION
|
|
12599
12981
|
};
|
|
12600
12982
|
var DEFAULT_HEADERS = {
|
|
12601
12983
|
Accept: "application/json",
|
|
@@ -12922,17 +13304,17 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
12922
13304
|
};
|
|
12923
13305
|
|
|
12924
13306
|
// src/api/parse-map.ts
|
|
12925
|
-
var
|
|
13307
|
+
var import_core16 = __toESM(require_core2(), 1);
|
|
12926
13308
|
|
|
12927
13309
|
// src/api/layer-map.ts
|
|
12928
13310
|
var import_moment_timezone = __toESM(require_moment_timezone2(), 1);
|
|
12929
13311
|
var import_aggregation_layers = __toESM(require_aggregation_layers(), 1);
|
|
12930
|
-
var
|
|
12931
|
-
var
|
|
13312
|
+
var import_layers6 = __toESM(require_layers(), 1);
|
|
13313
|
+
var import_geo_layers8 = __toESM(require_geo_layers(), 1);
|
|
12932
13314
|
var SCALE_FUNCS = {
|
|
12933
13315
|
linear: linear2,
|
|
12934
13316
|
ordinal,
|
|
12935
|
-
log:
|
|
13317
|
+
log: log4,
|
|
12936
13318
|
point,
|
|
12937
13319
|
quantile: quantile2,
|
|
12938
13320
|
quantize,
|
|
@@ -12962,6 +13344,15 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
12962
13344
|
stddev: deviation,
|
|
12963
13345
|
variance
|
|
12964
13346
|
};
|
|
13347
|
+
var TILE_LAYER_TYPE_TO_LAYER = {
|
|
13348
|
+
clusterTile: ClusterTileLayer,
|
|
13349
|
+
h3: H3TileLayer,
|
|
13350
|
+
heatmapTile: heatmap_tile_layer_default,
|
|
13351
|
+
mvt: VectorTileLayer,
|
|
13352
|
+
quadbin: QuadbinTileLayer,
|
|
13353
|
+
raster: RasterTileLayer,
|
|
13354
|
+
tileset: VectorTileLayer
|
|
13355
|
+
};
|
|
12965
13356
|
var hexToRGBA = (c) => {
|
|
12966
13357
|
const { r, g, b, opacity } = rgb(c);
|
|
12967
13358
|
return [r, g, b, 255 * opacity];
|
|
@@ -13000,7 +13391,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13000
13391
|
elevationPercentile: ["elevationLowerPercentile", "elevationUpperPercentile"],
|
|
13001
13392
|
percentile: ["lowerPercentile", "upperPercentile"]
|
|
13002
13393
|
};
|
|
13003
|
-
var
|
|
13394
|
+
var defaultProps11 = {
|
|
13004
13395
|
lineMiterLimit: 2,
|
|
13005
13396
|
lineWidthUnits: "pixels",
|
|
13006
13397
|
pointRadiusUnits: "pixels",
|
|
@@ -13015,15 +13406,15 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13015
13406
|
if (config.visConfig?.customMarkers) {
|
|
13016
13407
|
basePropMap = mergePropMaps(sharedPropMap, customMarkersPropsMap);
|
|
13017
13408
|
}
|
|
13018
|
-
if (type
|
|
13019
|
-
return getTileLayer(dataset, basePropMap);
|
|
13409
|
+
if (TILE_LAYER_TYPE_TO_LAYER[type]) {
|
|
13410
|
+
return getTileLayer(dataset, basePropMap, type);
|
|
13020
13411
|
}
|
|
13021
13412
|
const geoColumn = dataset?.geoColumn;
|
|
13022
13413
|
const getPosition = (d) => d[geoColumn].coordinates;
|
|
13023
13414
|
const hexagonId = config.columns?.hex_id;
|
|
13024
13415
|
const layerTypeDefs = {
|
|
13025
13416
|
point: {
|
|
13026
|
-
Layer:
|
|
13417
|
+
Layer: import_layers6.GeoJsonLayer,
|
|
13027
13418
|
propMap: {
|
|
13028
13419
|
columns: {
|
|
13029
13420
|
altitude: (x) => ({ parameters: { depthTest: Boolean(x) } })
|
|
@@ -13032,7 +13423,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13032
13423
|
}
|
|
13033
13424
|
},
|
|
13034
13425
|
geojson: {
|
|
13035
|
-
Layer:
|
|
13426
|
+
Layer: import_layers6.GeoJsonLayer
|
|
13036
13427
|
},
|
|
13037
13428
|
grid: {
|
|
13038
13429
|
Layer: import_aggregation_layers.CPUGridLayer,
|
|
@@ -13050,42 +13441,26 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13050
13441
|
defaultProps: { getPosition }
|
|
13051
13442
|
},
|
|
13052
13443
|
hexagonId: {
|
|
13053
|
-
Layer:
|
|
13444
|
+
Layer: import_geo_layers8.H3HexagonLayer,
|
|
13054
13445
|
propMap: { visConfig: { coverage: "coverage" } },
|
|
13055
13446
|
defaultProps: { getHexagon: (d) => d[hexagonId], stroked: false }
|
|
13056
13447
|
}
|
|
13057
13448
|
};
|
|
13058
13449
|
const layer = layerTypeDefs[type];
|
|
13059
|
-
|
|
13450
|
+
assert2(layer, `Unsupported layer type: ${type}`);
|
|
13060
13451
|
return {
|
|
13061
13452
|
...layer,
|
|
13062
13453
|
propMap: mergePropMaps(basePropMap, layer.propMap),
|
|
13063
|
-
defaultProps: { ...
|
|
13454
|
+
defaultProps: { ...defaultProps11, ...layer.defaultProps }
|
|
13064
13455
|
};
|
|
13065
13456
|
}
|
|
13066
|
-
function
|
|
13067
|
-
|
|
13068
|
-
return RasterTileLayer;
|
|
13069
|
-
}
|
|
13070
|
-
if (scheme === "h3") {
|
|
13071
|
-
return H3TileLayer;
|
|
13072
|
-
}
|
|
13073
|
-
if (scheme === "quadbin") {
|
|
13074
|
-
return QuadbinTileLayer;
|
|
13075
|
-
}
|
|
13076
|
-
return VectorTileLayer;
|
|
13077
|
-
}
|
|
13078
|
-
function getTileLayer(dataset, basePropMap) {
|
|
13079
|
-
const {
|
|
13080
|
-
aggregationExp,
|
|
13081
|
-
aggregationResLevel,
|
|
13082
|
-
data: { scheme }
|
|
13083
|
-
} = dataset;
|
|
13457
|
+
function getTileLayer(dataset, basePropMap, type) {
|
|
13458
|
+
const { aggregationExp, aggregationResLevel } = dataset;
|
|
13084
13459
|
return {
|
|
13085
|
-
Layer:
|
|
13460
|
+
Layer: TILE_LAYER_TYPE_TO_LAYER[type] || VectorTileLayer,
|
|
13086
13461
|
propMap: basePropMap,
|
|
13087
13462
|
defaultProps: {
|
|
13088
|
-
...
|
|
13463
|
+
...defaultProps11,
|
|
13089
13464
|
...aggregationExp && { aggregationExp },
|
|
13090
13465
|
...aggregationResLevel && { aggregationResLevel },
|
|
13091
13466
|
uniqueIdProperty: "geoid"
|
|
@@ -13284,7 +13659,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13284
13659
|
var collisionFilterExtension = new import_extensions2.CollisionFilterExtension();
|
|
13285
13660
|
function parseMap(json) {
|
|
13286
13661
|
const { keplerMapConfig, datasets, token } = json;
|
|
13287
|
-
|
|
13662
|
+
assert2(keplerMapConfig.version === "v1", "Only support Kepler v1");
|
|
13288
13663
|
const { mapState, mapStyle } = keplerMapConfig.config;
|
|
13289
13664
|
const { layers, layerBlending, interactionConfig } = keplerMapConfig.config.visState;
|
|
13290
13665
|
return {
|
|
@@ -13300,15 +13675,15 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13300
13675
|
try {
|
|
13301
13676
|
const { dataId } = config;
|
|
13302
13677
|
const dataset = datasets.find((d) => d.id === dataId);
|
|
13303
|
-
|
|
13678
|
+
assert2(dataset, `No dataset matching dataId: ${dataId}`);
|
|
13304
13679
|
const { data } = dataset;
|
|
13305
|
-
|
|
13306
|
-
const { Layer:
|
|
13680
|
+
assert2(data, `No data loaded for dataId: ${dataId}`);
|
|
13681
|
+
const { Layer: Layer10, propMap, defaultProps: defaultProps12 } = getLayer(type, config, dataset);
|
|
13307
13682
|
const styleProps = createStyleProps(config, propMap);
|
|
13308
|
-
return new
|
|
13683
|
+
return new Layer10({
|
|
13309
13684
|
id: id4,
|
|
13310
13685
|
data,
|
|
13311
|
-
...
|
|
13686
|
+
...defaultProps12,
|
|
13312
13687
|
...createInteractionProps(interactionConfig),
|
|
13313
13688
|
...styleProps,
|
|
13314
13689
|
...createChannelProps(id4, type, config, visualChannels, data),
|
|
@@ -13316,7 +13691,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13316
13691
|
...createLoadOptions(token)
|
|
13317
13692
|
});
|
|
13318
13693
|
} catch (e) {
|
|
13319
|
-
|
|
13694
|
+
import_core16.log.error(e.message)();
|
|
13320
13695
|
return void 0;
|
|
13321
13696
|
}
|
|
13322
13697
|
})
|
|
@@ -13759,12 +14134,12 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13759
14134
|
autoRefresh,
|
|
13760
14135
|
onNewData
|
|
13761
14136
|
}) {
|
|
13762
|
-
|
|
13763
|
-
|
|
14137
|
+
assert2(cartoMapId, 'Must define CARTO map id: fetchMap({cartoMapId: "XXXX-XXXX-XXXX"})');
|
|
14138
|
+
assert2(apiBaseUrl, "Must define apiBaseUrl");
|
|
13764
14139
|
if (autoRefresh || onNewData) {
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
14140
|
+
assert2(onNewData, "Must define `onNewData` when using autoRefresh");
|
|
14141
|
+
assert2(typeof onNewData === "function", "`onNewData` must be a function");
|
|
14142
|
+
assert2(
|
|
13768
14143
|
typeof autoRefresh === "number" && autoRefresh > 0,
|
|
13769
14144
|
"`autoRefresh` must be a positive number"
|
|
13770
14145
|
);
|
|
@@ -13852,6 +14227,7 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13852
14227
|
|
|
13853
14228
|
// src/index.ts
|
|
13854
14229
|
var CARTO_LAYERS = {
|
|
14230
|
+
ClusterTileLayer,
|
|
13855
14231
|
H3TileLayer,
|
|
13856
14232
|
HeatmapTileLayer: heatmap_tile_layer_default,
|
|
13857
14233
|
_PointLabelLayer: PointLabelLayer,
|
|
@@ -13876,9 +14252,9 @@ ${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
|
13876
14252
|
|
|
13877
14253
|
// ../layers/bundle/peer-dependency.ts
|
|
13878
14254
|
var peer_dependency_exports = {};
|
|
13879
|
-
var
|
|
14255
|
+
var import_layers7 = __toESM(require_layers(), 1);
|
|
13880
14256
|
__reExport(peer_dependency_exports, __toESM(require_layers(), 1));
|
|
13881
|
-
if (!
|
|
14257
|
+
if (!import_layers7.GeoJsonLayer) {
|
|
13882
14258
|
throw new Error("@deck.gl/layers is not found");
|
|
13883
14259
|
}
|
|
13884
14260
|
|