@mapwhit/tilerenderer 1.2.1 → 1.2.2
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/build/min/package.json +1 -1
- package/package.json +4 -4
- package/src/data/bucket/fill_extrusion_bucket.js +34 -39
- package/src/data/bucket/line_bucket.js +40 -48
- package/src/data/bucket/symbol_bucket.js +4 -5
- package/src/data/feature_index.js +10 -3
- package/src/geo/transform.js +13 -13
- package/src/index.js +1 -1
- package/src/source/geojson_wrapper.js +1 -9
- package/src/source/query_features.js +4 -1
- package/src/source/rtl_text_plugin.js +3 -1
- package/src/source/source_cache.js +3 -3
- package/src/source/tile.js +1 -1
- package/src/style/evaluation_parameters.js +5 -4
- package/src/style/query_utils.js +82 -7
- package/src/style/style.js +8 -2
- package/src/style/style_layer/circle_style_layer.js +26 -45
- package/src/style/style_layer/fill_extrusion_style_layer.js +26 -33
- package/src/style/style_layer/heatmap_style_layer.js +21 -7
- package/src/style/style_layer/line_style_layer.js +7 -7
- package/src/style/style_layer.js +3 -3
- package/src/style-spec/feature_filter/index.js +24 -19
- package/src/symbol/anchor.js +1 -1
- package/src/symbol/check_max_angle.js +6 -6
- package/src/symbol/collision_feature.js +9 -15
- package/src/symbol/collision_index.js +33 -27
- package/src/symbol/get_anchors.js +6 -5
- package/src/symbol/projection.js +3 -3
- package/src/symbol/quads.js +1 -1
- package/src/symbol/symbol_layout.js +1 -2
- package/src/ui/camera.js +1 -1
- package/src/ui/map.js +24 -24
- package/src/util/classify_rings.js +2 -4
- package/src/util/vectortile_to_geojson.js +65 -26
- package/src/symbol/clip_line.js +0 -72
package/build/min/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapwhit/tilerenderer",
|
|
3
3
|
"description": "A WebGL interactive maps library",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./src/index.js",
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@mapbox/gl-matrix": "^0.0.1",
|
|
17
|
-
"@mapbox/point-geometry": "~1",
|
|
18
17
|
"@mapbox/unitbezier": "^0.0.1",
|
|
19
18
|
"@mapbox/whoots-js": "^3.0.0",
|
|
20
19
|
"@mapwhit/events": "^1.0.0",
|
|
21
20
|
"@mapwhit/geojson-rewind": "^2.0.0",
|
|
22
|
-
"@mapwhit/geometry": "^1.
|
|
21
|
+
"@mapwhit/geometry": "^1.1.0",
|
|
23
22
|
"@mapwhit/pbf": "^1.0.0",
|
|
23
|
+
"@mapwhit/point-geometry": "^1.0.2",
|
|
24
24
|
"@mapwhit/style-expressions": "^1.2.0",
|
|
25
|
-
"@mapwhit/vector-tile": "
|
|
25
|
+
"@mapwhit/vector-tile": "4.0.0",
|
|
26
26
|
"@pirxpilot/nanoassert": "~1",
|
|
27
27
|
"csscolorparser": "^1.0.3",
|
|
28
28
|
"dynload": "^1.0.2",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { clone, dist, perp, sub, unit } from '@mapwhit/point-geometry';
|
|
2
2
|
import assert from 'assert';
|
|
3
3
|
import earcut from 'earcut';
|
|
4
4
|
import classifyRings from '../../util/classify_rings.js';
|
|
@@ -15,7 +15,6 @@ import EvaluationParameters from '../../style/evaluation_parameters.js';
|
|
|
15
15
|
import loadGeometry from '../load_geometry.js';
|
|
16
16
|
import { addPatternDependencies, hasPattern } from './pattern_bucket_features.js';
|
|
17
17
|
|
|
18
|
-
const { types: vectorTileFeatureTypes } = VectorTileFeature;
|
|
19
18
|
const layoutAttributes = layout.members;
|
|
20
19
|
|
|
21
20
|
const FACTOR = 2 ** 13;
|
|
@@ -34,7 +33,7 @@ function addVertex(vertexArray, x, y, nx, ny, nz, t, e) {
|
|
|
34
33
|
);
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
class FillExtrusionBucket {
|
|
36
|
+
export default class FillExtrusionBucket {
|
|
38
37
|
constructor(options) {
|
|
39
38
|
this.zoom = options.zoom;
|
|
40
39
|
this.overscaling = options.overscaling;
|
|
@@ -145,46 +144,44 @@ class FillExtrusionBucket {
|
|
|
145
144
|
}
|
|
146
145
|
|
|
147
146
|
let edgeDistance = 0;
|
|
147
|
+
let from = ring[0];
|
|
148
|
+
for (let i = 1; i < ring.length; i++) {
|
|
149
|
+
const to = ring[i];
|
|
148
150
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const p2 = ring[p - 1];
|
|
154
|
-
|
|
155
|
-
if (!isBoundaryEdge(p1, p2)) {
|
|
156
|
-
if (segment.vertexLength + 4 > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {
|
|
157
|
-
segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);
|
|
158
|
-
}
|
|
151
|
+
if (!isBoundaryEdge(to, from)) {
|
|
152
|
+
if (segment.vertexLength + 4 > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {
|
|
153
|
+
segment = this.segments.prepareSegment(4, this.layoutVertexArray, this.indexArray);
|
|
154
|
+
}
|
|
159
155
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
156
|
+
const { x, y } = unit(perp(sub(clone(to), from)));
|
|
157
|
+
const distance = dist(from, to);
|
|
158
|
+
if (edgeDistance + distance > 32768) {
|
|
159
|
+
edgeDistance = 0;
|
|
160
|
+
}
|
|
165
161
|
|
|
166
|
-
|
|
167
|
-
|
|
162
|
+
addVertex(this.layoutVertexArray, to.x, to.y, x, y, 0, 0, edgeDistance);
|
|
163
|
+
addVertex(this.layoutVertexArray, to.x, to.y, x, y, 0, 1, edgeDistance);
|
|
168
164
|
|
|
169
|
-
|
|
165
|
+
edgeDistance += distance;
|
|
170
166
|
|
|
171
|
-
|
|
172
|
-
|
|
167
|
+
addVertex(this.layoutVertexArray, from.x, from.y, x, y, 0, 0, edgeDistance);
|
|
168
|
+
addVertex(this.layoutVertexArray, from.x, from.y, x, y, 0, 1, edgeDistance);
|
|
173
169
|
|
|
174
|
-
|
|
170
|
+
const bottomRight = segment.vertexLength;
|
|
175
171
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
172
|
+
// ┌──────┐
|
|
173
|
+
// │ 0 1 │ Counter-clockwise winding order.
|
|
174
|
+
// │ │ Triangle 1: 0 => 2 => 1
|
|
175
|
+
// │ 2 3 │ Triangle 2: 1 => 2 => 3
|
|
176
|
+
// └──────┘
|
|
177
|
+
this.indexArray.emplaceBack(bottomRight, bottomRight + 2, bottomRight + 1);
|
|
178
|
+
this.indexArray.emplaceBack(bottomRight + 1, bottomRight + 2, bottomRight + 3);
|
|
183
179
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
180
|
+
segment.vertexLength += 4;
|
|
181
|
+
segment.primitiveLength += 2;
|
|
187
182
|
}
|
|
183
|
+
|
|
184
|
+
from = to;
|
|
188
185
|
}
|
|
189
186
|
}
|
|
190
187
|
|
|
@@ -194,7 +191,7 @@ class FillExtrusionBucket {
|
|
|
194
191
|
|
|
195
192
|
//Only triangulate and draw the area of the feature if it is a polygon
|
|
196
193
|
//Other feature types (e.g. LineString) do not have area, so triangulation is pointless / undefined
|
|
197
|
-
if (
|
|
194
|
+
if (feature.type !== 3) {
|
|
198
195
|
continue;
|
|
199
196
|
}
|
|
200
197
|
|
|
@@ -241,13 +238,11 @@ class FillExtrusionBucket {
|
|
|
241
238
|
}
|
|
242
239
|
}
|
|
243
240
|
|
|
244
|
-
export
|
|
245
|
-
|
|
246
|
-
function isBoundaryEdge(p1, p2) {
|
|
241
|
+
export function isBoundaryEdge(p1, p2) {
|
|
247
242
|
return (p1.x === p2.x && (p1.x < 0 || p1.x > EXTENT)) || (p1.y === p2.y && (p1.y < 0 || p1.y > EXTENT));
|
|
248
243
|
}
|
|
249
244
|
|
|
250
|
-
function isEntirelyOutside(ring) {
|
|
245
|
+
export function isEntirelyOutside(ring) {
|
|
251
246
|
let left = true;
|
|
252
247
|
let right = true;
|
|
253
248
|
let top = true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dist, equals, Point } from '@mapwhit/point-geometry';
|
|
2
2
|
import EvaluationParameters from '../../style/evaluation_parameters.js';
|
|
3
3
|
import { LineLayoutArray } from '../array_types.js';
|
|
4
4
|
import EXTENT from '../extent.js';
|
|
@@ -10,7 +10,6 @@ import layout from './line_attributes.js';
|
|
|
10
10
|
import { addPatternDependencies, hasPattern } from './pattern_bucket_features.js';
|
|
11
11
|
|
|
12
12
|
const layoutAttributes = layout.members;
|
|
13
|
-
const vectorTileFeatureTypes = VectorTileFeature.types;
|
|
14
13
|
|
|
15
14
|
// NOTE ON EXTRUDE SCALE:
|
|
16
15
|
// scale the extrusion vector so that the normal length is this value.
|
|
@@ -66,21 +65,18 @@ function addLineVertex(layoutVertexBuffer, point, extrude, round, up, dir, lines
|
|
|
66
65
|
);
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this.
|
|
75
|
-
this.overscaling = options.overscaling;
|
|
76
|
-
this.layers = options.layers;
|
|
77
|
-
this.index = options.index;
|
|
68
|
+
export default class LineBucket {
|
|
69
|
+
constructor({ zoom, overscaling, layers, index }) {
|
|
70
|
+
this.zoom = zoom;
|
|
71
|
+
this.overscaling = overscaling;
|
|
72
|
+
this.layers = layers;
|
|
73
|
+
this.index = index;
|
|
78
74
|
this.features = [];
|
|
79
75
|
this.hasPattern = false;
|
|
80
76
|
|
|
81
77
|
this.layoutVertexArray = new LineLayoutArray();
|
|
82
78
|
this.indexArray = new TriangleIndexArray();
|
|
83
|
-
this.programConfigurations = new ProgramConfigurationSet(layoutAttributes,
|
|
79
|
+
this.programConfigurations = new ProgramConfigurationSet(layoutAttributes, layers, zoom);
|
|
84
80
|
this.segments = new SegmentVector();
|
|
85
81
|
}
|
|
86
82
|
|
|
@@ -174,24 +170,11 @@ class LineBucket {
|
|
|
174
170
|
}
|
|
175
171
|
|
|
176
172
|
addLine(vertices, feature, join, cap, miterLimit, roundLimit, index, imagePositions) {
|
|
177
|
-
|
|
178
|
-
if (
|
|
179
|
-
!!feature.properties &&
|
|
180
|
-
feature.properties.hasOwnProperty('mapbox_clip_start') &&
|
|
181
|
-
feature.properties.hasOwnProperty('mapbox_clip_end')
|
|
182
|
-
) {
|
|
183
|
-
lineDistances = {
|
|
184
|
-
start: feature.properties.mapbox_clip_start,
|
|
185
|
-
end: feature.properties.mapbox_clip_end,
|
|
186
|
-
tileTotal: undefined
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const isPolygon = vectorTileFeatureTypes[feature.type] === 'Polygon';
|
|
173
|
+
const isPolygon = feature.type === 3;
|
|
191
174
|
|
|
192
175
|
// If the line has duplicate vertices at the ends, adjust start/length to remove them.
|
|
193
|
-
const firstVertex = vertices[0];
|
|
194
|
-
const lastVertex = vertices[vertices.length - 1];
|
|
176
|
+
const firstVertex = Point.clone(vertices[0]);
|
|
177
|
+
const lastVertex = Point.clone(vertices[vertices.length - 1]);
|
|
195
178
|
let len = vertices.length;
|
|
196
179
|
while (len >= 2 && lastVertex.equals(vertices[len - 2])) {
|
|
197
180
|
len--;
|
|
@@ -206,8 +189,16 @@ class LineBucket {
|
|
|
206
189
|
return;
|
|
207
190
|
}
|
|
208
191
|
|
|
209
|
-
|
|
210
|
-
|
|
192
|
+
let lineDistances = null;
|
|
193
|
+
if (
|
|
194
|
+
feature.properties?.hasOwnProperty('mapbox_clip_start') &&
|
|
195
|
+
feature.properties?.hasOwnProperty('mapbox_clip_end')
|
|
196
|
+
) {
|
|
197
|
+
lineDistances = {
|
|
198
|
+
start: feature.properties.mapbox_clip_start,
|
|
199
|
+
end: feature.properties.mapbox_clip_end,
|
|
200
|
+
tileTotal: calculateFullDistance(vertices, first, len)
|
|
201
|
+
};
|
|
211
202
|
}
|
|
212
203
|
|
|
213
204
|
if (join === 'bevel') {
|
|
@@ -238,16 +229,19 @@ class LineBucket {
|
|
|
238
229
|
}
|
|
239
230
|
|
|
240
231
|
for (let i = first; i < len; i++) {
|
|
241
|
-
|
|
232
|
+
let nextVertex =
|
|
242
233
|
isPolygon && i === len - 1
|
|
243
234
|
? vertices[first + 1]
|
|
244
235
|
: // if the line is closed, we treat the last vertex like the first
|
|
245
236
|
vertices[i + 1]; // just the next vertex
|
|
246
237
|
|
|
247
238
|
// if two consecutive vertices exist, skip the current one
|
|
248
|
-
if (nextVertex && vertices[i]
|
|
239
|
+
if (nextVertex && equals(vertices[i], nextVertex)) {
|
|
249
240
|
continue;
|
|
250
241
|
}
|
|
242
|
+
if (nextVertex) {
|
|
243
|
+
nextVertex = Point.clone(nextVertex);
|
|
244
|
+
}
|
|
251
245
|
|
|
252
246
|
if (nextNormal) {
|
|
253
247
|
prevNormal = nextNormal;
|
|
@@ -296,15 +290,15 @@ class LineBucket {
|
|
|
296
290
|
const isSharpCorner = cosHalfAngle < COS_HALF_SHARP_CORNER && prevVertex && nextVertex;
|
|
297
291
|
|
|
298
292
|
if (isSharpCorner && i > first) {
|
|
299
|
-
const prevSegmentLength =
|
|
293
|
+
const prevSegmentLength = dist(currentVertex, prevVertex);
|
|
300
294
|
if (prevSegmentLength > 2 * sharpCornerOffset) {
|
|
301
|
-
const newPrevVertex = currentVertex.
|
|
302
|
-
currentVertex
|
|
303
|
-
.
|
|
295
|
+
const newPrevVertex = Point.clone(currentVertex)._sub(
|
|
296
|
+
Point.clone(currentVertex)
|
|
297
|
+
._sub(prevVertex)
|
|
304
298
|
._mult(sharpCornerOffset / prevSegmentLength)
|
|
305
299
|
._round()
|
|
306
300
|
);
|
|
307
|
-
this.distance +=
|
|
301
|
+
this.distance += dist(newPrevVertex, prevVertex);
|
|
308
302
|
this.addCurrentVertex(newPrevVertex, this.distance, prevNormal.mult(1), 0, 0, false, segment, lineDistances);
|
|
309
303
|
prevVertex = newPrevVertex;
|
|
310
304
|
}
|
|
@@ -342,7 +336,7 @@ class LineBucket {
|
|
|
342
336
|
|
|
343
337
|
// Calculate how far along the line the currentVertex is
|
|
344
338
|
if (prevVertex) {
|
|
345
|
-
this.distance +=
|
|
339
|
+
this.distance += dist(currentVertex, prevVertex);
|
|
346
340
|
}
|
|
347
341
|
|
|
348
342
|
switch (currentJoin) {
|
|
@@ -356,7 +350,7 @@ class LineBucket {
|
|
|
356
350
|
|
|
357
351
|
if (miterLength > 100) {
|
|
358
352
|
// Almost parallel lines
|
|
359
|
-
joinNormal = nextNormal.
|
|
353
|
+
joinNormal = nextNormal.mult(-1);
|
|
360
354
|
} else {
|
|
361
355
|
const direction = prevNormal.x * nextNormal.y - prevNormal.y * nextNormal.x > 0 ? -1 : 1;
|
|
362
356
|
const bevelLength = (miterLength * prevNormal.add(nextNormal).mag()) / prevNormal.sub(nextNormal).mag();
|
|
@@ -505,15 +499,15 @@ class LineBucket {
|
|
|
505
499
|
}
|
|
506
500
|
|
|
507
501
|
if (isSharpCorner && i < len - 1) {
|
|
508
|
-
const nextSegmentLength =
|
|
502
|
+
const nextSegmentLength = dist(currentVertex, nextVertex);
|
|
509
503
|
if (nextSegmentLength > 2 * sharpCornerOffset) {
|
|
510
|
-
const newCurrentVertex = currentVertex.
|
|
511
|
-
nextVertex
|
|
512
|
-
.
|
|
504
|
+
const newCurrentVertex = Point.clone(currentVertex)._add(
|
|
505
|
+
Point.clone(nextVertex)
|
|
506
|
+
._sub(currentVertex)
|
|
513
507
|
._mult(sharpCornerOffset / nextSegmentLength)
|
|
514
508
|
._round()
|
|
515
509
|
);
|
|
516
|
-
this.distance +=
|
|
510
|
+
this.distance += dist(newCurrentVertex, currentVertex);
|
|
517
511
|
this.addCurrentVertex(
|
|
518
512
|
newCurrentVertex,
|
|
519
513
|
this.distance,
|
|
@@ -556,7 +550,7 @@ class LineBucket {
|
|
|
556
550
|
distance = scaleDistance(distance, distancesForScaling);
|
|
557
551
|
}
|
|
558
552
|
|
|
559
|
-
extrude =
|
|
553
|
+
extrude = Point.clone(normal);
|
|
560
554
|
if (endLeft) {
|
|
561
555
|
extrude._sub(normal.perp()._mult(endLeft));
|
|
562
556
|
}
|
|
@@ -658,10 +652,8 @@ function calculateFullDistance(vertices, first, len) {
|
|
|
658
652
|
let prev = vertices[first];
|
|
659
653
|
for (let i = first + 1; i < len; i++) {
|
|
660
654
|
const next = vertices[i];
|
|
661
|
-
total +=
|
|
655
|
+
total += dist(prev, next);
|
|
662
656
|
prev = next;
|
|
663
657
|
}
|
|
664
658
|
return total;
|
|
665
659
|
}
|
|
666
|
-
|
|
667
|
-
export default LineBucket;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dist } from '@mapwhit/point-geometry';
|
|
1
2
|
import { Formatted } from '@mapwhit/style-expressions';
|
|
2
3
|
import { VectorTileFeature } from '@mapwhit/vector-tile';
|
|
3
4
|
import EvaluationParameters from '../../style/evaluation_parameters.js';
|
|
@@ -20,8 +21,6 @@ import { collisionBoxLayout, collisionCircleLayout, symbolLayoutAttributes } fro
|
|
|
20
21
|
import SymbolBuffers from './symbol_buffers.js';
|
|
21
22
|
import CollisionBuffers from './symbol_collision_buffers.js';
|
|
22
23
|
|
|
23
|
-
const vectorTileFeatureTypes = VectorTileFeature.types;
|
|
24
|
-
|
|
25
24
|
function addVertex(array, anchorX, anchorY, ox, oy, tx, ty, sizeVertex) {
|
|
26
25
|
array.emplaceBack(
|
|
27
26
|
// a_pos_offset
|
|
@@ -186,7 +185,7 @@ export default class SymbolBucket {
|
|
|
186
185
|
sourceLayerIndex,
|
|
187
186
|
geometry: loadGeometry(feature),
|
|
188
187
|
properties: feature.properties,
|
|
189
|
-
type:
|
|
188
|
+
type: VectorTileFeature.types[feature.type]
|
|
190
189
|
};
|
|
191
190
|
if (typeof feature.id !== 'undefined') {
|
|
192
191
|
symbolFeature.id = feature.id;
|
|
@@ -263,13 +262,13 @@ export default class SymbolBucket {
|
|
|
263
262
|
for (let i = anchor.segment + 1; i < line.length; i++) {
|
|
264
263
|
vertices[i] = { x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumForwardLength };
|
|
265
264
|
if (i < line.length - 1) {
|
|
266
|
-
sumForwardLength += line[i + 1]
|
|
265
|
+
sumForwardLength += dist(line[i + 1], line[i]);
|
|
267
266
|
}
|
|
268
267
|
}
|
|
269
268
|
for (let i = anchor.segment || 0; i >= 0; i--) {
|
|
270
269
|
vertices[i] = { x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumBackwardLength };
|
|
271
270
|
if (i > 0) {
|
|
272
|
-
sumBackwardLength += line[i - 1]
|
|
271
|
+
sumBackwardLength += dist(line[i - 1], line[i]);
|
|
273
272
|
}
|
|
274
273
|
}
|
|
275
274
|
for (let i = 0; i < line.length; i++) {
|
|
@@ -45,7 +45,7 @@ class FeatureIndex {
|
|
|
45
45
|
|
|
46
46
|
const params = args.params || {};
|
|
47
47
|
const pixelsToTileUnits = EXTENT / args.tileSize / args.scale;
|
|
48
|
-
const filter = featureFilter(params.filter);
|
|
48
|
+
const filter = featureFilter(params.filter, params.globalState);
|
|
49
49
|
|
|
50
50
|
const queryGeometry = args.queryGeometry;
|
|
51
51
|
const queryPadding = args.queryPadding * pixelsToTileUnits;
|
|
@@ -175,11 +175,18 @@ class FeatureIndex {
|
|
|
175
175
|
|
|
176
176
|
// Given a set of symbol indexes that have already been looked up,
|
|
177
177
|
// return a matching set of GeoJSONFeatures
|
|
178
|
-
lookupSymbolFeatures(
|
|
178
|
+
lookupSymbolFeatures(
|
|
179
|
+
symbolFeatureIndexes,
|
|
180
|
+
bucketIndex,
|
|
181
|
+
sourceLayerIndex,
|
|
182
|
+
{ filterSpec, globalState },
|
|
183
|
+
filterLayerIDs,
|
|
184
|
+
styleLayers
|
|
185
|
+
) {
|
|
179
186
|
const result = {};
|
|
180
187
|
this.loadVTLayers();
|
|
181
188
|
|
|
182
|
-
const filter = featureFilter(filterSpec);
|
|
189
|
+
const filter = featureFilter(filterSpec, globalState);
|
|
183
190
|
|
|
184
191
|
for (const symbolFeatureIndex of symbolFeatureIndexes) {
|
|
185
192
|
this.loadMatchingFeature(
|
package/src/geo/transform.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import glMatrix from '@mapbox/gl-matrix';
|
|
2
|
-
import Point from '@
|
|
2
|
+
import { Point } from '@mapwhit/point-geometry';
|
|
3
3
|
import EXTENT from '../data/extent.js';
|
|
4
4
|
import { UnwrappedTileID } from '../source/tile_id.js';
|
|
5
5
|
import interpolate from '../util/interpolate.js';
|
|
@@ -194,10 +194,10 @@ class Transform {
|
|
|
194
194
|
getVisibleUnwrappedCoordinates(tileID) {
|
|
195
195
|
const result = [new UnwrappedTileID(0, tileID)];
|
|
196
196
|
if (this._renderWorldCopies) {
|
|
197
|
-
const utl = this.pointCoordinate(
|
|
198
|
-
const utr = this.pointCoordinate(
|
|
199
|
-
const ubl = this.pointCoordinate(
|
|
200
|
-
const ubr = this.pointCoordinate(
|
|
197
|
+
const utl = this.pointCoordinate({ x: 0, y: 0 }, 0);
|
|
198
|
+
const utr = this.pointCoordinate({ x: this.width, y: 0 }, 0);
|
|
199
|
+
const ubl = this.pointCoordinate({ x: this.width, y: this.height }, 0);
|
|
200
|
+
const ubr = this.pointCoordinate({ x: 0, y: this.height }, 0);
|
|
201
201
|
const w0 = Math.floor(Math.min(utl.column, utr.column, ubl.column, ubr.column));
|
|
202
202
|
const w1 = Math.floor(Math.max(utl.column, utr.column, ubl.column, ubr.column));
|
|
203
203
|
|
|
@@ -242,10 +242,10 @@ class Transform {
|
|
|
242
242
|
const centerCoord = this.pointCoordinate(this.centerPoint, z);
|
|
243
243
|
const centerPoint = new Point(centerCoord.column - 0.5, centerCoord.row - 0.5);
|
|
244
244
|
const cornerCoords = [
|
|
245
|
-
this.pointCoordinate(
|
|
246
|
-
this.pointCoordinate(
|
|
247
|
-
this.pointCoordinate(
|
|
248
|
-
this.pointCoordinate(
|
|
245
|
+
this.pointCoordinate({ x: 0, y: 0 }, z),
|
|
246
|
+
this.pointCoordinate({ x: this.width, y: 0 }, z),
|
|
247
|
+
this.pointCoordinate({ x: this.width, y: this.height }, z),
|
|
248
|
+
this.pointCoordinate({ x: 0, y: this.height }, z)
|
|
249
249
|
];
|
|
250
250
|
return tileCover(z, cornerCoords, options.reparseOverscaled ? actualZ : z, this._renderWorldCopies).sort(
|
|
251
251
|
(a, b) => centerPoint.dist(a.canonical) - centerPoint.dist(b.canonical)
|
|
@@ -472,7 +472,7 @@ class Transform {
|
|
|
472
472
|
const s = Math.max(sx || 0, sy || 0);
|
|
473
473
|
|
|
474
474
|
if (s) {
|
|
475
|
-
this.center = this.unproject(
|
|
475
|
+
this.center = this.unproject({ x: sx ? (maxX + minX) / 2 : this.x, y: sy ? (maxY + minY) / 2 : this.y });
|
|
476
476
|
this.zoom += this.scaleZoom(s);
|
|
477
477
|
this._unmodified = unmodified;
|
|
478
478
|
this._constraining = false;
|
|
@@ -505,7 +505,7 @@ class Transform {
|
|
|
505
505
|
|
|
506
506
|
// pan the map if the screen goes off the range
|
|
507
507
|
if (x2 !== undefined || y2 !== undefined) {
|
|
508
|
-
this.center = this.unproject(
|
|
508
|
+
this.center = this.unproject({ x: x2 ?? this.x, y: y2 ?? this.y });
|
|
509
509
|
}
|
|
510
510
|
|
|
511
511
|
this._unmodified = unmodified;
|
|
@@ -592,7 +592,7 @@ class Transform {
|
|
|
592
592
|
return 1;
|
|
593
593
|
}
|
|
594
594
|
|
|
595
|
-
const coord = this.pointCoordinate(
|
|
595
|
+
const coord = this.pointCoordinate({ x: 0, y: 0 }).zoomTo(this.zoom);
|
|
596
596
|
const p = [coord.column * this.tileSize, coord.row * this.tileSize, 0, 1];
|
|
597
597
|
const topPoint = vec4.transformMat4(p, p, this.pixelMatrix);
|
|
598
598
|
return topPoint[3] / this.cameraToCenterDistance;
|
|
@@ -612,7 +612,7 @@ class Transform {
|
|
|
612
612
|
getCameraPoint() {
|
|
613
613
|
const pitch = this._pitch;
|
|
614
614
|
const yOffset = Math.tan(pitch) * (this.cameraToCenterDistance || 1);
|
|
615
|
-
return this.centerPoint.add(
|
|
615
|
+
return this.centerPoint.add({ x: 0, y: yOffset });
|
|
616
616
|
}
|
|
617
617
|
|
|
618
618
|
/*
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './util/polyfill.js';
|
|
2
2
|
|
|
3
|
-
import { default as Point } from '@mapbox/point-geometry';
|
|
4
3
|
import { Evented } from '@mapwhit/events';
|
|
4
|
+
import { Point } from '@mapwhit/point-geometry';
|
|
5
5
|
import packageJSON from '../package.json' with { type: 'json' };
|
|
6
6
|
import { default as LngLat } from './geo/lng_lat.js';
|
|
7
7
|
import { default as LngLatBounds } from './geo/lng_lat_bounds.js';
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import Point from '@mapbox/point-geometry';
|
|
2
|
-
import { VectorTileFeature } from '@mapwhit/vector-tile';
|
|
3
1
|
import EXTENT from '../data/extent.js';
|
|
4
2
|
|
|
5
|
-
const { toGeoJSON } = VectorTileFeature.prototype;
|
|
6
|
-
|
|
7
3
|
// The feature type used by geojson-vt and supercluster. Should be extracted to
|
|
8
4
|
// global type and used in module definitions for those two modules.
|
|
9
5
|
|
|
@@ -47,10 +43,6 @@ class FeatureWrapper {
|
|
|
47
43
|
? this._feature.geometry.map(p => [makePoint(p)])
|
|
48
44
|
: this._feature.geometry.map(ring => ring.map(makePoint));
|
|
49
45
|
}
|
|
50
|
-
|
|
51
|
-
toGeoJSON(x, y, z) {
|
|
52
|
-
return toGeoJSON.call(this, x, y, z);
|
|
53
|
-
}
|
|
54
46
|
}
|
|
55
47
|
|
|
56
48
|
class GeoJSONWrapper {
|
|
@@ -79,5 +71,5 @@ class GeoJSONWrapper {
|
|
|
79
71
|
export default GeoJSONWrapper;
|
|
80
72
|
|
|
81
73
|
function makePoint(arr) {
|
|
82
|
-
return
|
|
74
|
+
return { x: arr[0], y: arr[1] };
|
|
83
75
|
}
|
|
@@ -94,7 +94,10 @@ export function queryRenderedSymbols(
|
|
|
94
94
|
renderedSymbols[queryData.bucketInstanceId],
|
|
95
95
|
queryData.bucketIndex,
|
|
96
96
|
queryData.sourceLayerIndex,
|
|
97
|
-
|
|
97
|
+
{
|
|
98
|
+
filterSpec: params.filter,
|
|
99
|
+
globalState: params.globalState
|
|
100
|
+
},
|
|
98
101
|
params.layers,
|
|
99
102
|
styleLayers
|
|
100
103
|
);
|
|
@@ -67,7 +67,9 @@ function registerRTLTextPlugin(loadedPlugin) {
|
|
|
67
67
|
plugin['processBidirectionalText'] = loadedPlugin.processBidirectionalText;
|
|
68
68
|
plugin['processStyledBidirectionalText'] = loadedPlugin.processStyledBidirectionalText;
|
|
69
69
|
|
|
70
|
-
_completionCallback
|
|
70
|
+
if (_completionCallback) {
|
|
71
|
+
_completionCallback();
|
|
72
|
+
}
|
|
71
73
|
_loadedCallbacks.forEach(callback => callback());
|
|
72
74
|
_loadedCallbacks.length = 0;
|
|
73
75
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Point from '@mapbox/point-geometry';
|
|
2
1
|
import { ErrorEvent, Event, Evented } from '@mapwhit/events';
|
|
2
|
+
import { Point } from '@mapwhit/point-geometry';
|
|
3
3
|
import EXTENT from '../data/extent.js';
|
|
4
4
|
import Coordinate from '../geo/coordinate.js';
|
|
5
5
|
import browser from '../util/browser.js';
|
|
@@ -162,8 +162,8 @@ class SourceCache extends Evented {
|
|
|
162
162
|
if (zDiff !== 0) {
|
|
163
163
|
return zDiff;
|
|
164
164
|
}
|
|
165
|
-
const rotatedA =
|
|
166
|
-
const rotatedB =
|
|
165
|
+
const rotatedA = Point.clone(a.canonical)._rotate(angle);
|
|
166
|
+
const rotatedB = Point.clone(b.canonical)._rotate(angle);
|
|
167
167
|
return rotatedB.y - rotatedA.y || rotatedB.x - rotatedA.x;
|
|
168
168
|
}
|
|
169
169
|
}
|
package/src/source/tile.js
CHANGED
|
@@ -6,6 +6,7 @@ export default class EvaluationParameters {
|
|
|
6
6
|
// "options" may also be another EvaluationParameters to copy, see CrossFadedProperty.possiblyEvaluate
|
|
7
7
|
constructor(zoom, options) {
|
|
8
8
|
this.zoom = zoom;
|
|
9
|
+
this.isSupportedScript = isSupportedScript;
|
|
9
10
|
|
|
10
11
|
if (options) {
|
|
11
12
|
this.now = options.now || 0;
|
|
@@ -20,10 +21,6 @@ export default class EvaluationParameters {
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
isSupportedScript(str) {
|
|
24
|
-
return isStringInSupportedScript(str, rtlTextPlugin.isLoaded());
|
|
25
|
-
}
|
|
26
|
-
|
|
27
24
|
crossFadingFactor() {
|
|
28
25
|
if (this.fadeDuration === 0) {
|
|
29
26
|
return 1;
|
|
@@ -41,3 +38,7 @@ export default class EvaluationParameters {
|
|
|
41
38
|
: { fromScale: 0.5, toScale: 1, t: 1 - (1 - t) * fraction };
|
|
42
39
|
}
|
|
43
40
|
}
|
|
41
|
+
|
|
42
|
+
function isSupportedScript(str) {
|
|
43
|
+
return isStringInSupportedScript(str, rtlTextPlugin.isLoaded());
|
|
44
|
+
}
|