@mapwhit/tilerenderer 1.0.0 → 1.1.1
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 +2 -1
- package/build/min/src/shaders/_prelude.fragment.glsl.js +1 -1
- package/build/min/src/shaders/_prelude.vertex.glsl.js +1 -1
- package/build/min/src/shaders/background.fragment.glsl.js +1 -1
- package/build/min/src/shaders/background.vertex.glsl.js +1 -1
- package/build/min/src/shaders/background_pattern.fragment.glsl.js +1 -1
- package/build/min/src/shaders/background_pattern.vertex.glsl.js +1 -1
- package/build/min/src/shaders/circle.fragment.glsl.js +1 -1
- package/build/min/src/shaders/circle.vertex.glsl.js +1 -1
- package/build/min/src/shaders/clipping_mask.fragment.glsl.js +1 -1
- package/build/min/src/shaders/clipping_mask.vertex.glsl.js +1 -1
- package/build/min/src/shaders/collision_box.fragment.glsl.js +1 -1
- package/build/min/src/shaders/collision_box.vertex.glsl.js +1 -1
- package/build/min/src/shaders/collision_circle.fragment.glsl.js +1 -1
- package/build/min/src/shaders/collision_circle.vertex.glsl.js +1 -1
- package/build/min/src/shaders/debug.fragment.glsl.js +1 -1
- package/build/min/src/shaders/debug.vertex.glsl.js +1 -1
- package/build/min/src/shaders/fill.fragment.glsl.js +1 -1
- package/build/min/src/shaders/fill.vertex.glsl.js +1 -1
- package/build/min/src/shaders/fill_extrusion.fragment.glsl.js +1 -1
- package/build/min/src/shaders/fill_extrusion.vertex.glsl.js +1 -1
- package/build/min/src/shaders/fill_extrusion_pattern.fragment.glsl.js +1 -1
- package/build/min/src/shaders/fill_extrusion_pattern.vertex.glsl.js +1 -1
- package/build/min/src/shaders/fill_outline.fragment.glsl.js +1 -1
- package/build/min/src/shaders/fill_outline.vertex.glsl.js +1 -1
- package/build/min/src/shaders/fill_outline_pattern.fragment.glsl.js +1 -1
- package/build/min/src/shaders/fill_outline_pattern.vertex.glsl.js +1 -1
- package/build/min/src/shaders/fill_pattern.fragment.glsl.js +1 -1
- package/build/min/src/shaders/fill_pattern.vertex.glsl.js +1 -1
- package/build/min/src/shaders/heatmap.fragment.glsl.js +1 -1
- package/build/min/src/shaders/heatmap.vertex.glsl.js +1 -1
- package/build/min/src/shaders/heatmap_texture.fragment.glsl.js +1 -1
- package/build/min/src/shaders/heatmap_texture.vertex.glsl.js +1 -1
- package/build/min/src/shaders/hillshade.fragment.glsl.js +1 -1
- package/build/min/src/shaders/hillshade.vertex.glsl.js +1 -1
- package/build/min/src/shaders/hillshade_prepare.fragment.glsl.js +1 -1
- package/build/min/src/shaders/hillshade_prepare.vertex.glsl.js +1 -1
- package/build/min/src/shaders/line.fragment.glsl.js +1 -1
- package/build/min/src/shaders/line.vertex.glsl.js +1 -1
- package/build/min/src/shaders/line_gradient.fragment.glsl.js +1 -1
- package/build/min/src/shaders/line_gradient.vertex.glsl.js +1 -1
- package/build/min/src/shaders/line_pattern.fragment.glsl.js +1 -1
- package/build/min/src/shaders/line_pattern.vertex.glsl.js +1 -1
- package/build/min/src/shaders/line_sdf.fragment.glsl.js +1 -1
- package/build/min/src/shaders/line_sdf.vertex.glsl.js +1 -1
- package/build/min/src/shaders/raster.fragment.glsl.js +1 -1
- package/build/min/src/shaders/raster.vertex.glsl.js +1 -1
- package/build/min/src/shaders/symbol_icon.fragment.glsl.js +1 -1
- package/build/min/src/shaders/symbol_icon.vertex.glsl.js +1 -1
- package/build/min/src/shaders/symbol_sdf.fragment.glsl.js +1 -1
- package/build/min/src/shaders/symbol_sdf.vertex.glsl.js +1 -1
- package/package.json +3 -2
- package/src/data/array_types.js +54 -81
- package/src/data/bucket/circle_attributes.js +2 -4
- package/src/data/bucket/circle_bucket.js +19 -13
- package/src/data/bucket/fill_attributes.js +2 -4
- package/src/data/bucket/fill_bucket.js +38 -24
- package/src/data/bucket/fill_extrusion_attributes.js +2 -4
- package/src/data/bucket/fill_extrusion_bucket.js +56 -34
- package/src/data/bucket/heatmap_bucket.js +2 -7
- package/src/data/bucket/line_attributes.js +2 -4
- package/src/data/bucket/line_bucket.js +207 -159
- package/src/data/bucket/pattern_attributes.js +2 -4
- package/src/data/bucket/pattern_bucket_features.js +5 -7
- package/src/data/bucket/symbol_attributes.js +12 -26
- package/src/data/bucket/symbol_bucket.js +111 -221
- package/src/data/bucket/symbol_buffers.js +62 -0
- package/src/data/bucket/symbol_collision_buffers.js +33 -0
- package/src/data/bucket.js +2 -6
- package/src/data/dem_data.js +11 -7
- package/src/data/extent.js +1 -1
- package/src/data/feature_index.js +35 -20
- package/src/data/index_array_type.js +1 -6
- package/src/data/load_geometry.js +6 -9
- package/src/data/pos_attributes.js +2 -3
- package/src/data/program_configuration.js +44 -26
- package/src/data/raster_bounds_attributes.js +2 -2
- package/src/data/segment.js +4 -3
- package/src/geo/coordinate.js +1 -1
- package/src/geo/lng_lat.js +3 -3
- package/src/geo/lng_lat_bounds.js +8 -4
- package/src/geo/transform.js +69 -30
- package/src/gl/color_mode.js +2 -2
- package/src/gl/context.js +28 -29
- package/src/gl/cull_face_mode.js +1 -1
- package/src/gl/depth_mode.js +1 -1
- package/src/gl/framebuffer.js +8 -4
- package/src/gl/index_buffer.js +2 -2
- package/src/gl/stencil_mode.js +1 -1
- package/src/gl/value.js +33 -68
- package/src/gl/vertex_buffer.js +2 -2
- package/src/index.js +49 -25
- package/src/render/draw_background.js +14 -9
- package/src/render/draw_circle.js +11 -8
- package/src/render/draw_collision_debug.js +11 -8
- package/src/render/draw_debug.js +16 -14
- package/src/render/draw_fill.js +19 -12
- package/src/render/draw_fill_extrusion.js +12 -9
- package/src/render/draw_heatmap.js +17 -12
- package/src/render/draw_hillshade.js +12 -9
- package/src/render/draw_line.js +30 -16
- package/src/render/draw_raster.js +17 -13
- package/src/render/draw_symbol.js +22 -17
- package/src/render/glyph_atlas.js +9 -5
- package/src/render/glyph_manager.js +1 -1
- package/src/render/image_atlas.js +4 -7
- package/src/render/image_manager.js +6 -9
- package/src/render/line_atlas.js +2 -2
- package/src/render/painter.js +65 -47
- package/src/render/program/background_program.js +6 -13
- package/src/render/program/circle_program.js +4 -6
- package/src/render/program/clipping_mask_program.js +3 -5
- package/src/render/program/collision_program.js +4 -6
- package/src/render/program/debug_program.js +3 -5
- package/src/render/program/fill_extrusion_program.js +8 -14
- package/src/render/program/fill_program.js +10 -21
- package/src/render/program/heatmap_program.js +8 -14
- package/src/render/program/hillshade_program.js +10 -16
- package/src/render/program/line_program.js +11 -22
- package/src/render/program/pattern.js +5 -7
- package/src/render/program/program_uniforms.js +13 -20
- package/src/render/program/raster_program.js +3 -5
- package/src/render/program/symbol_program.js +5 -7
- package/src/render/program.js +5 -6
- package/src/render/texture.js +1 -1
- package/src/render/tile_mask.js +6 -4
- package/src/render/uniform_binding.js +9 -20
- package/src/render/vertex_array_object.js +5 -3
- package/src/shaders/encode_attribute.js +2 -6
- package/src/shaders/index.js +103 -51
- package/src/source/geojson_source.js +11 -7
- package/src/source/geojson_worker_source.js +7 -7
- package/src/source/geojson_wrapper.js +4 -4
- package/src/source/image_source.js +11 -12
- package/src/source/load_tilejson.js +3 -3
- package/src/source/pixels_to_tile_units.js +3 -3
- package/src/source/query_features.js +13 -10
- package/src/source/raster_dem_tile_source.js +12 -10
- package/src/source/raster_tile_source.js +13 -9
- package/src/source/resources/glyphs.js +2 -3
- package/src/source/resources/index.js +2 -4
- package/src/source/rtl_text_plugin.js +8 -8
- package/src/source/source.js +9 -15
- package/src/source/source_cache.js +114 -49
- package/src/source/source_state.js +37 -14
- package/src/source/tile.js +38 -23
- package/src/source/tile_bounds.js +15 -8
- package/src/source/tile_cache.js +2 -2
- package/src/source/tile_id.js +30 -23
- package/src/source/vector_tile_source.js +10 -8
- package/src/source/vector_tile_worker_source.js +4 -4
- package/src/source/worker_tile.js +24 -22
- package/src/style/create_style_layer.js +11 -11
- package/src/style/evaluation_parameters.js +4 -6
- package/src/style/light.js +5 -5
- package/src/style/load_sprite.js +6 -6
- package/src/style/parse_glyph_pbf.js +21 -17
- package/src/style/pauseable_placement.js +3 -4
- package/src/style/properties.js +21 -44
- package/src/style/query_utils.js +4 -10
- package/src/style/style.js +64 -34
- package/src/style/style_layer/background_style_layer.js +3 -4
- package/src/style/style_layer/background_style_layer_properties.js +2 -2
- package/src/style/style_layer/circle_style_layer.js +12 -9
- package/src/style/style_layer/circle_style_layer_properties.js +2 -2
- package/src/style/style_layer/fill_extrusion_style_layer.js +16 -13
- package/src/style/style_layer/fill_extrusion_style_layer_properties.js +2 -2
- package/src/style/style_layer/fill_style_layer.js +6 -7
- package/src/style/style_layer/fill_style_layer_properties.js +2 -2
- package/src/style/style_layer/heatmap_style_layer.js +5 -6
- package/src/style/style_layer/heatmap_style_layer_properties.js +2 -2
- package/src/style/style_layer/hillshade_style_layer.js +3 -4
- package/src/style/style_layer/hillshade_style_layer_properties.js +2 -2
- package/src/style/style_layer/line_style_layer.js +10 -11
- package/src/style/style_layer/line_style_layer_properties.js +5 -5
- package/src/style/style_layer/raster_style_layer.js +3 -4
- package/src/style/style_layer/raster_style_layer_properties.js +2 -2
- package/src/style/style_layer/symbol_style_layer.js +7 -8
- package/src/style/style_layer/symbol_style_layer_properties.js +2 -2
- package/src/style/style_layer.js +21 -20
- package/src/style/style_layer_index.js +2 -2
- package/src/style/zoom_history.js +1 -1
- package/src/style-spec/error/parsing_error.js +1 -1
- package/src/style-spec/error/validation_error.js +5 -3
- package/src/style-spec/feature_filter/convert.js +17 -9
- package/src/style-spec/feature_filter/index.js +13 -9
- package/src/style-spec/util/eval_support.js +2 -2
- package/src/style-spec/util/ref_properties.js +1 -1
- package/src/symbol/anchor.js +2 -2
- package/src/symbol/check_max_angle.js +13 -5
- package/src/symbol/clip_line.js +2 -3
- package/src/symbol/collision_feature.js +8 -4
- package/src/symbol/collision_index.js +5 -7
- package/src/symbol/cross_tile_symbol_index.js +5 -5
- package/src/symbol/get_anchors.js +15 -8
- package/src/symbol/grid_index.js +5 -3
- package/src/symbol/mergelines.js +2 -2
- package/src/symbol/opacity_state.js +1 -1
- package/src/symbol/placement.js +25 -20
- package/src/symbol/projection.js +29 -28
- package/src/symbol/quads.js +10 -12
- package/src/symbol/shaping.js +27 -19
- package/src/symbol/symbol_layout.js +17 -21
- package/src/symbol/symbol_size.js +13 -12
- package/src/symbol/transform_text.js +3 -3
- package/src/ui/camera.js +34 -18
- package/src/ui/map.js +54 -34
- package/src/util/async.js +11 -5
- package/src/util/browser.js +1 -1
- package/src/util/callback.js +3 -9
- package/src/util/classify_rings.js +13 -8
- package/src/util/color_ramp.js +3 -3
- package/src/util/config.js +4 -4
- package/src/util/dictionary_coder.js +2 -3
- package/src/util/dom.js +7 -3
- package/src/util/find_pole_of_inaccessibility.js +29 -14
- package/src/util/group_layers.js +1 -1
- package/src/util/image.js +3 -8
- package/src/util/interpolate.js +1 -1
- package/src/util/intersection_tests.js +80 -42
- package/src/util/is_char_in_unicode_block.js +1 -1
- package/src/util/key.js +7 -3
- package/src/util/loader/image.js +1 -1
- package/src/util/object.js +25 -23
- package/src/util/script_detection.js +212 -91
- package/src/util/struct_array.js +8 -40
- package/src/util/task_queue.js +11 -7
- package/src/util/throttle.js +2 -2
- package/src/util/tile_cover.js +8 -5
- package/src/util/token.js +1 -1
- package/src/util/unique_id.js +2 -2
- package/src/util/util.js +21 -29
- package/src/util/vectortile_to_geojson.js +4 -2
- package/src/util/verticalize_punctuation.js +3 -7
- package/src/util/warn.js +4 -4
- package/src/util/web_worker.js +3 -3
|
@@ -1,46 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
SymbolLayoutArray,
|
|
11
|
-
SymbolDynamicLayoutArray,
|
|
12
|
-
SymbolOpacityArray,
|
|
1
|
+
import { Formatted } from '@mapwhit/style-expressions';
|
|
2
|
+
import { VectorTileFeature } from '@mapwhit/vector-tile';
|
|
3
|
+
import EvaluationParameters from '../../style/evaluation_parameters.js';
|
|
4
|
+
import mergeLines from '../../symbol/mergelines.js';
|
|
5
|
+
import { getSizeData } from '../../symbol/symbol_size.js';
|
|
6
|
+
import transformText from '../../symbol/transform_text.js';
|
|
7
|
+
import { allowsVerticalWritingMode } from '../../util/script_detection.js';
|
|
8
|
+
import { verticalizedCharacterMap } from '../../util/verticalize_punctuation.js';
|
|
9
|
+
import {
|
|
13
10
|
CollisionBoxLayoutArray,
|
|
14
11
|
CollisionCircleLayoutArray,
|
|
15
|
-
CollisionVertexArray,
|
|
16
|
-
PlacedSymbolArray,
|
|
17
|
-
SymbolInstanceArray,
|
|
18
12
|
GlyphOffsetArray,
|
|
13
|
+
SymbolInstanceArray,
|
|
19
14
|
SymbolLineVertexArray
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
const vectorTileFeatureTypes = mvt.VectorTileFeature.types;
|
|
30
|
-
const { verticalizedCharacterMap } = require('../../util/verticalize_punctuation');
|
|
31
|
-
const { getSizeData } = require('../../symbol/symbol_size');
|
|
32
|
-
const EvaluationParameters = require('../../style/evaluation_parameters');
|
|
33
|
-
const { Formatted } = require('@mapwhit/style-expressions');
|
|
34
|
-
|
|
35
|
-
// Opacity arrays are frequently updated but don't contain a lot of information, so we pack them
|
|
36
|
-
// tight. Each Uint32 is actually four duplicate Uint8s for the four corners of a glyph
|
|
37
|
-
// 7 bits are for the current opacity, and the lowest bit is the target opacity
|
|
38
|
-
|
|
39
|
-
// actually defined in symbol_attributes.js
|
|
40
|
-
// const placementOpacityAttributes = [
|
|
41
|
-
// { name: 'a_fade_opacity', components: 1, type: 'Uint32' }
|
|
42
|
-
// ];
|
|
43
|
-
const shaderOpacityAttributes = [{ name: 'a_fade_opacity', components: 1, type: 'Uint8', offset: 0 }];
|
|
15
|
+
} from '../array_types.js';
|
|
16
|
+
import { LineIndexArray, TriangleIndexArray } from '../index_array_type.js';
|
|
17
|
+
import loadGeometry from '../load_geometry.js';
|
|
18
|
+
import { ProgramConfigurationSet } from '../program_configuration.js';
|
|
19
|
+
import { collisionBoxLayout, collisionCircleLayout, symbolLayoutAttributes } from './symbol_attributes.js';
|
|
20
|
+
import SymbolBuffers from './symbol_buffers.js';
|
|
21
|
+
import CollisionBuffers from './symbol_collision_buffers.js';
|
|
22
|
+
|
|
23
|
+
const vectorTileFeatureTypes = VectorTileFeature.types;
|
|
44
24
|
|
|
45
25
|
function addVertex(array, anchorX, anchorY, ox, oy, tx, ty, sizeVertex) {
|
|
46
26
|
array.emplaceBack(
|
|
@@ -58,82 +38,13 @@ function addVertex(array, anchorX, anchorY, ox, oy, tx, ty, sizeVertex) {
|
|
|
58
38
|
);
|
|
59
39
|
}
|
|
60
40
|
|
|
61
|
-
function addDynamicAttributes(dynamicLayoutVertexArray, p, angle) {
|
|
41
|
+
export function addDynamicAttributes(dynamicLayoutVertexArray, p, angle) {
|
|
62
42
|
dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
|
|
63
43
|
dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
|
|
64
44
|
dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
|
|
65
45
|
dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
|
|
66
46
|
}
|
|
67
47
|
|
|
68
|
-
class SymbolBuffers {
|
|
69
|
-
constructor(programConfigurations) {
|
|
70
|
-
this.layoutVertexArray = new SymbolLayoutArray();
|
|
71
|
-
this.indexArray = new TriangleIndexArray();
|
|
72
|
-
this.programConfigurations = programConfigurations;
|
|
73
|
-
this.segments = new SegmentVector();
|
|
74
|
-
this.dynamicLayoutVertexArray = new SymbolDynamicLayoutArray();
|
|
75
|
-
this.opacityVertexArray = new SymbolOpacityArray();
|
|
76
|
-
this.placedSymbolArray = new PlacedSymbolArray();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
upload(context, dynamicIndexBuffer, upload, update) {
|
|
80
|
-
if (upload) {
|
|
81
|
-
this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, symbolLayoutAttributes.members);
|
|
82
|
-
this.indexBuffer = context.createIndexBuffer(this.indexArray, dynamicIndexBuffer);
|
|
83
|
-
this.dynamicLayoutVertexBuffer = context.createVertexBuffer(
|
|
84
|
-
this.dynamicLayoutVertexArray,
|
|
85
|
-
dynamicLayoutAttributes.members,
|
|
86
|
-
true
|
|
87
|
-
);
|
|
88
|
-
this.opacityVertexBuffer = context.createVertexBuffer(this.opacityVertexArray, shaderOpacityAttributes, true);
|
|
89
|
-
// This is a performance hack so that we can write to opacityVertexArray with uint32s
|
|
90
|
-
// even though the shaders read uint8s
|
|
91
|
-
this.opacityVertexBuffer.itemSize = 1;
|
|
92
|
-
}
|
|
93
|
-
if (upload || update) {
|
|
94
|
-
this.programConfigurations.upload(context);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
destroy() {
|
|
99
|
-
if (!this.layoutVertexBuffer) return;
|
|
100
|
-
this.layoutVertexBuffer.destroy();
|
|
101
|
-
this.indexBuffer.destroy();
|
|
102
|
-
this.programConfigurations.destroy();
|
|
103
|
-
this.segments.destroy();
|
|
104
|
-
this.dynamicLayoutVertexBuffer.destroy();
|
|
105
|
-
this.opacityVertexBuffer.destroy();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
class CollisionBuffers {
|
|
110
|
-
constructor(LayoutArray, layoutAttributes, IndexArray) {
|
|
111
|
-
this.layoutVertexArray = new LayoutArray();
|
|
112
|
-
this.layoutAttributes = layoutAttributes;
|
|
113
|
-
this.indexArray = new IndexArray();
|
|
114
|
-
this.segments = new SegmentVector();
|
|
115
|
-
this.collisionVertexArray = new CollisionVertexArray();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
upload(context) {
|
|
119
|
-
this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, this.layoutAttributes);
|
|
120
|
-
this.indexBuffer = context.createIndexBuffer(this.indexArray);
|
|
121
|
-
this.collisionVertexBuffer = context.createVertexBuffer(
|
|
122
|
-
this.collisionVertexArray,
|
|
123
|
-
collisionVertexAttributes.members,
|
|
124
|
-
true
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
destroy() {
|
|
129
|
-
if (!this.layoutVertexBuffer) return;
|
|
130
|
-
this.layoutVertexBuffer.destroy();
|
|
131
|
-
this.indexBuffer.destroy();
|
|
132
|
-
this.segments.destroy();
|
|
133
|
-
this.collisionVertexBuffer.destroy();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
48
|
/**
|
|
138
49
|
* Unlike other buckets, which simply implement #addFeature with type-specific
|
|
139
50
|
* logic for (essentially) triangulating feature geometries, SymbolBucket
|
|
@@ -166,14 +77,13 @@ class CollisionBuffers {
|
|
|
166
77
|
*
|
|
167
78
|
* @private
|
|
168
79
|
*/
|
|
169
|
-
class SymbolBucket {
|
|
80
|
+
export default class SymbolBucket {
|
|
170
81
|
constructor(options) {
|
|
171
82
|
this.collisionBoxArray = options.collisionBoxArray;
|
|
172
83
|
this.zoom = options.zoom;
|
|
173
84
|
this.globalState = options.globalState;
|
|
174
85
|
this.overscaling = options.overscaling;
|
|
175
86
|
this.layers = options.layers;
|
|
176
|
-
this.layerIds = this.layers.map(layer => layer.id);
|
|
177
87
|
this.index = options.index;
|
|
178
88
|
this.pixelRatio = options.pixelRatio;
|
|
179
89
|
this.sourceLayerIndex = options.sourceLayerIndex;
|
|
@@ -221,18 +131,6 @@ class SymbolBucket {
|
|
|
221
131
|
this.symbolInstances = new SymbolInstanceArray();
|
|
222
132
|
}
|
|
223
133
|
|
|
224
|
-
calculateGlyphDependencies(text, stack, textAlongLine, doesAllowVerticalWritingMode) {
|
|
225
|
-
for (let i = 0; i < text.length; i++) {
|
|
226
|
-
stack[text.charCodeAt(i)] = true;
|
|
227
|
-
if (textAlongLine && doesAllowVerticalWritingMode) {
|
|
228
|
-
const verticalChar = verticalizedCharacterMap[text.charAt(i)];
|
|
229
|
-
if (verticalChar) {
|
|
230
|
-
stack[verticalChar.charCodeAt(0)] = true;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
134
|
populate(features, options) {
|
|
237
135
|
const layer = this.layers[0];
|
|
238
136
|
const layout = layer._layout;
|
|
@@ -243,7 +141,7 @@ class SymbolBucket {
|
|
|
243
141
|
const hasText =
|
|
244
142
|
(textField.value.kind !== 'constant' || textField.value.value.toString().length > 0) &&
|
|
245
143
|
(textFont.value.kind !== 'constant' || textFont.value.value.length > 0);
|
|
246
|
-
const hasIcon = iconImage.value.kind !== 'constant' ||
|
|
144
|
+
const hasIcon = iconImage.value.kind !== 'constant' || iconImage.value.value?.length > 0;
|
|
247
145
|
|
|
248
146
|
this.features = [];
|
|
249
147
|
|
|
@@ -308,7 +206,7 @@ class SymbolBucket {
|
|
|
308
206
|
const doesAllowVerticalWritingMode = allowsVerticalWritingMode(text.toString());
|
|
309
207
|
const sectionFont = section.fontStack || fontStack;
|
|
310
208
|
const sectionStack = (stacks[sectionFont] = stacks[sectionFont] || {});
|
|
311
|
-
|
|
209
|
+
calculateGlyphDependencies(section.text, sectionStack, textAlongLine, doesAllowVerticalWritingMode);
|
|
312
210
|
}
|
|
313
211
|
}
|
|
314
212
|
}
|
|
@@ -321,7 +219,9 @@ class SymbolBucket {
|
|
|
321
219
|
}
|
|
322
220
|
|
|
323
221
|
update(states, vtLayer, imagePositions) {
|
|
324
|
-
if (!this.stateDependentLayers.length)
|
|
222
|
+
if (!this.stateDependentLayers.length) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
325
225
|
this.text.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, {
|
|
326
226
|
imagePositions,
|
|
327
227
|
globalState: this.globalState
|
|
@@ -398,52 +298,36 @@ class SymbolBucket {
|
|
|
398
298
|
lineStartIndex,
|
|
399
299
|
lineLength
|
|
400
300
|
) {
|
|
401
|
-
const indexArray = arrays
|
|
402
|
-
const
|
|
403
|
-
const dynamicLayoutVertexArray = arrays.dynamicLayoutVertexArray;
|
|
404
|
-
|
|
405
|
-
const segment = arrays.segments.prepareSegment(4 * quads.length, arrays.layoutVertexArray, arrays.indexArray);
|
|
301
|
+
const { indexArray, layoutVertexArray, dynamicLayoutVertexArray, segments } = arrays;
|
|
302
|
+
const segment = segments.prepareSegment(4 * quads.length, layoutVertexArray, indexArray);
|
|
406
303
|
const glyphOffsetArrayStart = this.glyphOffsetArray.length;
|
|
407
304
|
const vertexStartIndex = segment.vertexLength;
|
|
305
|
+
const { x: lax, y: lay } = labelAnchor;
|
|
408
306
|
|
|
409
|
-
for (const
|
|
410
|
-
const
|
|
411
|
-
const tr = symbol.tr;
|
|
412
|
-
const bl = symbol.bl;
|
|
413
|
-
const br = symbol.br;
|
|
414
|
-
const tex = symbol.tex;
|
|
415
|
-
|
|
416
|
-
const index = segment.vertexLength;
|
|
307
|
+
for (const { tl, tr, bl, br, tex, glyphOffset } of quads) {
|
|
308
|
+
const y = glyphOffset[1];
|
|
417
309
|
|
|
418
|
-
|
|
419
|
-
addVertex(layoutVertexArray,
|
|
420
|
-
addVertex(layoutVertexArray,
|
|
421
|
-
addVertex(layoutVertexArray,
|
|
422
|
-
addVertex(
|
|
423
|
-
layoutVertexArray,
|
|
424
|
-
labelAnchor.x,
|
|
425
|
-
labelAnchor.y,
|
|
426
|
-
br.x,
|
|
427
|
-
y + br.y,
|
|
428
|
-
tex.x + tex.w,
|
|
429
|
-
tex.y + tex.h,
|
|
430
|
-
sizeVertex
|
|
431
|
-
);
|
|
310
|
+
addVertex(layoutVertexArray, lax, lay, tl.x, y + tl.y, tex.x, tex.y, sizeVertex);
|
|
311
|
+
addVertex(layoutVertexArray, lax, lay, tr.x, y + tr.y, tex.x + tex.w, tex.y, sizeVertex);
|
|
312
|
+
addVertex(layoutVertexArray, lax, lay, bl.x, y + bl.y, tex.x, tex.y + tex.h, sizeVertex);
|
|
313
|
+
addVertex(layoutVertexArray, lax, lay, br.x, y + br.y, tex.x + tex.w, tex.y + tex.h, sizeVertex);
|
|
432
314
|
|
|
433
315
|
addDynamicAttributes(dynamicLayoutVertexArray, labelAnchor, 0);
|
|
434
316
|
|
|
317
|
+
const index = segment.vertexLength;
|
|
318
|
+
|
|
435
319
|
indexArray.emplaceBack(index, index + 1, index + 2);
|
|
436
320
|
indexArray.emplaceBack(index + 1, index + 2, index + 3);
|
|
437
321
|
|
|
438
322
|
segment.vertexLength += 4;
|
|
439
323
|
segment.primitiveLength += 2;
|
|
440
324
|
|
|
441
|
-
this.glyphOffsetArray.emplaceBack(
|
|
325
|
+
this.glyphOffsetArray.emplaceBack(glyphOffset[0]);
|
|
442
326
|
}
|
|
443
327
|
|
|
444
328
|
arrays.placedSymbolArray.emplaceBack(
|
|
445
|
-
|
|
446
|
-
|
|
329
|
+
lax,
|
|
330
|
+
lay,
|
|
447
331
|
glyphOffsetArrayStart,
|
|
448
332
|
this.glyphOffsetArray.length - glyphOffsetArrayStart,
|
|
449
333
|
vertexStartIndex,
|
|
@@ -494,22 +378,18 @@ class SymbolBucket {
|
|
|
494
378
|
|
|
495
379
|
addDebugCollisionBoxes(startIndex, endIndex, symbolInstance) {
|
|
496
380
|
for (let b = startIndex; b < endIndex; b++) {
|
|
497
|
-
const
|
|
498
|
-
const x1 = box.x1;
|
|
499
|
-
const y1 = box.y1;
|
|
500
|
-
const x2 = box.x2;
|
|
501
|
-
const y2 = box.y2;
|
|
381
|
+
const { x1, y1, x2, y2, radius, anchorPoint } = this.collisionBoxArray.get(b);
|
|
502
382
|
|
|
503
383
|
// If the radius > 0, this collision box is actually a circle
|
|
504
384
|
// The data we add to the buffers is exactly the same, but we'll render with a different shader.
|
|
505
|
-
const isCircle =
|
|
385
|
+
const isCircle = radius > 0;
|
|
506
386
|
this.addCollisionDebugVertices(
|
|
507
387
|
x1,
|
|
508
388
|
y1,
|
|
509
389
|
x2,
|
|
510
390
|
y2,
|
|
511
391
|
isCircle ? this.collisionCircle : this.collisionBox,
|
|
512
|
-
|
|
392
|
+
anchorPoint,
|
|
513
393
|
symbolInstance,
|
|
514
394
|
isCircle
|
|
515
395
|
);
|
|
@@ -565,66 +445,72 @@ class SymbolBucket {
|
|
|
565
445
|
}
|
|
566
446
|
|
|
567
447
|
sortFeatures(angle) {
|
|
568
|
-
if (!this.sortFeaturesByY)
|
|
448
|
+
if (!this.sortFeaturesByY) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
569
451
|
|
|
570
|
-
if (this.sortedAngle === angle)
|
|
452
|
+
if (this.sortedAngle === angle) {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
571
455
|
this.sortedAngle = angle;
|
|
572
456
|
|
|
573
457
|
// The current approach to sorting doesn't sort across segments so don't try.
|
|
574
458
|
// Sorting within segments separately seemed not to be worth the complexity.
|
|
575
|
-
if (this.text.segments.get().length > 1 || this.icon.segments.get().length > 1)
|
|
459
|
+
if (this.text.segments.get().length > 1 || this.icon.segments.get().length > 1) {
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
576
462
|
|
|
577
463
|
// If the symbols are allowed to overlap sort them by their vertical screen position.
|
|
578
464
|
// The index array buffer is rewritten to reference the (unchanged) vertices in the
|
|
579
465
|
// sorted order.
|
|
580
466
|
|
|
581
467
|
// To avoid sorting the actual symbolInstance array we sort an array of indexes.
|
|
582
|
-
const
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
468
|
+
const slen = this.symbolInstances.length;
|
|
469
|
+
const symbolInstanceIndexes = new Array(slen);
|
|
470
|
+
const rotatedYs = new Array(slen);
|
|
471
|
+
const featureIndexes = new Array(slen);
|
|
587
472
|
const sin = Math.sin(angle);
|
|
588
473
|
const cos = Math.cos(angle);
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
rotatedYs.push(Math.round(sin * symbolInstance.anchorX + cos * symbolInstance.anchorY) | 0);
|
|
595
|
-
featureIndexes.push(symbolInstance.featureIndex);
|
|
474
|
+
for (let i = 0; i < slen; i++) {
|
|
475
|
+
symbolInstanceIndexes[i] = i;
|
|
476
|
+
const { anchorX, anchorY, featureIndex } = this.symbolInstances.get(i);
|
|
477
|
+
rotatedYs[i] = Math.round(sin * anchorX + cos * anchorY) | 0;
|
|
478
|
+
featureIndexes[i] = featureIndex;
|
|
596
479
|
}
|
|
597
480
|
|
|
598
|
-
symbolInstanceIndexes.sort((
|
|
599
|
-
return rotatedYs[aIndex] - rotatedYs[bIndex] || featureIndexes[bIndex] - featureIndexes[aIndex];
|
|
600
|
-
});
|
|
481
|
+
symbolInstanceIndexes.sort((a, b) => rotatedYs[a] - rotatedYs[b] || featureIndexes[b] - featureIndexes[a]);
|
|
601
482
|
|
|
602
483
|
this.text.indexArray.clear();
|
|
603
484
|
this.icon.indexArray.clear();
|
|
604
485
|
|
|
605
|
-
this.featureSortOrder =
|
|
486
|
+
this.featureSortOrder = new Array(slen);
|
|
606
487
|
|
|
607
|
-
for (
|
|
608
|
-
const
|
|
609
|
-
|
|
488
|
+
for (let i = 0; i < slen; i++) {
|
|
489
|
+
const index = symbolInstanceIndexes[i];
|
|
490
|
+
const { featureIndex, horizontalPlacedTextSymbolIndex, verticalPlacedTextSymbolIndex } =
|
|
491
|
+
this.symbolInstances.get(index);
|
|
492
|
+
this.featureSortOrder[i] = featureIndex;
|
|
610
493
|
|
|
611
|
-
if (
|
|
612
|
-
this.addIndicesForPlacedTextSymbol(
|
|
494
|
+
if (horizontalPlacedTextSymbolIndex >= 0) {
|
|
495
|
+
this.addIndicesForPlacedTextSymbol(horizontalPlacedTextSymbolIndex);
|
|
613
496
|
}
|
|
614
|
-
if (
|
|
615
|
-
this.addIndicesForPlacedTextSymbol(
|
|
497
|
+
if (verticalPlacedTextSymbolIndex >= 0) {
|
|
498
|
+
this.addIndicesForPlacedTextSymbol(verticalPlacedTextSymbolIndex);
|
|
616
499
|
}
|
|
617
500
|
|
|
618
|
-
const
|
|
619
|
-
if (
|
|
620
|
-
const vertexIndex = placedIcon.vertexStartIndex;
|
|
501
|
+
const { numGlyphs, vertexStartIndex: vertexIndex } = this.icon.placedSymbolArray.get(index);
|
|
502
|
+
if (numGlyphs) {
|
|
621
503
|
this.icon.indexArray.emplaceBack(vertexIndex, vertexIndex + 1, vertexIndex + 2);
|
|
622
504
|
this.icon.indexArray.emplaceBack(vertexIndex + 1, vertexIndex + 2, vertexIndex + 3);
|
|
623
505
|
}
|
|
624
506
|
}
|
|
625
507
|
|
|
626
|
-
if (this.text.indexBuffer)
|
|
627
|
-
|
|
508
|
+
if (this.text.indexBuffer) {
|
|
509
|
+
this.text.indexBuffer.updateData(this.text.indexArray);
|
|
510
|
+
}
|
|
511
|
+
if (this.icon.indexBuffer) {
|
|
512
|
+
this.icon.indexBuffer.updateData(this.icon.indexArray);
|
|
513
|
+
}
|
|
628
514
|
}
|
|
629
515
|
}
|
|
630
516
|
|
|
@@ -654,45 +540,41 @@ function deserializeCollisionBoxesForSymbol(
|
|
|
654
540
|
) {
|
|
655
541
|
const collisionArrays = {};
|
|
656
542
|
for (let k = textStartIndex; k < textEndIndex; k++) {
|
|
657
|
-
const
|
|
658
|
-
|
|
543
|
+
const { x1, y1, x2, y2, anchorPointX, anchorPointY, featureIndex, radius, signedDistanceFromAnchor } =
|
|
544
|
+
collisionBoxArray.get(k);
|
|
545
|
+
if (radius === 0) {
|
|
659
546
|
collisionArrays.textBox = {
|
|
660
|
-
x1
|
|
661
|
-
y1
|
|
662
|
-
x2
|
|
663
|
-
y2
|
|
664
|
-
anchorPointX
|
|
665
|
-
anchorPointY
|
|
547
|
+
x1,
|
|
548
|
+
y1,
|
|
549
|
+
x2,
|
|
550
|
+
y2,
|
|
551
|
+
anchorPointX,
|
|
552
|
+
anchorPointY
|
|
666
553
|
};
|
|
667
|
-
collisionArrays.textFeatureIndex =
|
|
554
|
+
collisionArrays.textFeatureIndex = featureIndex;
|
|
668
555
|
break; // Only one box allowed per instance
|
|
669
556
|
}
|
|
670
557
|
if (!collisionArrays.textCircles) {
|
|
671
558
|
collisionArrays.textCircles = [];
|
|
672
|
-
collisionArrays.textFeatureIndex =
|
|
559
|
+
collisionArrays.textFeatureIndex = featureIndex;
|
|
673
560
|
}
|
|
674
561
|
const used = 1; // May be updated at collision detection time
|
|
675
|
-
collisionArrays.textCircles.push(
|
|
676
|
-
box.anchorPointX,
|
|
677
|
-
box.anchorPointY,
|
|
678
|
-
box.radius,
|
|
679
|
-
box.signedDistanceFromAnchor,
|
|
680
|
-
used
|
|
681
|
-
);
|
|
562
|
+
collisionArrays.textCircles.push(anchorPointX, anchorPointY, radius, signedDistanceFromAnchor, used);
|
|
682
563
|
}
|
|
683
564
|
for (let k = iconStartIndex; k < iconEndIndex; k++) {
|
|
684
565
|
// An icon can only have one box now, so this indexing is a bit vestigial...
|
|
685
566
|
const box = collisionBoxArray.get(k);
|
|
686
567
|
if (box.radius === 0) {
|
|
568
|
+
const { x1, y1, x2, y2, anchorPointX, anchorPointY, featureIndex } = box;
|
|
687
569
|
collisionArrays.iconBox = {
|
|
688
|
-
x1
|
|
689
|
-
y1
|
|
690
|
-
x2
|
|
691
|
-
y2
|
|
692
|
-
anchorPointX
|
|
693
|
-
anchorPointY
|
|
570
|
+
x1,
|
|
571
|
+
y1,
|
|
572
|
+
x2,
|
|
573
|
+
y2,
|
|
574
|
+
anchorPointX,
|
|
575
|
+
anchorPointY
|
|
694
576
|
};
|
|
695
|
-
collisionArrays.iconFeatureIndex =
|
|
577
|
+
collisionArrays.iconFeatureIndex = featureIndex;
|
|
696
578
|
break; // Only one box allowed per instance
|
|
697
579
|
}
|
|
698
580
|
}
|
|
@@ -707,6 +589,14 @@ function deserializeCollisionBoxesForSymbol(
|
|
|
707
589
|
// but we expect there to be many fewer boxes/lines than glyphs
|
|
708
590
|
SymbolBucket.MAX_GLYPHS = 65535;
|
|
709
591
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
592
|
+
function calculateGlyphDependencies(text, stack, textAlongLine, doesAllowVerticalWritingMode) {
|
|
593
|
+
for (let i = 0; i < text.length; i++) {
|
|
594
|
+
stack[text.charCodeAt(i)] = true;
|
|
595
|
+
if (textAlongLine && doesAllowVerticalWritingMode) {
|
|
596
|
+
const verticalChar = verticalizedCharacterMap[text.charAt(i)];
|
|
597
|
+
if (verticalChar) {
|
|
598
|
+
stack[verticalChar.charCodeAt(0)] = true;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PlacedSymbolArray,
|
|
3
|
+
StructArrayLayout3f12 as SymbolDynamicLayoutArray,
|
|
4
|
+
StructArrayLayout4i4ui16 as SymbolLayoutArray,
|
|
5
|
+
StructArrayLayout1ul4 as SymbolOpacityArray,
|
|
6
|
+
StructArrayLayout3ui6 as TriangleIndexArray
|
|
7
|
+
} from '../array_types.js';
|
|
8
|
+
import SegmentVector from '../segment.js';
|
|
9
|
+
import { dynamicLayoutAttributes, symbolLayoutAttributes } from './symbol_attributes.js';
|
|
10
|
+
|
|
11
|
+
// Opacity arrays are frequently updated but don't contain a lot of information, so we pack them
|
|
12
|
+
// tight. Each Uint32 is actually four duplicate Uint8s for the four corners of a glyph
|
|
13
|
+
// 7 bits are for the current opacity, and the lowest bit is the target opacity
|
|
14
|
+
|
|
15
|
+
// actually defined in symbol_attributes.js
|
|
16
|
+
// const placementOpacityAttributes = [
|
|
17
|
+
// { name: 'a_fade_opacity', components: 1, type: 'Uint32' }
|
|
18
|
+
// ];
|
|
19
|
+
const shaderOpacityAttributes = [{ name: 'a_fade_opacity', components: 1, type: 'Uint8', offset: 0 }];
|
|
20
|
+
|
|
21
|
+
export default class SymbolBuffers {
|
|
22
|
+
constructor(programConfigurations) {
|
|
23
|
+
this.layoutVertexArray = new SymbolLayoutArray();
|
|
24
|
+
this.indexArray = new TriangleIndexArray();
|
|
25
|
+
this.programConfigurations = programConfigurations;
|
|
26
|
+
this.segments = new SegmentVector();
|
|
27
|
+
this.dynamicLayoutVertexArray = new SymbolDynamicLayoutArray();
|
|
28
|
+
this.opacityVertexArray = new SymbolOpacityArray();
|
|
29
|
+
this.placedSymbolArray = new PlacedSymbolArray();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
upload(context, dynamicIndexBuffer, upload, update) {
|
|
33
|
+
if (upload) {
|
|
34
|
+
this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, symbolLayoutAttributes.members);
|
|
35
|
+
this.indexBuffer = context.createIndexBuffer(this.indexArray, dynamicIndexBuffer);
|
|
36
|
+
this.dynamicLayoutVertexBuffer = context.createVertexBuffer(
|
|
37
|
+
this.dynamicLayoutVertexArray,
|
|
38
|
+
dynamicLayoutAttributes.members,
|
|
39
|
+
true
|
|
40
|
+
);
|
|
41
|
+
this.opacityVertexBuffer = context.createVertexBuffer(this.opacityVertexArray, shaderOpacityAttributes, true);
|
|
42
|
+
// This is a performance hack so that we can write to opacityVertexArray with uint32s
|
|
43
|
+
// even though the shaders read uint8s
|
|
44
|
+
this.opacityVertexBuffer.itemSize = 1;
|
|
45
|
+
}
|
|
46
|
+
if (upload || update) {
|
|
47
|
+
this.programConfigurations.upload(context);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
destroy() {
|
|
52
|
+
if (!this.layoutVertexBuffer) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.layoutVertexBuffer.destroy();
|
|
56
|
+
this.indexBuffer.destroy();
|
|
57
|
+
this.programConfigurations.destroy();
|
|
58
|
+
this.segments.destroy();
|
|
59
|
+
this.dynamicLayoutVertexBuffer.destroy();
|
|
60
|
+
this.opacityVertexBuffer.destroy();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { StructArrayLayout2ub4 as CollisionVertexArray } from '../array_types.js';
|
|
2
|
+
import SegmentVector from '../segment.js';
|
|
3
|
+
import { collisionVertexAttributes } from './symbol_attributes.js';
|
|
4
|
+
|
|
5
|
+
export default class CollisionBuffers {
|
|
6
|
+
constructor(LayoutArray, layoutAttributes, IndexArray) {
|
|
7
|
+
this.layoutVertexArray = new LayoutArray();
|
|
8
|
+
this.layoutAttributes = layoutAttributes;
|
|
9
|
+
this.indexArray = new IndexArray();
|
|
10
|
+
this.segments = new SegmentVector();
|
|
11
|
+
this.collisionVertexArray = new CollisionVertexArray();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
upload(context) {
|
|
15
|
+
this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, this.layoutAttributes);
|
|
16
|
+
this.indexBuffer = context.createIndexBuffer(this.indexArray);
|
|
17
|
+
this.collisionVertexBuffer = context.createVertexBuffer(
|
|
18
|
+
this.collisionVertexArray,
|
|
19
|
+
collisionVertexAttributes.members,
|
|
20
|
+
true
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
destroy() {
|
|
25
|
+
if (!this.layoutVertexBuffer) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.layoutVertexBuffer.destroy();
|
|
29
|
+
this.indexBuffer.destroy();
|
|
30
|
+
this.segments.destroy();
|
|
31
|
+
this.collisionVertexBuffer.destroy();
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/data/bucket.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
// style may have changed between creating a bucket when tile was loaded and rendering it
|
|
21
|
-
function updateBuckets(buckets, style) {
|
|
21
|
+
export function updateBuckets(buckets, style) {
|
|
22
22
|
if (!style._changed) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
@@ -39,7 +39,7 @@ function updateBuckets(buckets, style) {
|
|
|
39
39
|
}
|
|
40
40
|
updatedAlready.add(id);
|
|
41
41
|
|
|
42
|
-
const layers = bucket.
|
|
42
|
+
const layers = bucket.layers.map(({ id }) => style.getLayer(id)).filter(Boolean);
|
|
43
43
|
|
|
44
44
|
if (layers.length === 0) {
|
|
45
45
|
bucket.destroy();
|
|
@@ -52,7 +52,3 @@ function updateBuckets(buckets, style) {
|
|
|
52
52
|
bucket.stateDependentLayers = layers.filter(layer => layer.isStateDependent());
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
module.exports = {
|
|
57
|
-
updateBuckets
|
|
58
|
-
};
|
package/src/data/dem_data.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const warn = require('../util/warn');
|
|
1
|
+
import { RGBAImage } from '../util/image.js';
|
|
2
|
+
import warn from '../util/warn.js';
|
|
4
3
|
|
|
5
4
|
// DEMData is a data structure for decoding, backfilling, and storing elevation data for processing in the hillshade shaders
|
|
6
5
|
// data can be populated either from a pngraw image tile or from serliazed data sent back from a worker. When data is initially
|
|
@@ -15,7 +14,9 @@ const warn = require('../util/warn');
|
|
|
15
14
|
class DEMData {
|
|
16
15
|
constructor(uid, data, encoding) {
|
|
17
16
|
this.uid = uid;
|
|
18
|
-
if (data.height !== data.width)
|
|
17
|
+
if (data.height !== data.width) {
|
|
18
|
+
throw new RangeError('DEM tiles must be square');
|
|
19
|
+
}
|
|
19
20
|
if (encoding && encoding !== 'mapbox' && encoding !== 'terrarium') {
|
|
20
21
|
warn.once(`"${encoding}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);
|
|
21
22
|
return;
|
|
@@ -63,8 +64,9 @@ class DEMData {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
_idx(x, y) {
|
|
66
|
-
if (x < -1 || x >= this.dim + 1 || y < -1 || y >= this.dim + 1)
|
|
67
|
+
if (x < -1 || x >= this.dim + 1 || y < -1 || y >= this.dim + 1) {
|
|
67
68
|
throw new RangeError('out of range source coordinates for DEM data');
|
|
69
|
+
}
|
|
68
70
|
return (y + 1) * this.stride + (x + 1);
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -85,7 +87,9 @@ class DEMData {
|
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
backfillBorder(borderTile, dx, dy) {
|
|
88
|
-
if (this.dim !== borderTile.dim)
|
|
90
|
+
if (this.dim !== borderTile.dim) {
|
|
91
|
+
throw new Error('dem dimension mismatch');
|
|
92
|
+
}
|
|
89
93
|
|
|
90
94
|
let xMin = dx * this.dim;
|
|
91
95
|
let xMax = dx * this.dim + this.dim;
|
|
@@ -120,4 +124,4 @@ class DEMData {
|
|
|
120
124
|
}
|
|
121
125
|
}
|
|
122
126
|
|
|
123
|
-
|
|
127
|
+
export default DEMData;
|
package/src/data/extent.js
CHANGED