@mapgis/mapbox-gl 16.0.1 → 16.2.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/dist/mapbox-gl.js +3 -3
- package/dist/mapbox-gl.js.map +1 -1
- package/package.json +1 -1
- package/.flowconfig +0 -61
- package/LICENSE.txt +0 -84
- package/README.md +0 -34
- package/build/banner.js +0 -4
- package/build/check-bundle-size.js +0 -140
- package/build/generate-access-token-script.js +0 -11
- package/build/generate-flow-typed-style-spec.js +0 -188
- package/build/generate-release-list.js +0 -21
- package/build/generate-struct-arrays.js +0 -237
- package/build/generate-style-code.js +0 -159
- package/build/mapbox-gl.js.flow +0 -3
- package/build/print-release-url.js +0 -6
- package/build/rollup_plugin_minify_style_spec.js +0 -20
- package/build/rollup_plugins.js +0 -80
- package/build/run-node +0 -3
- package/build/run-tap +0 -8
- package/build/test/build-tape.js +0 -19
- package/flow-typed/gl.js +0 -5
- package/flow-typed/jsdom.js +0 -18
- package/flow-typed/mapbox-gl-supported.js +0 -9
- package/flow-typed/mapbox-unitbezier.js +0 -14
- package/flow-typed/offscreen-canvas.js +0 -9
- package/flow-typed/pbf.js +0 -25
- package/flow-typed/point-geometry.js +0 -44
- package/flow-typed/potpack.js +0 -12
- package/flow-typed/sinon.js +0 -28
- package/flow-typed/vector-tile.js +0 -41
- package/src/css/mapbox-gl.css +0 -798
- package/src/css/svg/mapboxgl-ctrl-attrib.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-compass.svg +0 -4
- package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-geolocate.svg +0 -5
- package/src/css/svg/mapboxgl-ctrl-logo.svg +0 -20
- package/src/css/svg/mapboxgl-ctrl-shrink.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +0 -3
- package/src/data/array_types.js +0 -1095
- package/src/data/bucket/circle_attributes.js +0 -9
- package/src/data/bucket/circle_bucket.js +0 -204
- package/src/data/bucket/fill_attributes.js +0 -9
- package/src/data/bucket/fill_bucket.js +0 -233
- package/src/data/bucket/fill_extrusion_attributes.js +0 -10
- package/src/data/bucket/fill_extrusion_bucket.js +0 -289
- package/src/data/bucket/heatmap_bucket.js +0 -17
- package/src/data/bucket/line_attributes.js +0 -10
- package/src/data/bucket/line_bucket.js +0 -556
- package/src/data/bucket/pattern_attributes.js +0 -10
- package/src/data/bucket/pattern_bucket_features.js +0 -60
- package/src/data/bucket/symbol_attributes.js +0 -117
- package/src/data/bucket/symbol_bucket.js +0 -972
- package/src/data/bucket.js +0 -123
- package/src/data/dem_data.js +0 -125
- package/src/data/extent.js +0 -18
- package/src/data/feature_index.js +0 -321
- package/src/data/feature_position_map.js +0 -125
- package/src/data/index_array_type.js +0 -16
- package/src/data/load_geometry.js +0 -48
- package/src/data/pos_attributes.js +0 -6
- package/src/data/program_configuration.js +0 -687
- package/src/data/raster_bounds_attributes.js +0 -7
- package/src/data/segment.js +0 -76
- package/src/geo/edge_insets.js +0 -102
- package/src/geo/lng_lat.js +0 -165
- package/src/geo/lng_lat_bounds.js +0 -267
- package/src/geo/mercator_coordinate.js +0 -153
- package/src/geo/transform.js +0 -864
- package/src/gl/color_mode.js +0 -34
- package/src/gl/context.js +0 -298
- package/src/gl/cull_face_mode.js +0 -26
- package/src/gl/depth_mode.js +0 -29
- package/src/gl/framebuffer.js +0 -44
- package/src/gl/index_buffer.js +0 -55
- package/src/gl/stencil_mode.js +0 -30
- package/src/gl/types.js +0 -84
- package/src/gl/value.js +0 -520
- package/src/gl/vertex_buffer.js +0 -119
- package/src/index.js +0 -201
- package/src/render/draw_background.js +0 -57
- package/src/render/draw_circle.js +0 -113
- package/src/render/draw_collision_debug.js +0 -49
- package/src/render/draw_custom.js +0 -49
- package/src/render/draw_debug.js +0 -127
- package/src/render/draw_fill.js +0 -126
- package/src/render/draw_fill_extrusion.js +0 -96
- package/src/render/draw_heatmap.js +0 -140
- package/src/render/draw_hillshade.js +0 -108
- package/src/render/draw_line.js +0 -98
- package/src/render/draw_raster.js +0 -125
- package/src/render/draw_symbol.js +0 -394
- package/src/render/glyph_atlas.js +0 -71
- package/src/render/glyph_manager.js +0 -182
- package/src/render/image_atlas.js +0 -149
- package/src/render/image_manager.js +0 -306
- package/src/render/line_atlas.js +0 -210
- package/src/render/painter.js +0 -653
- package/src/render/program/background_program.js +0 -103
- package/src/render/program/circle_program.js +0 -69
- package/src/render/program/clipping_mask_program.js +0 -20
- package/src/render/program/collision_program.js +0 -49
- package/src/render/program/debug_program.js +0 -35
- package/src/render/program/fill_extrusion_program.js +0 -122
- package/src/render/program/fill_program.js +0 -126
- package/src/render/program/heatmap_program.js +0 -83
- package/src/render/program/hillshade_program.js +0 -122
- package/src/render/program/line_program.js +0 -207
- package/src/render/program/pattern.js +0 -102
- package/src/render/program/program_uniforms.js +0 -42
- package/src/render/program/raster_program.js +0 -92
- package/src/render/program/symbol_program.js +0 -224
- package/src/render/program.js +0 -168
- package/src/render/texture.js +0 -122
- package/src/render/uniform_binding.js +0 -147
- package/src/render/vertex_array_object.js +0 -163
- package/src/shaders/README.md +0 -42
- package/src/shaders/_prelude.fragment.glsl +0 -17
- package/src/shaders/_prelude.vertex.glsl +0 -73
- package/src/shaders/background.fragment.glsl +0 -10
- package/src/shaders/background.vertex.glsl +0 -7
- package/src/shaders/background_pattern.fragment.glsl +0 -28
- package/src/shaders/background_pattern.vertex.glsl +0 -20
- package/src/shaders/circle.fragment.glsl +0 -39
- package/src/shaders/circle.vertex.glsl +0 -64
- package/src/shaders/clipping_mask.fragment.glsl +0 -3
- package/src/shaders/clipping_mask.vertex.glsl +0 -7
- package/src/shaders/collision_box.fragment.glsl +0 -21
- package/src/shaders/collision_box.vertex.glsl +0 -27
- package/src/shaders/collision_circle.fragment.glsl +0 -34
- package/src/shaders/collision_circle.vertex.glsl +0 -36
- package/src/shaders/debug.fragment.glsl +0 -9
- package/src/shaders/debug.vertex.glsl +0 -12
- package/src/shaders/encode_attribute.js +0 -17
- package/src/shaders/fill.fragment.glsl +0 -13
- package/src/shaders/fill.vertex.glsl +0 -13
- package/src/shaders/fill_extrusion.fragment.glsl +0 -9
- package/src/shaders/fill_extrusion.vertex.glsl +0 -66
- package/src/shaders/fill_extrusion_pattern.fragment.glsl +0 -45
- package/src/shaders/fill_extrusion_pattern.vertex.glsl +0 -79
- package/src/shaders/fill_outline.fragment.glsl +0 -17
- package/src/shaders/fill_outline.vertex.glsl +0 -17
- package/src/shaders/fill_outline_pattern.fragment.glsl +0 -43
- package/src/shaders/fill_outline_pattern.vertex.glsl +0 -44
- package/src/shaders/fill_pattern.fragment.glsl +0 -36
- package/src/shaders/fill_pattern.vertex.glsl +0 -39
- package/src/shaders/heatmap.fragment.glsl +0 -22
- package/src/shaders/heatmap.vertex.glsl +0 -54
- package/src/shaders/heatmap_texture.fragment.glsl +0 -14
- package/src/shaders/heatmap_texture.vertex.glsl +0 -11
- package/src/shaders/hillshade.fragment.glsl +0 -52
- package/src/shaders/hillshade.vertex.glsl +0 -11
- package/src/shaders/hillshade_prepare.fragment.glsl +0 -74
- package/src/shaders/hillshade_prepare.vertex.glsl +0 -15
- package/src/shaders/index.js +0 -20
- package/src/shaders/line.fragment.glsl +0 -30
- package/src/shaders/line.vertex.glsl +0 -85
- package/src/shaders/line_gradient.fragment.glsl +0 -34
- package/src/shaders/line_gradient.vertex.glsl +0 -87
- package/src/shaders/line_pattern.fragment.glsl +0 -74
- package/src/shaders/line_pattern.vertex.glsl +0 -99
- package/src/shaders/line_sdf.fragment.glsl +0 -45
- package/src/shaders/line_sdf.vertex.glsl +0 -98
- package/src/shaders/raster.fragment.glsl +0 -52
- package/src/shaders/raster.vertex.glsl +0 -21
- package/src/shaders/shaders.js +0 -180
- package/src/shaders/symbol_icon.fragment.glsl +0 -17
- package/src/shaders/symbol_icon.vertex.glsl +0 -94
- package/src/shaders/symbol_sdf.fragment.glsl +0 -52
- package/src/shaders/symbol_sdf.vertex.glsl +0 -115
- package/src/shaders/symbol_text_and_icon.fragment.glsl +0 -68
- package/src/shaders/symbol_text_and_icon.vertex.glsl +0 -116
- package/src/source/canvas_source.js +0 -238
- package/src/source/geojson_helper.js +0 -92
- package/src/source/geojson_source.js +0 -374
- package/src/source/geojson_worker_source.js +0 -357
- package/src/source/geojson_wrapper.js +0 -94
- package/src/source/image_source.js +0 -307
- package/src/source/load_tilejson.js +0 -39
- package/src/source/mbtiles_source.js +0 -115
- package/src/source/offline_database.js +0 -61
- package/src/source/offline_database_root.js +0 -62
- package/src/source/pixels_to_tile_units.js +0 -21
- package/src/source/query_features.js +0 -208
- package/src/source/raster_dem_tile_source.js +0 -138
- package/src/source/raster_dem_tile_worker_source.js +0 -62
- package/src/source/raster_tile_offline_source.js +0 -136
- package/src/source/raster_tile_source.js +0 -177
- package/src/source/rtl_text_plugin.js +0 -138
- package/src/source/source.js +0 -137
- package/src/source/source_cache.js +0 -957
- package/src/source/source_state.js +0 -159
- package/src/source/tile.js +0 -465
- package/src/source/tile_bounds.js +0 -38
- package/src/source/tile_cache.js +0 -212
- package/src/source/tile_id.js +0 -402
- package/src/source/vector_tile_source.js +0 -192
- package/src/source/vector_tile_worker_source.js +0 -216
- package/src/source/video_source.js +0 -203
- package/src/source/worker.js +0 -237
- package/src/source/worker_source.js +0 -106
- package/src/source/worker_tile.js +0 -224
- package/src/style/create_style_layer.js +0 -36
- package/src/style/evaluation_parameters.js +0 -62
- package/src/style/light.js +0 -130
- package/src/style/load_glyph_range.js +0 -38
- package/src/style/load_sprite.js +0 -67
- package/src/style/parse_glyph_pbf.js +0 -44
- package/src/style/pauseable_placement.js +0 -132
- package/src/style/properties.js +0 -753
- package/src/style/query_utils.js +0 -43
- package/src/style/style.js +0 -1361
- package/src/style/style_glyph.js +0 -17
- package/src/style/style_image.js +0 -137
- package/src/style/style_layer/background_style_layer.js +0 -21
- package/src/style/style_layer/background_style_layer_properties.js +0 -40
- package/src/style/style_layer/circle_style_layer.js +0 -98
- package/src/style/style_layer/circle_style_layer_properties.js +0 -63
- package/src/style/style_layer/custom_style_layer.js +0 -223
- package/src/style/style_layer/fill_extrusion_style_layer.js +0 -224
- package/src/style/style_layer/fill_extrusion_style_layer_properties.js +0 -50
- package/src/style/style_layer/fill_style_layer.js +0 -67
- package/src/style/style_layer/fill_style_layer_properties.js +0 -55
- package/src/style/style_layer/heatmap_style_layer.js +0 -69
- package/src/style/style_layer/heatmap_style_layer_properties.js +0 -44
- package/src/style/style_layer/hillshade_style_layer.js +0 -25
- package/src/style/style_layer/hillshade_style_layer_properties.js +0 -46
- package/src/style/style_layer/layer_properties.js.ejs +0 -69
- package/src/style/style_layer/line_style_layer.js +0 -151
- package/src/style/style_layer/line_style_layer_properties.js +0 -71
- package/src/style/style_layer/raster_style_layer.js +0 -21
- package/src/style/style_layer/raster_style_layer_properties.js +0 -50
- package/src/style/style_layer/symbol_style_layer.js +0 -190
- package/src/style/style_layer/symbol_style_layer_properties.js +0 -153
- package/src/style/style_layer/typed_style_layer.js +0 -17
- package/src/style/style_layer.js +0 -281
- package/src/style/style_layer_index.js +0 -80
- package/src/style/validate_style.js +0 -42
- package/src/style/zoom_history.js +0 -44
- package/src/style-spec/.eslintrc +0 -5
- package/src/style-spec/CHANGELOG.md +0 -438
- package/src/style-spec/README.md +0 -59
- package/src/style-spec/bin/gl-style-composite +0 -9
- package/src/style-spec/bin/gl-style-format +0 -22
- package/src/style-spec/bin/gl-style-migrate +0 -9
- package/src/style-spec/bin/gl-style-validate +0 -50
- package/src/style-spec/composite.js +0 -50
- package/src/style-spec/declass.js +0 -42
- package/src/style-spec/deref.js +0 -52
- package/src/style-spec/diff.js +0 -393
- package/src/style-spec/dist/.gitkeep +0 -0
- package/src/style-spec/empty.js +0 -29
- package/src/style-spec/error/parsing_error.js +0 -16
- package/src/style-spec/error/validation_error.js +0 -18
- package/src/style-spec/expression/compound_expression.js +0 -162
- package/src/style-spec/expression/definitions/assertion.js +0 -130
- package/src/style-spec/expression/definitions/at.js +0 -70
- package/src/style-spec/expression/definitions/case.js +0 -85
- package/src/style-spec/expression/definitions/coalesce.js +0 -93
- package/src/style-spec/expression/definitions/coercion.js +0 -133
- package/src/style-spec/expression/definitions/collator.js +0 -78
- package/src/style-spec/expression/definitions/comparison.js +0 -184
- package/src/style-spec/expression/definitions/format.js +0 -144
- package/src/style-spec/expression/definitions/format_section_override.js +0 -54
- package/src/style-spec/expression/definitions/image.js +0 -52
- package/src/style-spec/expression/definitions/in.js +0 -92
- package/src/style-spec/expression/definitions/index.js +0 -561
- package/src/style-spec/expression/definitions/interpolate.js +0 -267
- package/src/style-spec/expression/definitions/length.js +0 -61
- package/src/style-spec/expression/definitions/let.js +0 -72
- package/src/style-spec/expression/definitions/literal.js +0 -77
- package/src/style-spec/expression/definitions/match.js +0 -158
- package/src/style-spec/expression/definitions/number_format.js +0 -142
- package/src/style-spec/expression/definitions/step.js +0 -120
- package/src/style-spec/expression/definitions/var.js +0 -46
- package/src/style-spec/expression/definitions/within.js +0 -333
- package/src/style-spec/expression/evaluation_context.js +0 -59
- package/src/style-spec/expression/expression.js +0 -27
- package/src/style-spec/expression/index.js +0 -392
- package/src/style-spec/expression/is_constant.js +0 -59
- package/src/style-spec/expression/parsing_context.js +0 -233
- package/src/style-spec/expression/parsing_error.js +0 -13
- package/src/style-spec/expression/runtime_error.js +0 -17
- package/src/style-spec/expression/scope.js +0 -36
- package/src/style-spec/expression/stops.js +0 -39
- package/src/style-spec/expression/types/collator.js +0 -61
- package/src/style-spec/expression/types/formatted.js +0 -73
- package/src/style-spec/expression/types/resolved_image.js +0 -29
- package/src/style-spec/expression/types.js +0 -106
- package/src/style-spec/expression/values.js +0 -123
- package/src/style-spec/feature_filter/README.md +0 -55
- package/src/style-spec/feature_filter/convert.js +0 -208
- package/src/style-spec/feature_filter/index.js +0 -165
- package/src/style-spec/format.js +0 -51
- package/src/style-spec/function/convert.js +0 -254
- package/src/style-spec/function/index.js +0 -262
- package/src/style-spec/group_by_layout.js +0 -75
- package/src/style-spec/migrate/expressions.js +0 -39
- package/src/style-spec/migrate/v8.js +0 -203
- package/src/style-spec/migrate/v9.js +0 -26
- package/src/style-spec/migrate.js +0 -36
- package/src/style-spec/package.json +0 -41
- package/src/style-spec/read_style.js +0 -14
- package/src/style-spec/reference/latest.js +0 -3
- package/src/style-spec/reference/v8.json +0 -5808
- package/src/style-spec/rollup.config.js +0 -45
- package/src/style-spec/style-spec.js +0 -122
- package/src/style-spec/types.js +0 -438
- package/src/style-spec/util/color.js +0 -95
- package/src/style-spec/util/color_spaces.js +0 -139
- package/src/style-spec/util/deep_equal.js +0 -28
- package/src/style-spec/util/extend.js +0 -10
- package/src/style-spec/util/get_type.js +0 -17
- package/src/style-spec/util/interpolate.js +0 -22
- package/src/style-spec/util/properties.js +0 -15
- package/src/style-spec/util/ref_properties.js +0 -2
- package/src/style-spec/util/result.js +0 -19
- package/src/style-spec/util/unbundle_jsonlint.js +0 -24
- package/src/style-spec/validate/latest.js +0 -11
- package/src/style-spec/validate/validate.js +0 -75
- package/src/style-spec/validate/validate_array.js +0 -52
- package/src/style-spec/validate/validate_boolean.js +0 -15
- package/src/style-spec/validate/validate_color.js +0 -20
- package/src/style-spec/validate/validate_constants.js +0 -13
- package/src/style-spec/validate/validate_enum.js +0 -21
- package/src/style-spec/validate/validate_expression.js +0 -43
- package/src/style-spec/validate/validate_filter.js +0 -111
- package/src/style-spec/validate/validate_formatted.js +0 -11
- package/src/style-spec/validate/validate_function.js +0 -207
- package/src/style-spec/validate/validate_glyphs_url.js +0 -21
- package/src/style-spec/validate/validate_image.js +0 -11
- package/src/style-spec/validate/validate_layer.js +0 -134
- package/src/style-spec/validate/validate_layout_property.js +0 -6
- package/src/style-spec/validate/validate_light.js +0 -47
- package/src/style-spec/validate/validate_number.js +0 -29
- package/src/style-spec/validate/validate_object.js +0 -61
- package/src/style-spec/validate/validate_paint_property.js +0 -6
- package/src/style-spec/validate/validate_property.js +0 -64
- package/src/style-spec/validate/validate_source.js +0 -111
- package/src/style-spec/validate/validate_string.js +0 -15
- package/src/style-spec/validate_mapbox_api_supported.js +0 -171
- package/src/style-spec/validate_style.js +0 -39
- package/src/style-spec/validate_style.min.js +0 -78
- package/src/style-spec/visit.js +0 -77
- package/src/symbol/anchor.js +0 -26
- package/src/symbol/check_max_angle.js +0 -81
- package/src/symbol/clip_line.js +0 -71
- package/src/symbol/collision_feature.js +0 -217
- package/src/symbol/collision_index.js +0 -372
- package/src/symbol/cross_tile_symbol_index.js +0 -301
- package/src/symbol/get_anchors.js +0 -167
- package/src/symbol/grid_index.js +0 -335
- package/src/symbol/mergelines.js +0 -82
- package/src/symbol/one_em.js +0 -4
- package/src/symbol/opacity_state.js +0 -27
- package/src/symbol/placement.js +0 -1062
- package/src/symbol/projection.js +0 -450
- package/src/symbol/quads.js +0 -334
- package/src/symbol/shaping.js +0 -816
- package/src/symbol/symbol_layout.js +0 -772
- package/src/symbol/symbol_size.js +0 -113
- package/src/symbol/transform_text.js +0 -29
- package/src/types/callback.js +0 -17
- package/src/types/cancelable.js +0 -3
- package/src/types/tilejson.js +0 -17
- package/src/types/transferable.js +0 -3
- package/src/types/window.js +0 -172
- package/src/ui/anchor.js +0 -32
- package/src/ui/bind_handlers.js +0 -202
- package/src/ui/camera.js +0 -1152
- package/src/ui/control/attribution_control.js +0 -189
- package/src/ui/control/fps_control.js +0 -185
- package/src/ui/control/fullscreen_control.js +0 -147
- package/src/ui/control/geolocate_control.js +0 -594
- package/src/ui/control/logo_control.js +0 -92
- package/src/ui/control/navigation_control.js +0 -148
- package/src/ui/control/scale_control.js +0 -142
- package/src/ui/crs.js +0 -64
- package/src/ui/default_locale.js +0 -20
- package/src/ui/events.js +0 -806
- package/src/ui/handler/box_zoom.js +0 -175
- package/src/ui/handler/dblclick_zoom.js +0 -139
- package/src/ui/handler/drag_pan.js +0 -416
- package/src/ui/handler/drag_rotate.js +0 -378
- package/src/ui/handler/keyboard.js +0 -161
- package/src/ui/handler/scroll_zoom.js +0 -333
- package/src/ui/handler/touch_zoom_rotate.js +0 -293
- package/src/ui/hash.js +0 -147
- package/src/ui/map.js +0 -2883
- package/src/ui/marker.js +0 -607
- package/src/ui/offline_map.js +0 -91
- package/src/ui/popup.js +0 -530
- package/src/util/actor.js +0 -212
- package/src/util/ajax.js +0 -371
- package/src/util/browser/web_worker.js +0 -10
- package/src/util/browser/window.js +0 -5
- package/src/util/browser.js +0 -70
- package/src/util/classify_rings.js +0 -52
- package/src/util/color_ramp.js +0 -28
- package/src/util/config.js +0 -30
- package/src/util/debug.js +0 -12
- package/src/util/dictionary_coder.js +0 -30
- package/src/util/dispatcher.js +0 -70
- package/src/util/dom.js +0 -144
- package/src/util/evented.js +0 -174
- package/src/util/find_pole_of_inaccessibility.js +0 -129
- package/src/util/global_worker_pool.js +0 -17
- package/src/util/image.js +0 -142
- package/src/util/intersection_tests.js +0 -208
- package/src/util/is_char_in_unicode_block.js +0 -311
- package/src/util/mapbox.js +0 -486
- package/src/util/offscreen_canvas_supported.js +0 -14
- package/src/util/performance.js +0 -112
- package/src/util/primitives.js +0 -145
- package/src/util/resolve_tokens.js +0 -16
- package/src/util/script_detection.js +0 -328
- package/src/util/sku_token.js +0 -42
- package/src/util/smart_wrap.js +0 -55
- package/src/util/struct_array.js +0 -243
- package/src/util/struct_array.js.ejs +0 -112
- package/src/util/struct_array_layout.js.ejs +0 -98
- package/src/util/task_queue.js +0 -68
- package/src/util/throttle.js +0 -28
- package/src/util/throttled_invoker.js +0 -46
- package/src/util/tile_cover.js +0 -101
- package/src/util/tile_request_cache.js +0 -172
- package/src/util/util.js +0 -504
- package/src/util/vectortile_to_geojson.js +0 -54
- package/src/util/verticalize_punctuation.js +0 -114
- package/src/util/web_worker.js +0 -91
- package/src/util/web_worker_transfer.js +0 -266
- package/src/util/webp_supported.js +0 -69
- package/src/util/window.js +0 -102
- package/src/util/worker_pool.js +0 -47
|
@@ -1,972 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import {symbolLayoutAttributes,
|
|
4
|
-
collisionVertexAttributes,
|
|
5
|
-
collisionBoxLayout,
|
|
6
|
-
collisionCircleLayout,
|
|
7
|
-
dynamicLayoutAttributes
|
|
8
|
-
} from './symbol_attributes';
|
|
9
|
-
|
|
10
|
-
import {SymbolLayoutArray,
|
|
11
|
-
SymbolDynamicLayoutArray,
|
|
12
|
-
SymbolOpacityArray,
|
|
13
|
-
CollisionBoxLayoutArray,
|
|
14
|
-
CollisionCircleLayoutArray,
|
|
15
|
-
CollisionVertexArray,
|
|
16
|
-
PlacedSymbolArray,
|
|
17
|
-
SymbolInstanceArray,
|
|
18
|
-
GlyphOffsetArray,
|
|
19
|
-
SymbolLineVertexArray
|
|
20
|
-
} from '../array_types';
|
|
21
|
-
|
|
22
|
-
import Point from '@mapbox/point-geometry';
|
|
23
|
-
import SegmentVector from '../segment';
|
|
24
|
-
import {ProgramConfigurationSet} from '../program_configuration';
|
|
25
|
-
import {TriangleIndexArray, LineIndexArray} from '../index_array_type';
|
|
26
|
-
import transformText from '../../symbol/transform_text';
|
|
27
|
-
import mergeLines from '../../symbol/mergelines';
|
|
28
|
-
import {allowsVerticalWritingMode, stringContainsRTLText} from '../../util/script_detection';
|
|
29
|
-
import {WritingMode} from '../../symbol/shaping';
|
|
30
|
-
import loadGeometry from '../load_geometry';
|
|
31
|
-
import mvt from '@mapbox/vector-tile';
|
|
32
|
-
const vectorTileFeatureTypes = mvt.VectorTileFeature.types;
|
|
33
|
-
import {verticalizedCharacterMap} from '../../util/verticalize_punctuation';
|
|
34
|
-
import Anchor from '../../symbol/anchor';
|
|
35
|
-
import {getSizeData} from '../../symbol/symbol_size';
|
|
36
|
-
import {MAX_PACKED_SIZE} from '../../symbol/symbol_layout';
|
|
37
|
-
import {register} from '../../util/web_worker_transfer';
|
|
38
|
-
import EvaluationParameters from '../../style/evaluation_parameters';
|
|
39
|
-
import Formatted from '../../style-spec/expression/types/formatted';
|
|
40
|
-
import ResolvedImage from '../../style-spec/expression/types/resolved_image';
|
|
41
|
-
import {plugin as globalRTLTextPlugin, getRTLTextPluginStatus} from '../../source/rtl_text_plugin';
|
|
42
|
-
|
|
43
|
-
import type {CanonicalTileID} from '../../source/tile_id';
|
|
44
|
-
import type {
|
|
45
|
-
Bucket,
|
|
46
|
-
BucketParameters,
|
|
47
|
-
IndexedFeature,
|
|
48
|
-
PopulateParameters
|
|
49
|
-
} from '../bucket';
|
|
50
|
-
import type {CollisionBoxArray, CollisionBox, SymbolInstance} from '../array_types';
|
|
51
|
-
import type {StructArray, StructArrayMember} from '../../util/struct_array';
|
|
52
|
-
import SymbolStyleLayer from '../../style/style_layer/symbol_style_layer';
|
|
53
|
-
import type Context from '../../gl/context';
|
|
54
|
-
import type IndexBuffer from '../../gl/index_buffer';
|
|
55
|
-
import type VertexBuffer from '../../gl/vertex_buffer';
|
|
56
|
-
import type {SymbolQuad} from '../../symbol/quads';
|
|
57
|
-
import type {SizeData} from '../../symbol/symbol_size';
|
|
58
|
-
import type {FeatureStates} from '../../source/source_state';
|
|
59
|
-
import type {ImagePosition} from '../../render/image_atlas';
|
|
60
|
-
|
|
61
|
-
export type SingleCollisionBox = {
|
|
62
|
-
x1: number;
|
|
63
|
-
y1: number;
|
|
64
|
-
x2: number;
|
|
65
|
-
y2: number;
|
|
66
|
-
anchorPointX: number;
|
|
67
|
-
anchorPointY: number;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export type CollisionArrays = {
|
|
71
|
-
textBox?: SingleCollisionBox;
|
|
72
|
-
verticalTextBox?: SingleCollisionBox;
|
|
73
|
-
iconBox?: SingleCollisionBox;
|
|
74
|
-
verticalIconBox?: SingleCollisionBox;
|
|
75
|
-
textCircles?: Array<number>;
|
|
76
|
-
textFeatureIndex?: number;
|
|
77
|
-
verticalTextFeatureIndex?: number;
|
|
78
|
-
iconFeatureIndex?: number;
|
|
79
|
-
verticalIconFeatureIndex?: number;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export type SymbolFeature = {|
|
|
83
|
-
sortKey: number | void,
|
|
84
|
-
text: Formatted | void,
|
|
85
|
-
icon: ?ResolvedImage,
|
|
86
|
-
index: number,
|
|
87
|
-
sourceLayerIndex: number,
|
|
88
|
-
geometry: Array<Array<Point>>,
|
|
89
|
-
properties: Object,
|
|
90
|
-
type: 'Point' | 'LineString' | 'Polygon',
|
|
91
|
-
id?: any
|
|
92
|
-
|};
|
|
93
|
-
|
|
94
|
-
export type SortKeyRange = {
|
|
95
|
-
sortKey: number,
|
|
96
|
-
symbolInstanceStart: number,
|
|
97
|
-
symbolInstanceEnd: number
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
// Opacity arrays are frequently updated but don't contain a lot of information, so we pack them
|
|
101
|
-
// tight. Each Uint32 is actually four duplicate Uint8s for the four corners of a glyph
|
|
102
|
-
// 7 bits are for the current opacity, and the lowest bit is the target opacity
|
|
103
|
-
|
|
104
|
-
// actually defined in symbol_attributes.js
|
|
105
|
-
// const placementOpacityAttributes = [
|
|
106
|
-
// { name: 'a_fade_opacity', components: 1, type: 'Uint32' }
|
|
107
|
-
// ];
|
|
108
|
-
const shaderOpacityAttributes = [
|
|
109
|
-
{name: 'a_fade_opacity', components: 1, type: 'Uint8', offset: 0}
|
|
110
|
-
];
|
|
111
|
-
|
|
112
|
-
function addVertex(array, anchorX, anchorY, ox, oy, tx, ty, sizeVertex, isSDF: boolean, pixelOffsetX, pixelOffsetY, minFontScaleX, minFontScaleY) {
|
|
113
|
-
const aSizeX = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[0])) : 0;
|
|
114
|
-
const aSizeY = sizeVertex ? Math.min(MAX_PACKED_SIZE, Math.round(sizeVertex[1])) : 0;
|
|
115
|
-
array.emplaceBack(
|
|
116
|
-
// a_pos_offset
|
|
117
|
-
anchorX,
|
|
118
|
-
anchorY,
|
|
119
|
-
Math.round(ox * 32),
|
|
120
|
-
Math.round(oy * 32),
|
|
121
|
-
|
|
122
|
-
// a_data
|
|
123
|
-
tx, // x coordinate of symbol on glyph atlas texture
|
|
124
|
-
ty, // y coordinate of symbol on glyph atlas texture
|
|
125
|
-
(aSizeX << 1) + (isSDF ? 1 : 0),
|
|
126
|
-
aSizeY,
|
|
127
|
-
pixelOffsetX * 16,
|
|
128
|
-
pixelOffsetY * 16,
|
|
129
|
-
minFontScaleX * 256,
|
|
130
|
-
minFontScaleY * 256
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function addDynamicAttributes(dynamicLayoutVertexArray: StructArray, p: Point, angle: number) {
|
|
135
|
-
dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
|
|
136
|
-
dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
|
|
137
|
-
dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
|
|
138
|
-
dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function containsRTLText(formattedText: Formatted): boolean {
|
|
142
|
-
for (const section of formattedText.sections) {
|
|
143
|
-
if (stringContainsRTLText(section.text)) {
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export class SymbolBuffers {
|
|
151
|
-
layoutVertexArray: SymbolLayoutArray;
|
|
152
|
-
layoutVertexBuffer: VertexBuffer;
|
|
153
|
-
|
|
154
|
-
indexArray: TriangleIndexArray;
|
|
155
|
-
indexBuffer: IndexBuffer;
|
|
156
|
-
|
|
157
|
-
programConfigurations: ProgramConfigurationSet<SymbolStyleLayer>;
|
|
158
|
-
segments: SegmentVector;
|
|
159
|
-
|
|
160
|
-
dynamicLayoutVertexArray: SymbolDynamicLayoutArray;
|
|
161
|
-
dynamicLayoutVertexBuffer: VertexBuffer;
|
|
162
|
-
|
|
163
|
-
opacityVertexArray: SymbolOpacityArray;
|
|
164
|
-
opacityVertexBuffer: VertexBuffer;
|
|
165
|
-
|
|
166
|
-
collisionVertexArray: CollisionVertexArray;
|
|
167
|
-
collisionVertexBuffer: VertexBuffer;
|
|
168
|
-
|
|
169
|
-
placedSymbolArray: PlacedSymbolArray;
|
|
170
|
-
|
|
171
|
-
constructor(programConfigurations: ProgramConfigurationSet<SymbolStyleLayer>) {
|
|
172
|
-
this.layoutVertexArray = new SymbolLayoutArray();
|
|
173
|
-
this.indexArray = new TriangleIndexArray();
|
|
174
|
-
this.programConfigurations = programConfigurations;
|
|
175
|
-
this.segments = new SegmentVector();
|
|
176
|
-
this.dynamicLayoutVertexArray = new SymbolDynamicLayoutArray();
|
|
177
|
-
this.opacityVertexArray = new SymbolOpacityArray();
|
|
178
|
-
this.placedSymbolArray = new PlacedSymbolArray();
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
isEmpty() {
|
|
182
|
-
return this.layoutVertexArray.length === 0 &&
|
|
183
|
-
this.indexArray.length === 0 &&
|
|
184
|
-
this.dynamicLayoutVertexArray.length === 0 &&
|
|
185
|
-
this.opacityVertexArray.length === 0;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
upload(context: Context, dynamicIndexBuffer: boolean, upload?: boolean, update?: boolean) {
|
|
189
|
-
if (this.isEmpty()) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (upload) {
|
|
194
|
-
this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, symbolLayoutAttributes.members);
|
|
195
|
-
this.indexBuffer = context.createIndexBuffer(this.indexArray, dynamicIndexBuffer);
|
|
196
|
-
this.dynamicLayoutVertexBuffer = context.createVertexBuffer(this.dynamicLayoutVertexArray, dynamicLayoutAttributes.members, true);
|
|
197
|
-
this.opacityVertexBuffer = context.createVertexBuffer(this.opacityVertexArray, shaderOpacityAttributes, true);
|
|
198
|
-
// This is a performance hack so that we can write to opacityVertexArray with uint32s
|
|
199
|
-
// even though the shaders read uint8s
|
|
200
|
-
this.opacityVertexBuffer.itemSize = 1;
|
|
201
|
-
}
|
|
202
|
-
if (upload || update) {
|
|
203
|
-
this.programConfigurations.upload(context);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
destroy() {
|
|
208
|
-
if (!this.layoutVertexBuffer) return;
|
|
209
|
-
this.layoutVertexBuffer.destroy();
|
|
210
|
-
this.indexBuffer.destroy();
|
|
211
|
-
this.programConfigurations.destroy();
|
|
212
|
-
this.segments.destroy();
|
|
213
|
-
this.dynamicLayoutVertexBuffer.destroy();
|
|
214
|
-
this.opacityVertexBuffer.destroy();
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
register('SymbolBuffers', SymbolBuffers);
|
|
219
|
-
|
|
220
|
-
class CollisionBuffers {
|
|
221
|
-
layoutVertexArray: StructArray;
|
|
222
|
-
layoutAttributes: Array<StructArrayMember>;
|
|
223
|
-
layoutVertexBuffer: VertexBuffer;
|
|
224
|
-
|
|
225
|
-
indexArray: TriangleIndexArray | LineIndexArray;
|
|
226
|
-
indexBuffer: IndexBuffer;
|
|
227
|
-
|
|
228
|
-
segments: SegmentVector;
|
|
229
|
-
|
|
230
|
-
collisionVertexArray: CollisionVertexArray;
|
|
231
|
-
collisionVertexBuffer: VertexBuffer;
|
|
232
|
-
|
|
233
|
-
constructor(LayoutArray: Class<StructArray>,
|
|
234
|
-
layoutAttributes: Array<StructArrayMember>,
|
|
235
|
-
IndexArray: Class<TriangleIndexArray | LineIndexArray>) {
|
|
236
|
-
this.layoutVertexArray = new LayoutArray();
|
|
237
|
-
this.layoutAttributes = layoutAttributes;
|
|
238
|
-
this.indexArray = new IndexArray();
|
|
239
|
-
this.segments = new SegmentVector();
|
|
240
|
-
this.collisionVertexArray = new CollisionVertexArray();
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
upload(context: Context) {
|
|
244
|
-
this.layoutVertexBuffer = context.createVertexBuffer(this.layoutVertexArray, this.layoutAttributes);
|
|
245
|
-
this.indexBuffer = context.createIndexBuffer(this.indexArray);
|
|
246
|
-
this.collisionVertexBuffer = context.createVertexBuffer(this.collisionVertexArray, collisionVertexAttributes.members, true);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
destroy() {
|
|
250
|
-
if (!this.layoutVertexBuffer) return;
|
|
251
|
-
this.layoutVertexBuffer.destroy();
|
|
252
|
-
this.indexBuffer.destroy();
|
|
253
|
-
this.segments.destroy();
|
|
254
|
-
this.collisionVertexBuffer.destroy();
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
register('CollisionBuffers', CollisionBuffers);
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Unlike other buckets, which simply implement #addFeature with type-specific
|
|
262
|
-
* logic for (essentially) triangulating feature geometries, SymbolBucket
|
|
263
|
-
* requires specialized behavior:
|
|
264
|
-
*
|
|
265
|
-
* 1. WorkerTile#parse(), the logical owner of the bucket creation process,
|
|
266
|
-
* calls SymbolBucket#populate(), which resolves text and icon tokens on
|
|
267
|
-
* each feature, adds each glyphs and symbols needed to the passed-in
|
|
268
|
-
* collections options.glyphDependencies and options.iconDependencies, and
|
|
269
|
-
* stores the feature data for use in subsequent step (this.features).
|
|
270
|
-
*
|
|
271
|
-
* 2. WorkerTile asynchronously requests from the main thread all of the glyphs
|
|
272
|
-
* and icons needed (by this bucket and any others). When glyphs and icons
|
|
273
|
-
* have been received, the WorkerTile creates a CollisionIndex and invokes:
|
|
274
|
-
*
|
|
275
|
-
* 3. performSymbolLayout(bucket, stacks, icons) perform texts shaping and
|
|
276
|
-
* layout on a Symbol Bucket. This step populates:
|
|
277
|
-
* `this.symbolInstances`: metadata on generated symbols
|
|
278
|
-
* `this.collisionBoxArray`: collision data for use by foreground
|
|
279
|
-
* `this.text`: SymbolBuffers for text symbols
|
|
280
|
-
* `this.icons`: SymbolBuffers for icons
|
|
281
|
-
* `this.iconCollisionBox`: Debug SymbolBuffers for icon collision boxes
|
|
282
|
-
* `this.textCollisionBox`: Debug SymbolBuffers for text collision boxes
|
|
283
|
-
* `this.iconCollisionCircle`: Debug SymbolBuffers for icon collision circles
|
|
284
|
-
* `this.textCollisionCircle`: Debug SymbolBuffers for text collision circles
|
|
285
|
-
* The results are sent to the foreground for rendering
|
|
286
|
-
*
|
|
287
|
-
* 4. performSymbolPlacement(bucket, collisionIndex) is run on the foreground,
|
|
288
|
-
* and uses the CollisionIndex along with current camera settings to determine
|
|
289
|
-
* which symbols can actually show on the map. Collided symbols are hidden
|
|
290
|
-
* using a dynamic "OpacityVertexArray".
|
|
291
|
-
*
|
|
292
|
-
* @private
|
|
293
|
-
*/
|
|
294
|
-
class SymbolBucket implements Bucket {
|
|
295
|
-
static MAX_GLYPHS: number;
|
|
296
|
-
static addDynamicAttributes: typeof addDynamicAttributes;
|
|
297
|
-
|
|
298
|
-
collisionBoxArray: CollisionBoxArray;
|
|
299
|
-
zoom: number;
|
|
300
|
-
overscaling: number;
|
|
301
|
-
layers: Array<SymbolStyleLayer>;
|
|
302
|
-
layerIds: Array<string>;
|
|
303
|
-
stateDependentLayers: Array<SymbolStyleLayer>;
|
|
304
|
-
stateDependentLayerIds: Array<string>;
|
|
305
|
-
|
|
306
|
-
index: number;
|
|
307
|
-
sdfIcons: boolean;
|
|
308
|
-
iconsInText: boolean;
|
|
309
|
-
iconsNeedLinear: boolean;
|
|
310
|
-
bucketInstanceId: number;
|
|
311
|
-
justReloaded: boolean;
|
|
312
|
-
hasPattern: boolean;
|
|
313
|
-
|
|
314
|
-
textSizeData: SizeData;
|
|
315
|
-
iconSizeData: SizeData;
|
|
316
|
-
|
|
317
|
-
glyphOffsetArray: GlyphOffsetArray;
|
|
318
|
-
lineVertexArray: SymbolLineVertexArray;
|
|
319
|
-
features: Array<SymbolFeature>;
|
|
320
|
-
symbolInstances: SymbolInstanceArray;
|
|
321
|
-
collisionArrays: Array<CollisionArrays>;
|
|
322
|
-
sortKeyRanges: Array<SortKeyRange>;
|
|
323
|
-
pixelRatio: number;
|
|
324
|
-
tilePixelRatio: number;
|
|
325
|
-
compareText: {[_: string]: Array<Point>};
|
|
326
|
-
fadeStartTime: number;
|
|
327
|
-
sortFeaturesByKey: boolean;
|
|
328
|
-
sortFeaturesByY: boolean;
|
|
329
|
-
sortedAngle: number;
|
|
330
|
-
featureSortOrder: Array<number>;
|
|
331
|
-
|
|
332
|
-
text: SymbolBuffers;
|
|
333
|
-
icon: SymbolBuffers;
|
|
334
|
-
textCollisionBox: CollisionBuffers;
|
|
335
|
-
iconCollisionBox: CollisionBuffers;
|
|
336
|
-
textCollisionCircle: CollisionBuffers;
|
|
337
|
-
iconCollisionCircle: CollisionBuffers;
|
|
338
|
-
uploaded: boolean;
|
|
339
|
-
sourceLayerIndex: number;
|
|
340
|
-
sourceID: string;
|
|
341
|
-
symbolInstanceIndexes: Array<number>;
|
|
342
|
-
writingModes: Array<number>;
|
|
343
|
-
allowVerticalPlacement: boolean;
|
|
344
|
-
hasRTLText: boolean;
|
|
345
|
-
|
|
346
|
-
constructor(options: BucketParameters<SymbolStyleLayer>) {
|
|
347
|
-
this.collisionBoxArray = options.collisionBoxArray;
|
|
348
|
-
this.zoom = options.zoom;
|
|
349
|
-
this.overscaling = options.overscaling;
|
|
350
|
-
this.layers = options.layers;
|
|
351
|
-
this.layerIds = this.layers.map(layer => layer.id);
|
|
352
|
-
this.index = options.index;
|
|
353
|
-
this.pixelRatio = options.pixelRatio;
|
|
354
|
-
this.sourceLayerIndex = options.sourceLayerIndex;
|
|
355
|
-
this.hasPattern = false;
|
|
356
|
-
this.hasRTLText = false;
|
|
357
|
-
this.sortKeyRanges = [];
|
|
358
|
-
|
|
359
|
-
const layer = this.layers[0];
|
|
360
|
-
const unevaluatedLayoutValues = layer._unevaluatedLayout._values;
|
|
361
|
-
|
|
362
|
-
this.textSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['text-size']);
|
|
363
|
-
this.iconSizeData = getSizeData(this.zoom, unevaluatedLayoutValues['icon-size']);
|
|
364
|
-
|
|
365
|
-
const layout = this.layers[0].layout;
|
|
366
|
-
const sortKey = layout.get('symbol-sort-key');
|
|
367
|
-
const zOrder = layout.get('symbol-z-order');
|
|
368
|
-
this.sortFeaturesByKey = zOrder !== 'viewport-y' && sortKey.constantOr(1) !== undefined;
|
|
369
|
-
const zOrderByViewportY = zOrder === 'viewport-y' || (zOrder === 'auto' && !this.sortFeaturesByKey);
|
|
370
|
-
this.sortFeaturesByY = zOrderByViewportY && (layout.get('text-allow-overlap') || layout.get('icon-allow-overlap') ||
|
|
371
|
-
layout.get('text-ignore-placement') || layout.get('icon-ignore-placement'));
|
|
372
|
-
|
|
373
|
-
if (layout.get('symbol-placement') === 'point') {
|
|
374
|
-
this.writingModes = layout.get('text-writing-mode').map(wm => WritingMode[wm]);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);
|
|
378
|
-
|
|
379
|
-
this.sourceID = options.sourceID;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
createArrays() {
|
|
383
|
-
this.text = new SymbolBuffers(new ProgramConfigurationSet(symbolLayoutAttributes.members, this.layers, this.zoom, property => /^text/.test(property)));
|
|
384
|
-
this.icon = new SymbolBuffers(new ProgramConfigurationSet(symbolLayoutAttributes.members, this.layers, this.zoom, property => /^icon/.test(property)));
|
|
385
|
-
|
|
386
|
-
this.glyphOffsetArray = new GlyphOffsetArray();
|
|
387
|
-
this.lineVertexArray = new SymbolLineVertexArray();
|
|
388
|
-
this.symbolInstances = new SymbolInstanceArray();
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
calculateGlyphDependencies(text: string, stack: {[_: number]: boolean}, textAlongLine: boolean, allowVerticalPlacement: boolean, doesAllowVerticalWritingMode: boolean) {
|
|
392
|
-
for (let i = 0; i < text.length; i++) {
|
|
393
|
-
stack[text.charCodeAt(i)] = true;
|
|
394
|
-
if ((textAlongLine || allowVerticalPlacement) && doesAllowVerticalWritingMode) {
|
|
395
|
-
const verticalChar = verticalizedCharacterMap[text.charAt(i)];
|
|
396
|
-
if (verticalChar) {
|
|
397
|
-
stack[verticalChar.charCodeAt(0)] = true;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
populate(features: Array<IndexedFeature>, options: PopulateParameters, canonical: CanonicalTileID) {
|
|
404
|
-
const layer = this.layers[0];
|
|
405
|
-
const layout = layer.layout;
|
|
406
|
-
|
|
407
|
-
const textFont = layout.get('text-font');
|
|
408
|
-
const textField = layout.get('text-field');
|
|
409
|
-
const iconImage = layout.get('icon-image');
|
|
410
|
-
const hasText =
|
|
411
|
-
(textField.value.kind !== 'constant' ||
|
|
412
|
-
(textField.value.value instanceof Formatted && !textField.value.value.isEmpty()) ||
|
|
413
|
-
textField.value.value.toString().length > 0) &&
|
|
414
|
-
(textFont.value.kind !== 'constant' || textFont.value.value.length > 0);
|
|
415
|
-
// we should always resolve the icon-image value if the property was defined in the style
|
|
416
|
-
// this allows us to fire the styleimagemissing event if image evaluation returns null
|
|
417
|
-
// the only way to distinguish between null returned from a coalesce statement with no valid images
|
|
418
|
-
// and null returned because icon-image wasn't defined is to check whether or not iconImage.parameters is an empty object
|
|
419
|
-
const hasIcon = iconImage.value.kind !== 'constant' || !!iconImage.value.value || Object.keys(iconImage.parameters).length > 0;
|
|
420
|
-
const symbolSortKey = layout.get('symbol-sort-key');
|
|
421
|
-
|
|
422
|
-
this.features = [];
|
|
423
|
-
|
|
424
|
-
if (!hasText && !hasIcon) {
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
const icons = options.iconDependencies;
|
|
429
|
-
const stacks = options.glyphDependencies;
|
|
430
|
-
const availableImages = options.availableImages;
|
|
431
|
-
const globalProperties = new EvaluationParameters(this.zoom);
|
|
432
|
-
|
|
433
|
-
for (const {feature, id, index, sourceLayerIndex} of features) {
|
|
434
|
-
|
|
435
|
-
const needGeometry = layer._featureFilter.needGeometry;
|
|
436
|
-
const evaluationFeature = {type: feature.type,
|
|
437
|
-
id,
|
|
438
|
-
properties: feature.properties,
|
|
439
|
-
geometry: needGeometry ? loadGeometry(feature) : []};
|
|
440
|
-
|
|
441
|
-
if (!layer._featureFilter.filter(globalProperties, evaluationFeature, canonical)) {
|
|
442
|
-
continue;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
if (!needGeometry) evaluationFeature.geometry = loadGeometry(feature);
|
|
446
|
-
|
|
447
|
-
let text: Formatted | void;
|
|
448
|
-
if (hasText) {
|
|
449
|
-
// Expression evaluation will automatically coerce to Formatted
|
|
450
|
-
// but plain string token evaluation skips that pathway so do the
|
|
451
|
-
// conversion here.
|
|
452
|
-
const resolvedTokens = layer.getValueAndResolveTokens('text-field', evaluationFeature, canonical, availableImages);
|
|
453
|
-
const formattedText = Formatted.factory(resolvedTokens);
|
|
454
|
-
if (containsRTLText(formattedText)) {
|
|
455
|
-
this.hasRTLText = true;
|
|
456
|
-
}
|
|
457
|
-
if (
|
|
458
|
-
!this.hasRTLText || // non-rtl text so can proceed safely
|
|
459
|
-
getRTLTextPluginStatus() === 'unavailable' || // We don't intend to lazy-load the rtl text plugin, so proceed with incorrect shaping
|
|
460
|
-
this.hasRTLText && globalRTLTextPlugin.isParsed() // Use the rtlText plugin to shape text
|
|
461
|
-
) {
|
|
462
|
-
text = transformText(formattedText, layer, evaluationFeature);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
let icon: ?ResolvedImage;
|
|
467
|
-
if (hasIcon) {
|
|
468
|
-
// Expression evaluation will automatically coerce to Image
|
|
469
|
-
// but plain string token evaluation skips that pathway so do the
|
|
470
|
-
// conversion here.
|
|
471
|
-
const resolvedTokens = layer.getValueAndResolveTokens('icon-image', evaluationFeature, canonical, availableImages);
|
|
472
|
-
if (resolvedTokens instanceof ResolvedImage) {
|
|
473
|
-
icon = resolvedTokens;
|
|
474
|
-
} else {
|
|
475
|
-
icon = ResolvedImage.fromString(resolvedTokens);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
if (!text && !icon) {
|
|
480
|
-
continue;
|
|
481
|
-
}
|
|
482
|
-
const sortKey = this.sortFeaturesByKey ?
|
|
483
|
-
symbolSortKey.evaluate(evaluationFeature, {}, canonical) :
|
|
484
|
-
undefined;
|
|
485
|
-
|
|
486
|
-
const symbolFeature: SymbolFeature = {
|
|
487
|
-
id,
|
|
488
|
-
text,
|
|
489
|
-
icon,
|
|
490
|
-
index,
|
|
491
|
-
sourceLayerIndex,
|
|
492
|
-
geometry: loadGeometry(feature),
|
|
493
|
-
properties: feature.properties,
|
|
494
|
-
type: vectorTileFeatureTypes[feature.type],
|
|
495
|
-
sortKey
|
|
496
|
-
};
|
|
497
|
-
this.features.push(symbolFeature);
|
|
498
|
-
|
|
499
|
-
if (icon) {
|
|
500
|
-
icons[icon.name] = true;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
if (text) {
|
|
504
|
-
const fontStack = textFont.evaluate(evaluationFeature, {}, canonical).join(',');
|
|
505
|
-
const textAlongLine = layout.get('text-rotation-alignment') === 'map' && layout.get('symbol-placement') !== 'point';
|
|
506
|
-
this.allowVerticalPlacement = this.writingModes && this.writingModes.indexOf(WritingMode.vertical) >= 0;
|
|
507
|
-
for (const section of text.sections) {
|
|
508
|
-
if (!section.image) {
|
|
509
|
-
const doesAllowVerticalWritingMode = allowsVerticalWritingMode(text.toString());
|
|
510
|
-
const sectionFont = section.fontStack || fontStack;
|
|
511
|
-
const sectionStack = stacks[sectionFont] = stacks[sectionFont] || {};
|
|
512
|
-
this.calculateGlyphDependencies(section.text, sectionStack, textAlongLine, this.allowVerticalPlacement, doesAllowVerticalWritingMode);
|
|
513
|
-
} else {
|
|
514
|
-
// Add section image to the list of dependencies.
|
|
515
|
-
icons[section.image.name] = true;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
if (layout.get('symbol-placement') === 'line') {
|
|
522
|
-
// Merge adjacent lines with the same text to improve labelling.
|
|
523
|
-
// It's better to place labels on one long line than on many short segments.
|
|
524
|
-
this.features = mergeLines(this.features);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
if (this.sortFeaturesByKey) {
|
|
528
|
-
this.features.sort((a, b) => {
|
|
529
|
-
// a.sortKey is always a number when sortFeaturesByKey is true
|
|
530
|
-
return ((a.sortKey: any): number) - ((b.sortKey: any): number);
|
|
531
|
-
});
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
update(states: FeatureStates, vtLayer: VectorTileLayer, imagePositions: {[_: string]: ImagePosition}) {
|
|
536
|
-
if (!this.stateDependentLayers.length) return;
|
|
537
|
-
this.text.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);
|
|
538
|
-
this.icon.programConfigurations.updatePaintArrays(states, vtLayer, this.layers, imagePositions);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
isEmpty() {
|
|
542
|
-
// When the bucket encounters only rtl-text but the plugin isnt loaded, no symbol instances will be created.
|
|
543
|
-
// In order for the bucket to be serialized, and not discarded as an empty bucket both checks are necessary.
|
|
544
|
-
return this.symbolInstances.length === 0 && !this.hasRTLText;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
uploadPending() {
|
|
548
|
-
return !this.uploaded || this.text.programConfigurations.needsUpload || this.icon.programConfigurations.needsUpload;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
upload(context: Context) {
|
|
552
|
-
if (!this.uploaded && this.hasDebugData()) {
|
|
553
|
-
this.textCollisionBox.upload(context);
|
|
554
|
-
this.iconCollisionBox.upload(context);
|
|
555
|
-
this.textCollisionCircle.upload(context);
|
|
556
|
-
this.iconCollisionCircle.upload(context);
|
|
557
|
-
}
|
|
558
|
-
this.text.upload(context, this.sortFeaturesByY, !this.uploaded, this.text.programConfigurations.needsUpload);
|
|
559
|
-
this.icon.upload(context, this.sortFeaturesByY, !this.uploaded, this.icon.programConfigurations.needsUpload);
|
|
560
|
-
this.uploaded = true;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
destroyDebugData() {
|
|
564
|
-
this.textCollisionBox.destroy();
|
|
565
|
-
this.iconCollisionBox.destroy();
|
|
566
|
-
this.textCollisionCircle.destroy();
|
|
567
|
-
this.iconCollisionCircle.destroy();
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
destroy() {
|
|
571
|
-
this.text.destroy();
|
|
572
|
-
this.icon.destroy();
|
|
573
|
-
|
|
574
|
-
if (this.hasDebugData()) {
|
|
575
|
-
this.destroyDebugData();
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
addToLineVertexArray(anchor: Anchor, line: any) {
|
|
580
|
-
const lineStartIndex = this.lineVertexArray.length;
|
|
581
|
-
if (anchor.segment !== undefined) {
|
|
582
|
-
let sumForwardLength = anchor.dist(line[anchor.segment + 1]);
|
|
583
|
-
let sumBackwardLength = anchor.dist(line[anchor.segment]);
|
|
584
|
-
const vertices = {};
|
|
585
|
-
for (let i = anchor.segment + 1; i < line.length; i++) {
|
|
586
|
-
vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumForwardLength};
|
|
587
|
-
if (i < line.length - 1) {
|
|
588
|
-
sumForwardLength += line[i + 1].dist(line[i]);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
for (let i = anchor.segment || 0; i >= 0; i--) {
|
|
592
|
-
vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumBackwardLength};
|
|
593
|
-
if (i > 0) {
|
|
594
|
-
sumBackwardLength += line[i - 1].dist(line[i]);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
for (let i = 0; i < line.length; i++) {
|
|
598
|
-
const vertex = vertices[i];
|
|
599
|
-
this.lineVertexArray.emplaceBack(vertex.x, vertex.y, vertex.tileUnitDistanceFromAnchor);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
return {
|
|
603
|
-
lineStartIndex,
|
|
604
|
-
lineLength: this.lineVertexArray.length - lineStartIndex
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
addSymbols(arrays: SymbolBuffers,
|
|
609
|
-
quads: Array<SymbolQuad>,
|
|
610
|
-
sizeVertex: any,
|
|
611
|
-
lineOffset: [number, number],
|
|
612
|
-
alongLine: boolean,
|
|
613
|
-
feature: SymbolFeature,
|
|
614
|
-
writingMode: any,
|
|
615
|
-
labelAnchor: Anchor,
|
|
616
|
-
lineStartIndex: number,
|
|
617
|
-
lineLength: number,
|
|
618
|
-
associatedIconIndex: number,
|
|
619
|
-
canonical: CanonicalTileID) {
|
|
620
|
-
const indexArray = arrays.indexArray;
|
|
621
|
-
const layoutVertexArray = arrays.layoutVertexArray;
|
|
622
|
-
|
|
623
|
-
const segment = arrays.segments.prepareSegment(4 * quads.length, layoutVertexArray, indexArray, feature.sortKey);
|
|
624
|
-
const glyphOffsetArrayStart = this.glyphOffsetArray.length;
|
|
625
|
-
const vertexStartIndex = segment.vertexLength;
|
|
626
|
-
|
|
627
|
-
const angle = (this.allowVerticalPlacement && writingMode === WritingMode.vertical) ? Math.PI / 2 : 0;
|
|
628
|
-
|
|
629
|
-
const sections = feature.text && feature.text.sections;
|
|
630
|
-
|
|
631
|
-
for (let i = 0; i < quads.length; i++) {
|
|
632
|
-
const {tl, tr, bl, br, tex, pixelOffsetTL, pixelOffsetBR, minFontScaleX, minFontScaleY, glyphOffset, isSDF, sectionIndex} = quads[i];
|
|
633
|
-
const index = segment.vertexLength;
|
|
634
|
-
|
|
635
|
-
const y = glyphOffset[1];
|
|
636
|
-
addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tl.x, y + tl.y, tex.x, tex.y, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY);
|
|
637
|
-
addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, tr.x, y + tr.y, tex.x + tex.w, tex.y, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetTL.y, minFontScaleX, minFontScaleY);
|
|
638
|
-
addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, bl.x, y + bl.y, tex.x, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetTL.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY);
|
|
639
|
-
addVertex(layoutVertexArray, labelAnchor.x, labelAnchor.y, br.x, y + br.y, tex.x + tex.w, tex.y + tex.h, sizeVertex, isSDF, pixelOffsetBR.x, pixelOffsetBR.y, minFontScaleX, minFontScaleY);
|
|
640
|
-
|
|
641
|
-
addDynamicAttributes(arrays.dynamicLayoutVertexArray, labelAnchor, angle);
|
|
642
|
-
|
|
643
|
-
indexArray.emplaceBack(index, index + 1, index + 2);
|
|
644
|
-
indexArray.emplaceBack(index + 1, index + 2, index + 3);
|
|
645
|
-
|
|
646
|
-
segment.vertexLength += 4;
|
|
647
|
-
segment.primitiveLength += 2;
|
|
648
|
-
|
|
649
|
-
this.glyphOffsetArray.emplaceBack(glyphOffset[0]);
|
|
650
|
-
|
|
651
|
-
if (i === quads.length - 1 || sectionIndex !== quads[i + 1].sectionIndex) {
|
|
652
|
-
arrays.programConfigurations.populatePaintArrays(layoutVertexArray.length, feature, feature.index, {}, canonical, sections && sections[sectionIndex]);
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
arrays.placedSymbolArray.emplaceBack(labelAnchor.x, labelAnchor.y,
|
|
657
|
-
glyphOffsetArrayStart, this.glyphOffsetArray.length - glyphOffsetArrayStart, vertexStartIndex,
|
|
658
|
-
lineStartIndex, lineLength, (labelAnchor.segment: any),
|
|
659
|
-
sizeVertex ? sizeVertex[0] : 0, sizeVertex ? sizeVertex[1] : 0,
|
|
660
|
-
lineOffset[0], lineOffset[1],
|
|
661
|
-
writingMode,
|
|
662
|
-
// placedOrientation is null initially; will be updated to horizontal(1)/vertical(2) if placed
|
|
663
|
-
0,
|
|
664
|
-
(false: any),
|
|
665
|
-
// The crossTileID is only filled/used on the foreground for dynamic text anchors
|
|
666
|
-
0,
|
|
667
|
-
associatedIconIndex
|
|
668
|
-
);
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
_addCollisionDebugVertex(layoutVertexArray: StructArray, collisionVertexArray: StructArray, point: Point, anchorX: number, anchorY: number, extrude: Point) {
|
|
672
|
-
collisionVertexArray.emplaceBack(0, 0);
|
|
673
|
-
return layoutVertexArray.emplaceBack(
|
|
674
|
-
// pos
|
|
675
|
-
point.x,
|
|
676
|
-
point.y,
|
|
677
|
-
// a_anchor_pos
|
|
678
|
-
anchorX,
|
|
679
|
-
anchorY,
|
|
680
|
-
// extrude
|
|
681
|
-
Math.round(extrude.x),
|
|
682
|
-
Math.round(extrude.y));
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
addCollisionDebugVertices(x1: number, y1: number, x2: number, y2: number, arrays: CollisionBuffers, boxAnchorPoint: Point, symbolInstance: SymbolInstance, isCircle: boolean) {
|
|
686
|
-
const segment = arrays.segments.prepareSegment(4, arrays.layoutVertexArray, arrays.indexArray);
|
|
687
|
-
const index = segment.vertexLength;
|
|
688
|
-
|
|
689
|
-
const layoutVertexArray = arrays.layoutVertexArray;
|
|
690
|
-
const collisionVertexArray = arrays.collisionVertexArray;
|
|
691
|
-
|
|
692
|
-
const anchorX = symbolInstance.anchorX;
|
|
693
|
-
const anchorY = symbolInstance.anchorY;
|
|
694
|
-
|
|
695
|
-
this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x1, y1));
|
|
696
|
-
this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x2, y1));
|
|
697
|
-
this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x2, y2));
|
|
698
|
-
this._addCollisionDebugVertex(layoutVertexArray, collisionVertexArray, boxAnchorPoint, anchorX, anchorY, new Point(x1, y2));
|
|
699
|
-
|
|
700
|
-
segment.vertexLength += 4;
|
|
701
|
-
if (isCircle) {
|
|
702
|
-
const indexArray: TriangleIndexArray = (arrays.indexArray: any);
|
|
703
|
-
indexArray.emplaceBack(index, index + 1, index + 2);
|
|
704
|
-
indexArray.emplaceBack(index, index + 2, index + 3);
|
|
705
|
-
|
|
706
|
-
segment.primitiveLength += 2;
|
|
707
|
-
} else {
|
|
708
|
-
const indexArray: LineIndexArray = (arrays.indexArray: any);
|
|
709
|
-
indexArray.emplaceBack(index, index + 1);
|
|
710
|
-
indexArray.emplaceBack(index + 1, index + 2);
|
|
711
|
-
indexArray.emplaceBack(index + 2, index + 3);
|
|
712
|
-
indexArray.emplaceBack(index + 3, index);
|
|
713
|
-
|
|
714
|
-
segment.primitiveLength += 4;
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
addDebugCollisionBoxes(startIndex: number, endIndex: number, symbolInstance: SymbolInstance, isText: boolean) {
|
|
719
|
-
for (let b = startIndex; b < endIndex; b++) {
|
|
720
|
-
const box: CollisionBox = (this.collisionBoxArray.get(b): any);
|
|
721
|
-
const x1 = box.x1;
|
|
722
|
-
const y1 = box.y1;
|
|
723
|
-
const x2 = box.x2;
|
|
724
|
-
const y2 = box.y2;
|
|
725
|
-
|
|
726
|
-
// If the radius > 0, this collision box is actually a circle
|
|
727
|
-
// The data we add to the buffers is exactly the same, but we'll render with a different shader.
|
|
728
|
-
const isCircle = box.radius > 0;
|
|
729
|
-
this.addCollisionDebugVertices(x1, y1, x2, y2, isCircle ?
|
|
730
|
-
(isText ? this.textCollisionCircle : this.iconCollisionCircle) : (isText ? this.textCollisionBox : this.iconCollisionBox),
|
|
731
|
-
box.anchorPoint, symbolInstance, isCircle);
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
generateCollisionDebugBuffers() {
|
|
736
|
-
if (this.hasDebugData()) {
|
|
737
|
-
this.destroyDebugData();
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
this.textCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray);
|
|
741
|
-
this.iconCollisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray);
|
|
742
|
-
this.textCollisionCircle = new CollisionBuffers(CollisionCircleLayoutArray, collisionCircleLayout.members, TriangleIndexArray);
|
|
743
|
-
this.iconCollisionCircle = new CollisionBuffers(CollisionCircleLayoutArray, collisionCircleLayout.members, TriangleIndexArray);
|
|
744
|
-
|
|
745
|
-
for (let i = 0; i < this.symbolInstances.length; i++) {
|
|
746
|
-
const symbolInstance = this.symbolInstances.get(i);
|
|
747
|
-
this.addDebugCollisionBoxes(symbolInstance.textBoxStartIndex, symbolInstance.textBoxEndIndex, symbolInstance, true);
|
|
748
|
-
this.addDebugCollisionBoxes(symbolInstance.verticalTextBoxStartIndex, symbolInstance.verticalTextBoxEndIndex, symbolInstance, true);
|
|
749
|
-
this.addDebugCollisionBoxes(symbolInstance.iconBoxStartIndex, symbolInstance.iconBoxEndIndex, symbolInstance, false);
|
|
750
|
-
this.addDebugCollisionBoxes(symbolInstance.verticalIconBoxStartIndex, symbolInstance.verticalIconBoxEndIndex, symbolInstance, false);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
// These flat arrays are meant to be quicker to iterate over than the source
|
|
755
|
-
// CollisionBoxArray
|
|
756
|
-
_deserializeCollisionBoxesForSymbol(collisionBoxArray: CollisionBoxArray,
|
|
757
|
-
textStartIndex: number, textEndIndex: number,
|
|
758
|
-
verticalTextStartIndex: number, verticalTextEndIndex: number,
|
|
759
|
-
iconStartIndex: number, iconEndIndex: number,
|
|
760
|
-
verticalIconStartIndex: number, verticalIconEndIndex: number): CollisionArrays {
|
|
761
|
-
|
|
762
|
-
const collisionArrays = {};
|
|
763
|
-
for (let k = textStartIndex; k < textEndIndex; k++) {
|
|
764
|
-
const box: CollisionBox = (collisionBoxArray.get(k): any);
|
|
765
|
-
if (box.radius === 0) {
|
|
766
|
-
collisionArrays.textBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};
|
|
767
|
-
collisionArrays.textFeatureIndex = box.featureIndex;
|
|
768
|
-
break; // Only one box allowed per instance
|
|
769
|
-
} else {
|
|
770
|
-
if (!collisionArrays.textCircles) {
|
|
771
|
-
collisionArrays.textCircles = [];
|
|
772
|
-
collisionArrays.textFeatureIndex = box.featureIndex;
|
|
773
|
-
}
|
|
774
|
-
const used = 1; // May be updated at collision detection time
|
|
775
|
-
collisionArrays.textCircles.push(box.anchorPointX, box.anchorPointY, box.radius, box.signedDistanceFromAnchor, used);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
for (let k = verticalTextStartIndex; k < verticalTextEndIndex; k++) {
|
|
779
|
-
const box: CollisionBox = (collisionBoxArray.get(k): any);
|
|
780
|
-
if (box.radius === 0) {
|
|
781
|
-
collisionArrays.verticalTextBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};
|
|
782
|
-
collisionArrays.verticalTextFeatureIndex = box.featureIndex;
|
|
783
|
-
break; // Only one box allowed per instance
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
for (let k = iconStartIndex; k < iconEndIndex; k++) {
|
|
787
|
-
// An icon can only have one box now, so this indexing is a bit vestigial...
|
|
788
|
-
const box: CollisionBox = (collisionBoxArray.get(k): any);
|
|
789
|
-
if (box.radius === 0) {
|
|
790
|
-
collisionArrays.iconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};
|
|
791
|
-
collisionArrays.iconFeatureIndex = box.featureIndex;
|
|
792
|
-
break; // Only one box allowed per instance
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
for (let k = verticalIconStartIndex; k < verticalIconEndIndex; k++) {
|
|
796
|
-
// An icon can only have one box now, so this indexing is a bit vestigial...
|
|
797
|
-
const box: CollisionBox = (collisionBoxArray.get(k): any);
|
|
798
|
-
if (box.radius === 0) {
|
|
799
|
-
collisionArrays.verticalIconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY};
|
|
800
|
-
collisionArrays.verticalIconFeatureIndex = box.featureIndex;
|
|
801
|
-
break; // Only one box allowed per instance
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
return collisionArrays;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
deserializeCollisionBoxes(collisionBoxArray: CollisionBoxArray) {
|
|
808
|
-
this.collisionArrays = [];
|
|
809
|
-
for (let i = 0; i < this.symbolInstances.length; i++) {
|
|
810
|
-
const symbolInstance = this.symbolInstances.get(i);
|
|
811
|
-
this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(
|
|
812
|
-
collisionBoxArray,
|
|
813
|
-
symbolInstance.textBoxStartIndex,
|
|
814
|
-
symbolInstance.textBoxEndIndex,
|
|
815
|
-
symbolInstance.verticalTextBoxStartIndex,
|
|
816
|
-
symbolInstance.verticalTextBoxEndIndex,
|
|
817
|
-
symbolInstance.iconBoxStartIndex,
|
|
818
|
-
symbolInstance.iconBoxEndIndex,
|
|
819
|
-
symbolInstance.verticalIconBoxStartIndex,
|
|
820
|
-
symbolInstance.verticalIconBoxEndIndex
|
|
821
|
-
));
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
hasTextData() {
|
|
826
|
-
return this.text.segments.get().length > 0;
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
hasIconData() {
|
|
830
|
-
return this.icon.segments.get().length > 0;
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
hasDebugData() {
|
|
834
|
-
return this.textCollisionBox && this.iconCollisionBox && this.textCollisionCircle && this.iconCollisionCircle;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
hasTextCollisionBoxData() {
|
|
838
|
-
return this.hasDebugData() && this.textCollisionBox.segments.get().length > 0;
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
hasIconCollisionBoxData() {
|
|
842
|
-
return this.hasDebugData() && this.iconCollisionBox.segments.get().length > 0;
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
hasTextCollisionCircleData() {
|
|
846
|
-
return this.hasDebugData() && this.textCollisionCircle.segments.get().length > 0;
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
hasIconCollisionCircleData() {
|
|
850
|
-
return this.hasDebugData() && this.iconCollisionCircle.segments.get().length > 0;
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
addIndicesForPlacedSymbol(iconOrText: SymbolBuffers, placedSymbolIndex: number) {
|
|
854
|
-
const placedSymbol = iconOrText.placedSymbolArray.get(placedSymbolIndex);
|
|
855
|
-
|
|
856
|
-
const endIndex = placedSymbol.vertexStartIndex + placedSymbol.numGlyphs * 4;
|
|
857
|
-
for (let vertexIndex = placedSymbol.vertexStartIndex; vertexIndex < endIndex; vertexIndex += 4) {
|
|
858
|
-
iconOrText.indexArray.emplaceBack(vertexIndex, vertexIndex + 1, vertexIndex + 2);
|
|
859
|
-
iconOrText.indexArray.emplaceBack(vertexIndex + 1, vertexIndex + 2, vertexIndex + 3);
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
getSortedSymbolIndexes(angle: number) {
|
|
864
|
-
if (this.sortedAngle === angle && this.symbolInstanceIndexes !== undefined) {
|
|
865
|
-
return this.symbolInstanceIndexes;
|
|
866
|
-
}
|
|
867
|
-
const sin = Math.sin(angle);
|
|
868
|
-
const cos = Math.cos(angle);
|
|
869
|
-
const rotatedYs = [];
|
|
870
|
-
const featureIndexes = [];
|
|
871
|
-
const result = [];
|
|
872
|
-
|
|
873
|
-
for (let i = 0; i < this.symbolInstances.length; ++i) {
|
|
874
|
-
result.push(i);
|
|
875
|
-
const symbolInstance = this.symbolInstances.get(i);
|
|
876
|
-
rotatedYs.push(Math.round(sin * symbolInstance.anchorX + cos * symbolInstance.anchorY) | 0);
|
|
877
|
-
featureIndexes.push(symbolInstance.featureIndex);
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
result.sort((aIndex, bIndex) => {
|
|
881
|
-
return (rotatedYs[aIndex] - rotatedYs[bIndex]) ||
|
|
882
|
-
(featureIndexes[bIndex] - featureIndexes[aIndex]);
|
|
883
|
-
});
|
|
884
|
-
|
|
885
|
-
return result;
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
addToSortKeyRanges(symbolInstanceIndex: number, sortKey: number) {
|
|
889
|
-
const last = this.sortKeyRanges[this.sortKeyRanges.length - 1];
|
|
890
|
-
if (last && last.sortKey === sortKey) {
|
|
891
|
-
last.symbolInstanceEnd = symbolInstanceIndex + 1;
|
|
892
|
-
} else {
|
|
893
|
-
this.sortKeyRanges.push({
|
|
894
|
-
sortKey,
|
|
895
|
-
symbolInstanceStart: symbolInstanceIndex,
|
|
896
|
-
symbolInstanceEnd: symbolInstanceIndex + 1
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
sortFeatures(angle: number) {
|
|
902
|
-
if (!this.sortFeaturesByY) return;
|
|
903
|
-
if (this.sortedAngle === angle) return;
|
|
904
|
-
|
|
905
|
-
// The current approach to sorting doesn't sort across segments so don't try.
|
|
906
|
-
// Sorting within segments separately seemed not to be worth the complexity.
|
|
907
|
-
if (this.text.segments.get().length > 1 || this.icon.segments.get().length > 1) return;
|
|
908
|
-
|
|
909
|
-
// If the symbols are allowed to overlap sort them by their vertical screen position.
|
|
910
|
-
// The index array buffer is rewritten to reference the (unchanged) vertices in the
|
|
911
|
-
// sorted order.
|
|
912
|
-
|
|
913
|
-
// To avoid sorting the actual symbolInstance array we sort an array of indexes.
|
|
914
|
-
this.symbolInstanceIndexes = this.getSortedSymbolIndexes(angle);
|
|
915
|
-
this.sortedAngle = angle;
|
|
916
|
-
|
|
917
|
-
this.text.indexArray.clear();
|
|
918
|
-
this.icon.indexArray.clear();
|
|
919
|
-
|
|
920
|
-
this.featureSortOrder = [];
|
|
921
|
-
|
|
922
|
-
for (const i of this.symbolInstanceIndexes) {
|
|
923
|
-
const symbolInstance = this.symbolInstances.get(i);
|
|
924
|
-
this.featureSortOrder.push(symbolInstance.featureIndex);
|
|
925
|
-
|
|
926
|
-
[
|
|
927
|
-
symbolInstance.rightJustifiedTextSymbolIndex,
|
|
928
|
-
symbolInstance.centerJustifiedTextSymbolIndex,
|
|
929
|
-
symbolInstance.leftJustifiedTextSymbolIndex
|
|
930
|
-
].forEach((index, i, array) => {
|
|
931
|
-
// Only add a given index the first time it shows up,
|
|
932
|
-
// to avoid duplicate opacity entries when multiple justifications
|
|
933
|
-
// share the same glyphs.
|
|
934
|
-
if (index >= 0 && array.indexOf(index) === i) {
|
|
935
|
-
this.addIndicesForPlacedSymbol(this.text, index);
|
|
936
|
-
}
|
|
937
|
-
});
|
|
938
|
-
|
|
939
|
-
if (symbolInstance.verticalPlacedTextSymbolIndex >= 0) {
|
|
940
|
-
this.addIndicesForPlacedSymbol(this.text, symbolInstance.verticalPlacedTextSymbolIndex);
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
if (symbolInstance.placedIconSymbolIndex >= 0) {
|
|
944
|
-
this.addIndicesForPlacedSymbol(this.icon, symbolInstance.placedIconSymbolIndex);
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
if (symbolInstance.verticalPlacedIconSymbolIndex >= 0) {
|
|
948
|
-
this.addIndicesForPlacedSymbol(this.icon, symbolInstance.verticalPlacedIconSymbolIndex);
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
if (this.text.indexBuffer) this.text.indexBuffer.updateData(this.text.indexArray);
|
|
953
|
-
if (this.icon.indexBuffer) this.icon.indexBuffer.updateData(this.icon.indexArray);
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
register('SymbolBucket', SymbolBucket, {
|
|
958
|
-
omit: ['layers', 'collisionBoxArray', 'features', 'compareText']
|
|
959
|
-
});
|
|
960
|
-
|
|
961
|
-
// this constant is based on the size of StructArray indexes used in a symbol
|
|
962
|
-
// bucket--namely, glyphOffsetArrayStart
|
|
963
|
-
// eg the max valid UInt16 is 65,535
|
|
964
|
-
// See https://github.com/mapbox/mapbox-gl-js/issues/2907 for motivation
|
|
965
|
-
// lineStartIndex and textBoxStartIndex could potentially be concerns
|
|
966
|
-
// but we expect there to be many fewer boxes/lines than glyphs
|
|
967
|
-
SymbolBucket.MAX_GLYPHS = 65535;
|
|
968
|
-
|
|
969
|
-
SymbolBucket.addDynamicAttributes = addDynamicAttributes;
|
|
970
|
-
|
|
971
|
-
export default SymbolBucket;
|
|
972
|
-
export {addDynamicAttributes};
|