@mapwhit/tilerenderer 0.48.0 → 0.49.0
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 +3 -2
- package/src/data/array_types.js +169 -0
- package/src/data/bucket/symbol_attributes.js +18 -0
- package/src/data/bucket/symbol_bucket.js +93 -64
- package/src/geo/transform.js +13 -5
- package/src/render/glyph_atlas.js +3 -6
- package/src/render/image_atlas.js +3 -6
- package/src/render/image_manager.js +41 -41
- package/src/style/style_layer/symbol_style_layer_properties.js +6 -0
- package/src/style-spec/expression/definitions/assertion.js +52 -5
- package/src/style-spec/expression/definitions/index.js +1 -2
- package/src/style-spec/expression/parsing_context.js +3 -8
- package/src/style-spec/feature_filter/convert.js +197 -0
- package/src/style-spec/feature_filter/index.js +4 -1
- package/src/style-spec/function/convert.js +78 -100
- package/src/style-spec/reference/v8.json +42 -5
- package/src/symbol/collision_index.js +0 -1
- package/src/symbol/cross_tile_symbol_index.js +12 -7
- package/src/symbol/placement.js +50 -52
- package/src/symbol/symbol_layout.js +31 -31
- package/src/style-spec/expression/definitions/array.js +0 -82
|
@@ -13,6 +13,7 @@ const EXTENT = require('../data/extent');
|
|
|
13
13
|
const SymbolBucket = require('../data/bucket/symbol_bucket');
|
|
14
14
|
const EvaluationParameters = require('../style/evaluation_parameters');
|
|
15
15
|
const { Formatted } = require('../style-spec/expression/definitions/formatted');
|
|
16
|
+
const murmur3 = require('murmurhash-js');
|
|
16
17
|
|
|
17
18
|
// The symbol layout process needs `text-size` evaluated at up to five different zoom levels, and
|
|
18
19
|
// `icon-size` at up to three:
|
|
@@ -31,7 +32,6 @@ const { Formatted } = require('../style-spec/expression/definitions/formatted');
|
|
|
31
32
|
|
|
32
33
|
function performSymbolLayout(bucket, glyphMap, glyphPositions, imageMap, imagePositions, showCollisionBoxes) {
|
|
33
34
|
bucket.createArrays();
|
|
34
|
-
bucket.symbolInstances = [];
|
|
35
35
|
|
|
36
36
|
const tileSize = 512 * bucket.overscaling;
|
|
37
37
|
bucket.tilePixelRatio = EXTENT / tileSize;
|
|
@@ -199,30 +199,28 @@ function addFeature(bucket, feature, shapedTextOrientations, shapedIcon, glyphPo
|
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
sizes
|
|
225
|
-
)
|
|
202
|
+
addSymbol(
|
|
203
|
+
bucket,
|
|
204
|
+
anchor,
|
|
205
|
+
line,
|
|
206
|
+
shapedTextOrientations,
|
|
207
|
+
shapedIcon,
|
|
208
|
+
bucket.layers[0],
|
|
209
|
+
bucket.collisionBoxArray,
|
|
210
|
+
feature.index,
|
|
211
|
+
feature.sourceLayerIndex,
|
|
212
|
+
bucket.index,
|
|
213
|
+
textBoxScale,
|
|
214
|
+
textPadding,
|
|
215
|
+
textAlongLine,
|
|
216
|
+
textOffset,
|
|
217
|
+
iconBoxScale,
|
|
218
|
+
iconPadding,
|
|
219
|
+
iconAlongLine,
|
|
220
|
+
iconOffset,
|
|
221
|
+
feature,
|
|
222
|
+
glyphPositionMap,
|
|
223
|
+
sizes
|
|
226
224
|
);
|
|
227
225
|
};
|
|
228
226
|
|
|
@@ -368,7 +366,7 @@ function addSymbol(
|
|
|
368
366
|
let numIconVertices = 0;
|
|
369
367
|
let numGlyphVertices = 0;
|
|
370
368
|
let numVerticalGlyphVertices = 0;
|
|
371
|
-
const key = shapedTextOrientations.horizontal ? shapedTextOrientations.horizontal.text : '';
|
|
369
|
+
const key = murmur3(shapedTextOrientations.horizontal ? shapedTextOrientations.horizontal.text : '');
|
|
372
370
|
const placedTextSymbolIndices = [];
|
|
373
371
|
if (shapedTextOrientations.horizontal) {
|
|
374
372
|
// As a collision approximation, we can use either the vertical or the horizontal version of the feature
|
|
@@ -483,20 +481,22 @@ function addSymbol(
|
|
|
483
481
|
if (bucket.glyphOffsetArray.length >= SymbolBucket.MAX_GLYPHS)
|
|
484
482
|
warn.once('Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907');
|
|
485
483
|
|
|
486
|
-
|
|
484
|
+
bucket.symbolInstances.emplaceBack(
|
|
485
|
+
anchor.x,
|
|
486
|
+
anchor.y,
|
|
487
|
+
placedTextSymbolIndices.length > 0 ? placedTextSymbolIndices[0] : -1,
|
|
488
|
+
placedTextSymbolIndices.length > 1 ? placedTextSymbolIndices[1] : -1,
|
|
487
489
|
key,
|
|
488
490
|
textBoxStartIndex,
|
|
489
491
|
textBoxEndIndex,
|
|
490
492
|
iconBoxStartIndex,
|
|
491
493
|
iconBoxEndIndex,
|
|
492
|
-
anchor,
|
|
493
494
|
featureIndex,
|
|
494
495
|
numGlyphVertices,
|
|
495
496
|
numVerticalGlyphVertices,
|
|
496
497
|
numIconVertices,
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
};
|
|
498
|
+
0
|
|
499
|
+
);
|
|
500
500
|
}
|
|
501
501
|
|
|
502
502
|
function anchorIsTooClose(bucket, text, repeatDistance, anchor) {
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
const { toString, array, ValueType, StringType, NumberType, BooleanType, checkSubtype } = require('../types');
|
|
2
|
-
|
|
3
|
-
const { typeOf } = require('../values');
|
|
4
|
-
const RuntimeError = require('../runtime_error');
|
|
5
|
-
|
|
6
|
-
const types = {
|
|
7
|
-
string: StringType,
|
|
8
|
-
number: NumberType,
|
|
9
|
-
boolean: BooleanType
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
class ArrayAssertion {
|
|
13
|
-
constructor(type, input) {
|
|
14
|
-
this.type = type;
|
|
15
|
-
this.input = input;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static parse(args, context) {
|
|
19
|
-
if (args.length < 2 || args.length > 4)
|
|
20
|
-
return context.error(`Expected 1, 2, or 3 arguments, but found ${args.length - 1} instead.`);
|
|
21
|
-
|
|
22
|
-
let itemType;
|
|
23
|
-
let N;
|
|
24
|
-
if (args.length > 2) {
|
|
25
|
-
const type = args[1];
|
|
26
|
-
if (typeof type !== 'string' || !(type in types))
|
|
27
|
-
return context.error('The item type argument of "array" must be one of string, number, boolean', 1);
|
|
28
|
-
itemType = types[type];
|
|
29
|
-
} else {
|
|
30
|
-
itemType = ValueType;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (args.length > 3) {
|
|
34
|
-
if (typeof args[2] !== 'number' || args[2] < 0 || args[2] !== Math.floor(args[2])) {
|
|
35
|
-
return context.error('The length argument to "array" must be a positive integer literal', 2);
|
|
36
|
-
}
|
|
37
|
-
N = args[2];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const type = array(itemType, N);
|
|
41
|
-
|
|
42
|
-
const input = context.parse(args[args.length - 1], args.length - 1, ValueType);
|
|
43
|
-
if (!input) return null;
|
|
44
|
-
|
|
45
|
-
return new ArrayAssertion(type, input);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
evaluate(ctx) {
|
|
49
|
-
const value = this.input.evaluate(ctx);
|
|
50
|
-
const error = checkSubtype(this.type, typeOf(value));
|
|
51
|
-
if (error) {
|
|
52
|
-
throw new RuntimeError(
|
|
53
|
-
`Expected value to be of type ${toString(this.type)}, but found ${toString(typeOf(value))} instead.`
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
return value;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
eachChild(fn) {
|
|
60
|
-
fn(this.input);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
possibleOutputs() {
|
|
64
|
-
return this.input.possibleOutputs();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
serialize() {
|
|
68
|
-
const serialized = ['array'];
|
|
69
|
-
const itemType = this.type.itemType;
|
|
70
|
-
if (itemType.kind === 'string' || itemType.kind === 'number' || itemType.kind === 'boolean') {
|
|
71
|
-
serialized.push(itemType.kind);
|
|
72
|
-
const N = this.type.N;
|
|
73
|
-
if (typeof N === 'number') {
|
|
74
|
-
serialized.push(N);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
serialized.push(this.input.serialize());
|
|
78
|
-
return serialized;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
module.exports = ArrayAssertion;
|