@mapwhit/tilerenderer 1.0.0 → 1.1.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 +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 +105 -47
- 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 +58 -33
- 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 +53 -33
- 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,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const { FeatureIndexArray } = require('./array_types');
|
|
1
|
+
import Grid from 'grid-index';
|
|
2
|
+
import EvaluationParameters from '../style/evaluation_parameters.js';
|
|
3
|
+
import featureFilter from '../style-spec/feature_filter/index.js';
|
|
4
|
+
import dictionaryCoder from '../util/dictionary_coder.js';
|
|
5
|
+
import { polygonIntersectsBox } from '../util/intersection_tests.js';
|
|
6
|
+
import { arraysIntersect } from '../util/object.js';
|
|
7
|
+
import GeoJSONFeature from '../util/vectortile_to_geojson.js';
|
|
8
|
+
import { FeatureIndexArray } from './array_types.js';
|
|
9
|
+
import EXTENT from './extent.js';
|
|
10
|
+
import loadGeometry from './load_geometry.js';
|
|
12
11
|
|
|
13
12
|
class FeatureIndex {
|
|
14
13
|
constructor(tileID, grid = new Grid(EXTENT, 16, 0), featureIndexArray = new FeatureIndexArray()) {
|
|
@@ -85,7 +84,9 @@ class FeatureIndex {
|
|
|
85
84
|
const index = matching[k];
|
|
86
85
|
|
|
87
86
|
// don't check the same feature more than once
|
|
88
|
-
if (index === previousIndex)
|
|
87
|
+
if (index === previousIndex) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
89
90
|
previousIndex = index;
|
|
90
91
|
|
|
91
92
|
const match = this.featureIndexArray.get(index);
|
|
@@ -136,13 +137,17 @@ class FeatureIndex {
|
|
|
136
137
|
intersectionTest
|
|
137
138
|
) {
|
|
138
139
|
const layerIDs = this.bucketLayerIDs[bucketIndex];
|
|
139
|
-
if (filterLayerIDs && !arraysIntersect(filterLayerIDs, layerIDs))
|
|
140
|
+
if (filterLayerIDs && !arraysIntersect(filterLayerIDs, layerIDs)) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
140
143
|
|
|
141
144
|
const sourceLayerName = this.sourceLayerCoder.decode(sourceLayerIndex);
|
|
142
145
|
const sourceLayer = this.vtLayers[sourceLayerName];
|
|
143
146
|
const feature = sourceLayer.feature(featureIndex);
|
|
144
147
|
|
|
145
|
-
if (!filter(new EvaluationParameters(this.tileID.overscaledZ), feature))
|
|
148
|
+
if (!filter(new EvaluationParameters(this.tileID.overscaledZ), feature)) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
146
151
|
|
|
147
152
|
const { x, y, z } = this.tileID.canonical;
|
|
148
153
|
for (const layerID of layerIDs) {
|
|
@@ -151,7 +156,9 @@ class FeatureIndex {
|
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
const styleLayer = styleLayers.get(layerID);
|
|
154
|
-
if (!styleLayer)
|
|
159
|
+
if (!styleLayer) {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
155
162
|
|
|
156
163
|
const intersectionZ = !intersectionTest || intersectionTest(feature, styleLayer);
|
|
157
164
|
if (!intersectionZ) {
|
|
@@ -189,7 +196,7 @@ class FeatureIndex {
|
|
|
189
196
|
}
|
|
190
197
|
}
|
|
191
198
|
|
|
192
|
-
|
|
199
|
+
export default FeatureIndex;
|
|
193
200
|
|
|
194
201
|
function getBounds(geometry) {
|
|
195
202
|
let minX = Number.POSITIVE_INFINITY;
|
|
@@ -197,10 +204,18 @@ function getBounds(geometry) {
|
|
|
197
204
|
let maxX = Number.NEGATIVE_INFINITY;
|
|
198
205
|
let maxY = Number.NEGATIVE_INFINITY;
|
|
199
206
|
for (const { x, y } of geometry) {
|
|
200
|
-
if (x < minX)
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (
|
|
207
|
+
if (x < minX) {
|
|
208
|
+
minX = x;
|
|
209
|
+
}
|
|
210
|
+
if (x > maxX) {
|
|
211
|
+
maxX = x;
|
|
212
|
+
}
|
|
213
|
+
if (y < minY) {
|
|
214
|
+
minY = y;
|
|
215
|
+
}
|
|
216
|
+
if (y > maxY) {
|
|
217
|
+
maxY = y;
|
|
218
|
+
}
|
|
204
219
|
}
|
|
205
220
|
return { minX, minY, maxX, maxY };
|
|
206
221
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export { LineIndexArray, LineStripIndexArray, TriangleIndexArray } from './array_types.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* An index array stores Uint16 indices of vertexes in a corresponding vertex array. We use
|
|
@@ -7,8 +7,3 @@ const { LineIndexArray, TriangleIndexArray, LineStripIndexArray } = require('./a
|
|
|
7
7
|
* forming a line strip.
|
|
8
8
|
* @private
|
|
9
9
|
*/
|
|
10
|
-
module.exports = {
|
|
11
|
-
LineIndexArray,
|
|
12
|
-
TriangleIndexArray,
|
|
13
|
-
LineStripIndexArray
|
|
14
|
-
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const EXTENT = require('./extent');
|
|
1
|
+
import warn from '../util/warn.js';
|
|
2
|
+
import EXTENT from './extent.js';
|
|
4
3
|
|
|
5
4
|
// These bounds define the minimum and maximum supported coordinate values.
|
|
6
5
|
// While visible coordinates are within [0, EXTENT], tiles may theoretically
|
|
@@ -21,13 +20,11 @@ const bounds = createBounds(16);
|
|
|
21
20
|
* @param {VectorTileFeature} feature
|
|
22
21
|
* @private
|
|
23
22
|
*/
|
|
24
|
-
|
|
23
|
+
export default function loadGeometry(feature) {
|
|
25
24
|
const scale = EXTENT / feature.extent;
|
|
26
25
|
const geometry = feature.loadGeometry();
|
|
27
|
-
for (
|
|
28
|
-
const ring
|
|
29
|
-
for (let p = 0; p < ring.length; p++) {
|
|
30
|
-
const point = ring[p];
|
|
26
|
+
for (const ring of geometry) {
|
|
27
|
+
for (const point of ring) {
|
|
31
28
|
// round here because mapbox-gl-native uses integers to represent
|
|
32
29
|
// points and we need to do the same to avoid renering differences.
|
|
33
30
|
point.x = Math.round(point.x * scale);
|
|
@@ -39,4 +36,4 @@ module.exports = function loadGeometry(feature) {
|
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
38
|
return geometry;
|
|
42
|
-
}
|
|
39
|
+
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module.exports = createLayout([{ name: 'a_pos', type: 'Int16', components: 2 }]);
|
|
1
|
+
import { createLayout } from '../util/struct_array.js';
|
|
2
|
+
export default createLayout([{ name: 'a_pos', type: 'Int16', components: 2 }]);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { supportsPropertyExpression } from '@mapwhit/style-expressions';
|
|
2
|
+
import { Uniform1f, Uniform4f, UniformColor } from '../render/uniform_binding.js';
|
|
3
|
+
import { packUint8ToFloat } from '../shaders/encode_attribute.js';
|
|
4
|
+
import EvaluationParameters from '../style/evaluation_parameters.js';
|
|
5
|
+
import { PossiblyEvaluatedPropertyValue } from '../style/properties.js';
|
|
6
|
+
import {
|
|
7
|
+
PatternLayoutArray,
|
|
5
8
|
StructArrayLayout1f4,
|
|
6
9
|
StructArrayLayout2f8,
|
|
7
|
-
StructArrayLayout4f16
|
|
8
|
-
|
|
9
|
-
} = require('./array_types');
|
|
10
|
-
const EvaluationParameters = require('../style/evaluation_parameters');
|
|
11
|
-
const { Uniform1f, UniformColor, Uniform4f } = require('../render/uniform_binding');
|
|
10
|
+
StructArrayLayout4f16
|
|
11
|
+
} from './array_types.js';
|
|
12
12
|
|
|
13
13
|
function packColor(color) {
|
|
14
14
|
return [packUint8ToFloat(255 * color.r, 255 * color.g), packUint8ToFloat(255 * color.b, 255 * color.a)];
|
|
@@ -96,8 +96,12 @@ class CrossFadedConstantBinder {
|
|
|
96
96
|
|
|
97
97
|
setUniforms(context, uniform, globals, currentValue, uniformName) {
|
|
98
98
|
const pos = this.patternPositions;
|
|
99
|
-
if (uniformName === 'u_pattern_to' && pos.patternTo)
|
|
100
|
-
|
|
99
|
+
if (uniformName === 'u_pattern_to' && pos.patternTo) {
|
|
100
|
+
uniform.set(pos.patternTo);
|
|
101
|
+
}
|
|
102
|
+
if (uniformName === 'u_pattern_from' && pos.patternFrom) {
|
|
103
|
+
uniform.set(pos.patternFrom);
|
|
104
|
+
}
|
|
101
105
|
}
|
|
102
106
|
|
|
103
107
|
getBinding(context, location) {
|
|
@@ -350,7 +354,9 @@ class CrossFadedCompositeBinder {
|
|
|
350
354
|
const imageMid = imagePositions[mid];
|
|
351
355
|
const imageMax = imagePositions[max];
|
|
352
356
|
|
|
353
|
-
if (!imageMin || !imageMid || !imageMax)
|
|
357
|
+
if (!imageMin || !imageMid || !imageMax) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
354
360
|
|
|
355
361
|
for (let i = start; i < length; i++) {
|
|
356
362
|
zoomInArray.emplaceBack(
|
|
@@ -393,7 +399,9 @@ class CrossFadedCompositeBinder {
|
|
|
393
399
|
const imageMid = imagePositions[mid];
|
|
394
400
|
const imageMax = imagePositions[max];
|
|
395
401
|
|
|
396
|
-
if (!imageMin || !imageMid || !imageMax)
|
|
402
|
+
if (!imageMin || !imageMid || !imageMax) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
397
405
|
for (let i = start; i < end; i++) {
|
|
398
406
|
zoomInArray.emplace(
|
|
399
407
|
i,
|
|
@@ -438,8 +446,12 @@ class CrossFadedCompositeBinder {
|
|
|
438
446
|
}
|
|
439
447
|
|
|
440
448
|
destroy() {
|
|
441
|
-
if (this.zoomOutPaintVertexBuffer)
|
|
442
|
-
|
|
449
|
+
if (this.zoomOutPaintVertexBuffer) {
|
|
450
|
+
this.zoomOutPaintVertexBuffer.destroy();
|
|
451
|
+
}
|
|
452
|
+
if (this.zoomInPaintVertexBuffer) {
|
|
453
|
+
this.zoomInPaintVertexBuffer.destroy();
|
|
454
|
+
}
|
|
443
455
|
}
|
|
444
456
|
|
|
445
457
|
setUniforms(context, uniform) {
|
|
@@ -471,7 +483,7 @@ class CrossFadedCompositeBinder {
|
|
|
471
483
|
*
|
|
472
484
|
* @private
|
|
473
485
|
*/
|
|
474
|
-
class ProgramConfiguration {
|
|
486
|
+
export default class ProgramConfiguration {
|
|
475
487
|
constructor() {
|
|
476
488
|
this.binders = {};
|
|
477
489
|
this.cacheKey = '';
|
|
@@ -486,7 +498,9 @@ class ProgramConfiguration {
|
|
|
486
498
|
const keys = [];
|
|
487
499
|
|
|
488
500
|
for (const property in layer._paint._values) {
|
|
489
|
-
if (!filterProperties(property))
|
|
501
|
+
if (!filterProperties(property)) {
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
490
504
|
const value = layer._paint.get(property);
|
|
491
505
|
if (
|
|
492
506
|
!(value instanceof PossiblyEvaluatedPropertyValue) ||
|
|
@@ -574,7 +588,9 @@ class ProgramConfiguration {
|
|
|
574
588
|
let dirty = false;
|
|
575
589
|
for (const id in featureStates) {
|
|
576
590
|
const posArray = this._idMap[id];
|
|
577
|
-
if (!posArray)
|
|
591
|
+
if (!posArray) {
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
578
594
|
|
|
579
595
|
const featureState = featureStates[id];
|
|
580
596
|
for (const pos of posArray) {
|
|
@@ -582,7 +598,9 @@ class ProgramConfiguration {
|
|
|
582
598
|
|
|
583
599
|
for (const property in this.binders) {
|
|
584
600
|
const binder = this.binders[property];
|
|
585
|
-
if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder)
|
|
601
|
+
if (binder instanceof ConstantBinder || binder instanceof CrossFadedConstantBinder) {
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
586
604
|
if (binder.expression.isStateDependent === true) {
|
|
587
605
|
//AHM: Remove after https://github.com/mapbox/mapbox-gl-js/issues/6255
|
|
588
606
|
const value = layer._paint.get(property);
|
|
@@ -639,7 +657,9 @@ class ProgramConfiguration {
|
|
|
639
657
|
if (binder instanceof CrossFadedCompositeBinder) {
|
|
640
658
|
const patternVertexBuffer =
|
|
641
659
|
crossfade.fromScale === 2 ? binder.zoomInPaintVertexBuffer : binder.zoomOutPaintVertexBuffer;
|
|
642
|
-
if (patternVertexBuffer)
|
|
660
|
+
if (patternVertexBuffer) {
|
|
661
|
+
buffers.push(patternVertexBuffer);
|
|
662
|
+
}
|
|
643
663
|
} else if (
|
|
644
664
|
(binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) &&
|
|
645
665
|
binder.paintVertexBuffer
|
|
@@ -676,7 +696,7 @@ class ProgramConfiguration {
|
|
|
676
696
|
}
|
|
677
697
|
}
|
|
678
698
|
|
|
679
|
-
class ProgramConfigurationSet {
|
|
699
|
+
export class ProgramConfigurationSet {
|
|
680
700
|
constructor(layoutAttributes, layers, zoom, filterProperties = () => true) {
|
|
681
701
|
this.programConfigurations = {};
|
|
682
702
|
for (const layer of layers) {
|
|
@@ -706,7 +726,9 @@ class ProgramConfigurationSet {
|
|
|
706
726
|
}
|
|
707
727
|
|
|
708
728
|
upload(context) {
|
|
709
|
-
if (!this.needsUpload)
|
|
729
|
+
if (!this.needsUpload) {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
710
732
|
for (const layerId in this.programConfigurations) {
|
|
711
733
|
this.programConfigurations[layerId].upload(context);
|
|
712
734
|
}
|
|
@@ -775,7 +797,3 @@ function layoutType(property, type, binderType) {
|
|
|
775
797
|
const layoutException = getLayoutException(property);
|
|
776
798
|
return layoutException?.[binderType] || defaultLayouts[type][binderType];
|
|
777
799
|
}
|
|
778
|
-
|
|
779
|
-
ProgramConfiguration.ProgramConfigurationSet = ProgramConfigurationSet;
|
|
780
|
-
|
|
781
|
-
module.exports = ProgramConfiguration;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { createLayout } from '../util/struct_array.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default createLayout([
|
|
4
4
|
{ name: 'a_pos', type: 'Int16', components: 2 },
|
|
5
5
|
{ name: 'a_texture_pos', type: 'Int16', components: 2 }
|
|
6
6
|
]);
|
package/src/data/segment.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import warn from '../util/warn.js';
|
|
2
2
|
|
|
3
3
|
class SegmentVector {
|
|
4
4
|
constructor(segments = []) {
|
|
@@ -6,10 +6,11 @@ class SegmentVector {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
prepareSegment(numVertices, layoutVertexArray, indexArray) {
|
|
9
|
-
if (numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH)
|
|
9
|
+
if (numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {
|
|
10
10
|
warn.once(
|
|
11
11
|
`Max vertices per segment is ${SegmentVector.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${numVertices}`
|
|
12
12
|
);
|
|
13
|
+
}
|
|
13
14
|
let segment = this.segments.at(-1);
|
|
14
15
|
if (!segment || segment.vertexLength + numVertices > SegmentVector.MAX_VERTEX_ARRAY_LENGTH) {
|
|
15
16
|
segment = {
|
|
@@ -56,4 +57,4 @@ class SegmentVector {
|
|
|
56
57
|
*/
|
|
57
58
|
SegmentVector.MAX_VERTEX_ARRAY_LENGTH = 2 ** 16 - 1;
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
export default SegmentVector;
|
package/src/geo/coordinate.js
CHANGED
package/src/geo/lng_lat.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { wrap } from '../util/util.js';
|
|
2
|
+
import LngLatBounds from './lng_lat_bounds.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees.
|
|
@@ -80,7 +81,6 @@ class LngLat {
|
|
|
80
81
|
const earthCircumferenceInMetersAtEquator = 40075017;
|
|
81
82
|
const latAccuracy = (360 * radius) / earthCircumferenceInMetersAtEquator;
|
|
82
83
|
const lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
|
|
83
|
-
const LngLatBounds = require('./lng_lat_bounds');
|
|
84
84
|
|
|
85
85
|
return new LngLatBounds(
|
|
86
86
|
new LngLat(this.lng - lngAccuracy, this.lat - latAccuracy),
|
|
@@ -126,4 +126,4 @@ class LngLat {
|
|
|
126
126
|
* var v2 = [-122.420679, 37.772537];
|
|
127
127
|
*/
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
export default LngLat;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import LngLat from './lng_lat.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A `LngLatBounds` object represents a geographical bounding box,
|
|
@@ -73,7 +73,9 @@ class LngLatBounds {
|
|
|
73
73
|
sw2 = obj._sw;
|
|
74
74
|
ne2 = obj._ne;
|
|
75
75
|
|
|
76
|
-
if (!sw2 || !ne2)
|
|
76
|
+
if (!sw2 || !ne2) {
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
77
79
|
} else {
|
|
78
80
|
if (Array.isArray(obj)) {
|
|
79
81
|
if (obj.every(Array.isArray)) {
|
|
@@ -231,7 +233,9 @@ class LngLatBounds {
|
|
|
231
233
|
* llb; // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}}
|
|
232
234
|
*/
|
|
233
235
|
static convert(input) {
|
|
234
|
-
if (!input || input instanceof LngLatBounds)
|
|
236
|
+
if (!input || input instanceof LngLatBounds) {
|
|
237
|
+
return input;
|
|
238
|
+
}
|
|
235
239
|
return new LngLatBounds(input);
|
|
236
240
|
}
|
|
237
241
|
}
|
|
@@ -250,4 +254,4 @@ class LngLatBounds {
|
|
|
250
254
|
* var v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
|
|
251
255
|
*/
|
|
252
256
|
|
|
253
|
-
|
|
257
|
+
export default LngLatBounds;
|
package/src/geo/transform.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import glMatrix from '@mapbox/gl-matrix';
|
|
2
|
+
import Point from '@mapbox/point-geometry';
|
|
3
|
+
import EXTENT from '../data/extent.js';
|
|
4
|
+
import { UnwrappedTileID } from '../source/tile_id.js';
|
|
5
|
+
import interpolate from '../util/interpolate.js';
|
|
6
|
+
import tileCover from '../util/tile_cover.js';
|
|
7
|
+
import { clamp, wrap } from '../util/util.js';
|
|
8
|
+
import Coordinate from './coordinate.js';
|
|
9
|
+
import LngLat from './lng_lat.js';
|
|
10
|
+
|
|
11
|
+
const { mat2, mat4, vec4 } = glMatrix;
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* A single transform, generally used for a single tile to be
|
|
@@ -57,7 +58,9 @@ class Transform {
|
|
|
57
58
|
return this._minZoom;
|
|
58
59
|
}
|
|
59
60
|
set minZoom(zoom) {
|
|
60
|
-
if (this._minZoom === zoom)
|
|
61
|
+
if (this._minZoom === zoom) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
61
64
|
this._minZoom = zoom;
|
|
62
65
|
this.zoom = Math.max(this.zoom, zoom);
|
|
63
66
|
}
|
|
@@ -66,7 +69,9 @@ class Transform {
|
|
|
66
69
|
return this._maxZoom;
|
|
67
70
|
}
|
|
68
71
|
set maxZoom(zoom) {
|
|
69
|
-
if (this._maxZoom === zoom)
|
|
72
|
+
if (this._maxZoom === zoom) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
70
75
|
this._maxZoom = zoom;
|
|
71
76
|
this.zoom = Math.min(this.zoom, zoom);
|
|
72
77
|
}
|
|
@@ -101,7 +106,9 @@ class Transform {
|
|
|
101
106
|
}
|
|
102
107
|
set bearing(bearing) {
|
|
103
108
|
const b = (-wrap(bearing, -180, 180) * Math.PI) / 180;
|
|
104
|
-
if (this.angle === b)
|
|
109
|
+
if (this.angle === b) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
105
112
|
this._unmodified = false;
|
|
106
113
|
this.angle = b;
|
|
107
114
|
this._calcMatrices();
|
|
@@ -116,7 +123,9 @@ class Transform {
|
|
|
116
123
|
}
|
|
117
124
|
set pitch(pitch) {
|
|
118
125
|
const p = (clamp(pitch, 0, 60) / 180) * Math.PI;
|
|
119
|
-
if (this._pitch === p)
|
|
126
|
+
if (this._pitch === p) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
120
129
|
this._unmodified = false;
|
|
121
130
|
this._pitch = p;
|
|
122
131
|
this._calcMatrices();
|
|
@@ -127,7 +136,9 @@ class Transform {
|
|
|
127
136
|
}
|
|
128
137
|
set fov(fov) {
|
|
129
138
|
fov = Math.max(0.01, Math.min(60, fov));
|
|
130
|
-
if (this._fov === fov)
|
|
139
|
+
if (this._fov === fov) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
131
142
|
this._unmodified = false;
|
|
132
143
|
this._fov = (fov / 180) * Math.PI;
|
|
133
144
|
this._calcMatrices();
|
|
@@ -138,7 +149,9 @@ class Transform {
|
|
|
138
149
|
}
|
|
139
150
|
set zoom(zoom) {
|
|
140
151
|
const z = Math.min(Math.max(zoom, this.minZoom), this.maxZoom);
|
|
141
|
-
if (this._zoom === z)
|
|
152
|
+
if (this._zoom === z) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
142
155
|
this._unmodified = false;
|
|
143
156
|
this._zoom = z;
|
|
144
157
|
this.scale = this.zoomScale(z);
|
|
@@ -152,7 +165,9 @@ class Transform {
|
|
|
152
165
|
return this._center;
|
|
153
166
|
}
|
|
154
167
|
set center(center) {
|
|
155
|
-
if (center.lat === this._center.lat && center.lng === this._center.lng)
|
|
168
|
+
if (center.lat === this._center.lat && center.lng === this._center.lng) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
156
171
|
this._unmodified = false;
|
|
157
172
|
this._center = center;
|
|
158
173
|
this._constrain();
|
|
@@ -192,7 +207,9 @@ class Transform {
|
|
|
192
207
|
const extraWorldCopy = 1;
|
|
193
208
|
|
|
194
209
|
for (let w = w0 - extraWorldCopy; w <= w1 + extraWorldCopy; w++) {
|
|
195
|
-
if (w === 0)
|
|
210
|
+
if (w === 0) {
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
196
213
|
result.push(new UnwrappedTileID(w, tileID));
|
|
197
214
|
}
|
|
198
215
|
}
|
|
@@ -215,8 +232,12 @@ class Transform {
|
|
|
215
232
|
let z = this.coveringZoomLevel(options);
|
|
216
233
|
const actualZ = z;
|
|
217
234
|
|
|
218
|
-
if (options.minzoom !== undefined && z < options.minzoom)
|
|
219
|
-
|
|
235
|
+
if (options.minzoom !== undefined && z < options.minzoom) {
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
238
|
+
if (options.maxzoom !== undefined && z > options.maxzoom) {
|
|
239
|
+
z = options.maxzoom;
|
|
240
|
+
}
|
|
220
241
|
|
|
221
242
|
const centerCoord = this.pointCoordinate(this.centerPoint, z);
|
|
222
243
|
const centerPoint = new Point(centerCoord.column - 0.5, centerCoord.row - 0.5);
|
|
@@ -346,7 +367,9 @@ class Transform {
|
|
|
346
367
|
}
|
|
347
368
|
|
|
348
369
|
pointCoordinate(p, zoom) {
|
|
349
|
-
if (zoom === undefined)
|
|
370
|
+
if (zoom === undefined) {
|
|
371
|
+
zoom = this.tileZoom;
|
|
372
|
+
}
|
|
350
373
|
|
|
351
374
|
const targetZ = 0;
|
|
352
375
|
// since we don't know the correct projected z value for the point,
|
|
@@ -414,7 +437,9 @@ class Transform {
|
|
|
414
437
|
}
|
|
415
438
|
|
|
416
439
|
_constrain() {
|
|
417
|
-
if (!this.center || !this.width || !this.height || this._constraining)
|
|
440
|
+
if (!this.center || !this.width || !this.height || this._constraining) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
418
443
|
|
|
419
444
|
this._constraining = true;
|
|
420
445
|
|
|
@@ -458,16 +483,24 @@ class Transform {
|
|
|
458
483
|
const y = this.y;
|
|
459
484
|
const h2 = size.y / 2;
|
|
460
485
|
|
|
461
|
-
if (y - h2 < minY)
|
|
462
|
-
|
|
486
|
+
if (y - h2 < minY) {
|
|
487
|
+
y2 = minY + h2;
|
|
488
|
+
}
|
|
489
|
+
if (y + h2 > maxY) {
|
|
490
|
+
y2 = maxY - h2;
|
|
491
|
+
}
|
|
463
492
|
}
|
|
464
493
|
|
|
465
494
|
if (this.lngRange) {
|
|
466
495
|
const x = this.x;
|
|
467
496
|
const w2 = size.x / 2;
|
|
468
497
|
|
|
469
|
-
if (x - w2 < minX)
|
|
470
|
-
|
|
498
|
+
if (x - w2 < minX) {
|
|
499
|
+
x2 = minX + w2;
|
|
500
|
+
}
|
|
501
|
+
if (x + w2 > maxX) {
|
|
502
|
+
x2 = maxX - w2;
|
|
503
|
+
}
|
|
471
504
|
}
|
|
472
505
|
|
|
473
506
|
// pan the map if the screen goes off the range
|
|
@@ -480,7 +513,9 @@ class Transform {
|
|
|
480
513
|
}
|
|
481
514
|
|
|
482
515
|
_calcMatrices() {
|
|
483
|
-
if (!this.height)
|
|
516
|
+
if (!this.height) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
484
519
|
|
|
485
520
|
this.cameraToCenterDistance = (0.5 / Math.tan(this._fov / 2)) * this.height;
|
|
486
521
|
|
|
@@ -542,7 +577,9 @@ class Transform {
|
|
|
542
577
|
|
|
543
578
|
// inverse matrix for conversion from screen coordinaes to location
|
|
544
579
|
m = mat4.invert(new Float64Array(16), this.pixelMatrix);
|
|
545
|
-
if (!m)
|
|
580
|
+
if (!m) {
|
|
581
|
+
throw new Error('failed to invert matrix');
|
|
582
|
+
}
|
|
546
583
|
this.pixelMatrixInverse = m;
|
|
547
584
|
|
|
548
585
|
this._posMatrixCache = {};
|
|
@@ -551,7 +588,9 @@ class Transform {
|
|
|
551
588
|
|
|
552
589
|
maxPitchScaleFactor() {
|
|
553
590
|
// calcMatrices hasn't run yet
|
|
554
|
-
if (!this.pixelMatrixInverse)
|
|
591
|
+
if (!this.pixelMatrixInverse) {
|
|
592
|
+
return 1;
|
|
593
|
+
}
|
|
555
594
|
|
|
556
595
|
const coord = this.pointCoordinate(new Point(0, 0)).zoomTo(this.zoom);
|
|
557
596
|
const p = [coord.column * this.tileSize, coord.row * this.tileSize, 0, 1];
|
|
@@ -612,4 +651,4 @@ class Transform {
|
|
|
612
651
|
}
|
|
613
652
|
}
|
|
614
653
|
|
|
615
|
-
|
|
654
|
+
export default Transform;
|
package/src/gl/color_mode.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { Color } from '@mapwhit/style-expressions';
|
|
2
2
|
|
|
3
3
|
const ZERO = 0x0000;
|
|
4
4
|
const ONE = 0x0001;
|
|
@@ -18,4 +18,4 @@ class ColorMode {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
export default ColorMode;
|