@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.
Files changed (35) hide show
  1. package/build/min/package.json +1 -1
  2. package/package.json +4 -4
  3. package/src/data/bucket/fill_extrusion_bucket.js +34 -39
  4. package/src/data/bucket/line_bucket.js +40 -48
  5. package/src/data/bucket/symbol_bucket.js +4 -5
  6. package/src/data/feature_index.js +10 -3
  7. package/src/geo/transform.js +13 -13
  8. package/src/index.js +1 -1
  9. package/src/source/geojson_wrapper.js +1 -9
  10. package/src/source/query_features.js +4 -1
  11. package/src/source/rtl_text_plugin.js +3 -1
  12. package/src/source/source_cache.js +3 -3
  13. package/src/source/tile.js +1 -1
  14. package/src/style/evaluation_parameters.js +5 -4
  15. package/src/style/query_utils.js +82 -7
  16. package/src/style/style.js +8 -2
  17. package/src/style/style_layer/circle_style_layer.js +26 -45
  18. package/src/style/style_layer/fill_extrusion_style_layer.js +26 -33
  19. package/src/style/style_layer/heatmap_style_layer.js +21 -7
  20. package/src/style/style_layer/line_style_layer.js +7 -7
  21. package/src/style/style_layer.js +3 -3
  22. package/src/style-spec/feature_filter/index.js +24 -19
  23. package/src/symbol/anchor.js +1 -1
  24. package/src/symbol/check_max_angle.js +6 -6
  25. package/src/symbol/collision_feature.js +9 -15
  26. package/src/symbol/collision_index.js +33 -27
  27. package/src/symbol/get_anchors.js +6 -5
  28. package/src/symbol/projection.js +3 -3
  29. package/src/symbol/quads.js +1 -1
  30. package/src/symbol/symbol_layout.js +1 -2
  31. package/src/ui/camera.js +1 -1
  32. package/src/ui/map.js +24 -24
  33. package/src/util/classify_rings.js +2 -4
  34. package/src/util/vectortile_to_geojson.js +65 -26
  35. package/src/symbol/clip_line.js +0 -72
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "1.2.1",
2
+ "version": "1.2.2",
3
3
  "type": "module"
4
4
  }
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.1",
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.0.0",
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": "^2.0.1",
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 { VectorTileFeature } from '@mapwhit/vector-tile';
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
- for (let p = 0; p < ring.length; p++) {
150
- const p1 = ring[p];
151
-
152
- if (p >= 1) {
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
- const perp = p1.sub(p2)._perp()._unit();
161
- const dist = p2.dist(p1);
162
- if (edgeDistance + dist > 32768) {
163
- edgeDistance = 0;
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
- addVertex(this.layoutVertexArray, p1.x, p1.y, perp.x, perp.y, 0, 0, edgeDistance);
167
- addVertex(this.layoutVertexArray, p1.x, p1.y, perp.x, perp.y, 0, 1, edgeDistance);
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
- edgeDistance += dist;
165
+ edgeDistance += distance;
170
166
 
171
- addVertex(this.layoutVertexArray, p2.x, p2.y, perp.x, perp.y, 0, 0, edgeDistance);
172
- addVertex(this.layoutVertexArray, p2.x, p2.y, perp.x, perp.y, 0, 1, edgeDistance);
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
- const bottomRight = segment.vertexLength;
170
+ const bottomRight = segment.vertexLength;
175
171
 
176
- // ┌──────┐
177
- // │ 0 1 │ Counter-clockwise winding order.
178
- // │ │ Triangle 1: 0 => 2 => 1
179
- // │ 2 3 │ Triangle 2: 1 => 2 => 3
180
- // └──────┘
181
- this.indexArray.emplaceBack(bottomRight, bottomRight + 2, bottomRight + 1);
182
- this.indexArray.emplaceBack(bottomRight + 1, bottomRight + 2, bottomRight + 3);
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
- segment.vertexLength += 4;
185
- segment.primitiveLength += 2;
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 (vectorTileFeatureTypes[feature.type] !== 'Polygon') {
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 default FillExtrusionBucket;
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 { VectorTileFeature } from '@mapwhit/vector-tile';
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
- * @private
71
- */
72
- class LineBucket {
73
- constructor(options) {
74
- this.zoom = options.zoom;
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, options.layers, options.zoom);
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
- let lineDistances = null;
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
- if (lineDistances) {
210
- lineDistances.tileTotal = calculateFullDistance(vertices, first, len);
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
- const nextVertex =
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].equals(nextVertex)) {
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 = currentVertex.dist(prevVertex);
293
+ const prevSegmentLength = dist(currentVertex, prevVertex);
300
294
  if (prevSegmentLength > 2 * sharpCornerOffset) {
301
- const newPrevVertex = currentVertex.sub(
302
- currentVertex
303
- .sub(prevVertex)
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 += newPrevVertex.dist(prevVertex);
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 += currentVertex.dist(prevVertex);
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.clone().mult(-1);
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 = currentVertex.dist(nextVertex);
502
+ const nextSegmentLength = dist(currentVertex, nextVertex);
509
503
  if (nextSegmentLength > 2 * sharpCornerOffset) {
510
- const newCurrentVertex = currentVertex.add(
511
- nextVertex
512
- .sub(currentVertex)
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 += newCurrentVertex.dist(currentVertex);
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 = normal.clone();
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 += prev.dist(next);
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: vectorTileFeatureTypes[feature.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].dist(line[i]);
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].dist(line[i]);
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(symbolFeatureIndexes, bucketIndex, sourceLayerIndex, filterSpec, filterLayerIDs, styleLayers) {
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(
@@ -1,5 +1,5 @@
1
1
  import glMatrix from '@mapbox/gl-matrix';
2
- import Point from '@mapbox/point-geometry';
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(new Point(0, 0), 0);
198
- const utr = this.pointCoordinate(new Point(this.width, 0), 0);
199
- const ubl = this.pointCoordinate(new Point(this.width, this.height), 0);
200
- const ubr = this.pointCoordinate(new Point(0, this.height), 0);
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(new Point(0, 0), z),
246
- this.pointCoordinate(new Point(this.width, 0), z),
247
- this.pointCoordinate(new Point(this.width, this.height), z),
248
- this.pointCoordinate(new Point(0, this.height), z)
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(new Point(sx ? (maxX + minX) / 2 : this.x, sy ? (maxY + minY) / 2 : this.y));
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(new Point(x2 !== undefined ? x2 : this.x, y2 !== undefined ? y2 : this.y));
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(new Point(0, 0)).zoomTo(this.zoom);
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(new Point(0, yOffset));
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 new Point(arr[0], arr[1]);
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
- params.filter,
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 = new Point(a.canonical.x, a.canonical.y).rotate(angle);
166
- const rotatedB = new Point(b.canonical.x, b.canonical.y).rotate(angle);
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
  }
@@ -204,7 +204,7 @@ class Tile {
204
204
  return;
205
205
  }
206
206
 
207
- const filter = featureFilter(params?.filter);
207
+ const filter = featureFilter(params?.filter, params?.globalState);
208
208
  const { z, x, y } = this.tileID.canonical;
209
209
  const coord = { z, x, y };
210
210
 
@@ -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
+ }