@mapgis/mapbox-gl 1.9.12 → 16.0.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/.flowconfig +61 -0
- package/LICENSE.txt +84 -0
- package/README.md +30 -13
- package/build/banner.js +4 -0
- package/build/check-bundle-size.js +140 -0
- package/build/generate-access-token-script.js +11 -0
- package/build/generate-flow-typed-style-spec.js +188 -0
- package/build/generate-release-list.js +21 -0
- package/build/generate-struct-arrays.js +237 -0
- package/build/generate-style-code.js +159 -0
- package/build/mapbox-gl.js.flow +3 -0
- package/build/print-release-url.js +6 -0
- package/build/rollup_plugin_minify_style_spec.js +20 -0
- package/build/rollup_plugins.js +80 -0
- package/build/run-node +3 -0
- package/build/run-tap +8 -0
- package/build/test/build-tape.js +19 -0
- package/dist/mapbox-gl-csp-worker.js +2 -0
- package/dist/mapbox-gl-csp-worker.js.map +1 -0
- package/dist/mapbox-gl-csp.js +2 -0
- package/dist/mapbox-gl-csp.js.map +1 -0
- package/dist/mapbox-gl-dev.js +68798 -0
- package/dist/mapbox-gl-unminified.js +45076 -0
- package/dist/mapbox-gl-unminified.js.map +1 -0
- package/dist/mapbox-gl.js +4 -4
- package/dist/mapbox-gl.js.map +1 -0
- package/flow-typed/gl.js +5 -0
- package/flow-typed/jsdom.js +18 -0
- package/flow-typed/mapbox-gl-supported.js +9 -0
- package/flow-typed/mapbox-unitbezier.js +14 -0
- package/flow-typed/offscreen-canvas.js +9 -0
- package/flow-typed/pbf.js +25 -0
- package/flow-typed/point-geometry.js +44 -0
- package/flow-typed/potpack.js +12 -0
- package/flow-typed/sinon.js +28 -0
- package/flow-typed/vector-tile.js +41 -0
- package/package.json +171 -19
- package/src/css/mapbox-gl.css +798 -0
- package/src/css/svg/mapboxgl-ctrl-attrib.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-compass.svg +4 -0
- package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-geolocate.svg +5 -0
- package/src/css/svg/mapboxgl-ctrl-logo.svg +20 -0
- package/src/css/svg/mapboxgl-ctrl-shrink.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +3 -0
- package/src/data/array_types.js +1095 -0
- package/src/data/bucket/circle_attributes.js +9 -0
- package/src/data/bucket/circle_bucket.js +204 -0
- package/src/data/bucket/fill_attributes.js +9 -0
- package/src/data/bucket/fill_bucket.js +233 -0
- package/src/data/bucket/fill_extrusion_attributes.js +10 -0
- package/src/data/bucket/fill_extrusion_bucket.js +289 -0
- package/src/data/bucket/heatmap_bucket.js +17 -0
- package/src/data/bucket/line_attributes.js +10 -0
- package/src/data/bucket/line_bucket.js +556 -0
- package/src/data/bucket/pattern_attributes.js +10 -0
- package/src/data/bucket/pattern_bucket_features.js +60 -0
- package/src/data/bucket/symbol_attributes.js +117 -0
- package/src/data/bucket/symbol_bucket.js +972 -0
- package/src/data/bucket.js +123 -0
- package/src/data/dem_data.js +125 -0
- package/src/data/extent.js +18 -0
- package/src/data/feature_index.js +321 -0
- package/src/data/feature_position_map.js +125 -0
- package/src/data/index_array_type.js +16 -0
- package/src/data/load_geometry.js +48 -0
- package/src/data/pos_attributes.js +6 -0
- package/src/data/program_configuration.js +687 -0
- package/src/data/raster_bounds_attributes.js +7 -0
- package/src/data/segment.js +76 -0
- package/src/geo/edge_insets.js +102 -0
- package/src/geo/lng_lat.js +165 -0
- package/src/geo/lng_lat_bounds.js +267 -0
- package/src/geo/mercator_coordinate.js +153 -0
- package/src/geo/transform.js +864 -0
- package/src/gl/color_mode.js +34 -0
- package/src/gl/context.js +298 -0
- package/src/gl/cull_face_mode.js +26 -0
- package/src/gl/depth_mode.js +29 -0
- package/src/gl/framebuffer.js +44 -0
- package/src/gl/index_buffer.js +55 -0
- package/src/gl/stencil_mode.js +30 -0
- package/src/gl/types.js +84 -0
- package/src/gl/value.js +520 -0
- package/src/gl/vertex_buffer.js +119 -0
- package/src/index.js +201 -0
- package/src/render/draw_background.js +57 -0
- package/src/render/draw_circle.js +113 -0
- package/src/render/draw_collision_debug.js +49 -0
- package/src/render/draw_custom.js +49 -0
- package/src/render/draw_debug.js +127 -0
- package/src/render/draw_fill.js +126 -0
- package/src/render/draw_fill_extrusion.js +96 -0
- package/src/render/draw_heatmap.js +140 -0
- package/src/render/draw_hillshade.js +108 -0
- package/src/render/draw_line.js +98 -0
- package/src/render/draw_raster.js +125 -0
- package/src/render/draw_symbol.js +394 -0
- package/src/render/glyph_atlas.js +71 -0
- package/src/render/glyph_manager.js +182 -0
- package/src/render/image_atlas.js +149 -0
- package/src/render/image_manager.js +306 -0
- package/src/render/line_atlas.js +210 -0
- package/src/render/painter.js +653 -0
- package/src/render/program/background_program.js +103 -0
- package/src/render/program/circle_program.js +69 -0
- package/src/render/program/clipping_mask_program.js +20 -0
- package/src/render/program/collision_program.js +49 -0
- package/src/render/program/debug_program.js +35 -0
- package/src/render/program/fill_extrusion_program.js +122 -0
- package/src/render/program/fill_program.js +126 -0
- package/src/render/program/heatmap_program.js +83 -0
- package/src/render/program/hillshade_program.js +122 -0
- package/src/render/program/line_program.js +207 -0
- package/src/render/program/pattern.js +102 -0
- package/src/render/program/program_uniforms.js +42 -0
- package/src/render/program/raster_program.js +92 -0
- package/src/render/program/symbol_program.js +224 -0
- package/src/render/program.js +168 -0
- package/src/render/texture.js +122 -0
- package/src/render/uniform_binding.js +147 -0
- package/src/render/vertex_array_object.js +163 -0
- package/src/shaders/README.md +42 -0
- package/src/shaders/_prelude.fragment.glsl +17 -0
- package/src/shaders/_prelude.vertex.glsl +73 -0
- package/src/shaders/background.fragment.glsl +10 -0
- package/src/shaders/background.vertex.glsl +7 -0
- package/src/shaders/background_pattern.fragment.glsl +28 -0
- package/src/shaders/background_pattern.vertex.glsl +20 -0
- package/src/shaders/circle.fragment.glsl +39 -0
- package/src/shaders/circle.vertex.glsl +64 -0
- package/src/shaders/clipping_mask.fragment.glsl +3 -0
- package/src/shaders/clipping_mask.vertex.glsl +7 -0
- package/src/shaders/collision_box.fragment.glsl +21 -0
- package/src/shaders/collision_box.vertex.glsl +27 -0
- package/src/shaders/collision_circle.fragment.glsl +34 -0
- package/src/shaders/collision_circle.vertex.glsl +36 -0
- package/src/shaders/debug.fragment.glsl +9 -0
- package/src/shaders/debug.vertex.glsl +12 -0
- package/src/shaders/encode_attribute.js +17 -0
- package/src/shaders/fill.fragment.glsl +13 -0
- package/src/shaders/fill.vertex.glsl +13 -0
- package/src/shaders/fill_extrusion.fragment.glsl +9 -0
- package/src/shaders/fill_extrusion.vertex.glsl +66 -0
- package/src/shaders/fill_extrusion_pattern.fragment.glsl +45 -0
- package/src/shaders/fill_extrusion_pattern.vertex.glsl +79 -0
- package/src/shaders/fill_outline.fragment.glsl +17 -0
- package/src/shaders/fill_outline.vertex.glsl +17 -0
- package/src/shaders/fill_outline_pattern.fragment.glsl +43 -0
- package/src/shaders/fill_outline_pattern.vertex.glsl +44 -0
- package/src/shaders/fill_pattern.fragment.glsl +36 -0
- package/src/shaders/fill_pattern.vertex.glsl +39 -0
- package/src/shaders/heatmap.fragment.glsl +22 -0
- package/src/shaders/heatmap.vertex.glsl +54 -0
- package/src/shaders/heatmap_texture.fragment.glsl +14 -0
- package/src/shaders/heatmap_texture.vertex.glsl +11 -0
- package/src/shaders/hillshade.fragment.glsl +52 -0
- package/src/shaders/hillshade.vertex.glsl +11 -0
- package/src/shaders/hillshade_prepare.fragment.glsl +74 -0
- package/src/shaders/hillshade_prepare.vertex.glsl +15 -0
- package/src/shaders/index.js +20 -0
- package/src/shaders/line.fragment.glsl +30 -0
- package/src/shaders/line.vertex.glsl +85 -0
- package/src/shaders/line_gradient.fragment.glsl +34 -0
- package/src/shaders/line_gradient.vertex.glsl +87 -0
- package/src/shaders/line_pattern.fragment.glsl +74 -0
- package/src/shaders/line_pattern.vertex.glsl +99 -0
- package/src/shaders/line_sdf.fragment.glsl +45 -0
- package/src/shaders/line_sdf.vertex.glsl +98 -0
- package/src/shaders/raster.fragment.glsl +52 -0
- package/src/shaders/raster.vertex.glsl +21 -0
- package/src/shaders/shaders.js +180 -0
- package/src/shaders/symbol_icon.fragment.glsl +17 -0
- package/src/shaders/symbol_icon.vertex.glsl +94 -0
- package/src/shaders/symbol_sdf.fragment.glsl +52 -0
- package/src/shaders/symbol_sdf.vertex.glsl +115 -0
- package/src/shaders/symbol_text_and_icon.fragment.glsl +68 -0
- package/src/shaders/symbol_text_and_icon.vertex.glsl +116 -0
- package/src/source/canvas_source.js +238 -0
- package/src/source/geojson_helper.js +92 -0
- package/src/source/geojson_source.js +374 -0
- package/src/source/geojson_worker_source.js +357 -0
- package/src/source/geojson_wrapper.js +94 -0
- package/src/source/image_source.js +307 -0
- package/src/source/load_tilejson.js +39 -0
- package/src/source/mbtiles_source.js +115 -0
- package/src/source/offline_database.js +61 -0
- package/src/source/offline_database_root.js +62 -0
- package/src/source/pixels_to_tile_units.js +21 -0
- package/src/source/query_features.js +208 -0
- package/src/source/raster_dem_tile_source.js +138 -0
- package/src/source/raster_dem_tile_worker_source.js +62 -0
- package/src/source/raster_tile_offline_source.js +136 -0
- package/src/source/raster_tile_source.js +177 -0
- package/src/source/rtl_text_plugin.js +138 -0
- package/src/source/source.js +137 -0
- package/src/source/source_cache.js +957 -0
- package/src/source/source_state.js +159 -0
- package/src/source/tile.js +465 -0
- package/src/source/tile_bounds.js +38 -0
- package/src/source/tile_cache.js +212 -0
- package/src/source/tile_id.js +402 -0
- package/src/source/vector_tile_source.js +192 -0
- package/src/source/vector_tile_worker_source.js +216 -0
- package/src/source/video_source.js +203 -0
- package/src/source/worker.js +237 -0
- package/src/source/worker_source.js +106 -0
- package/src/source/worker_tile.js +224 -0
- package/src/style/create_style_layer.js +36 -0
- package/src/style/evaluation_parameters.js +62 -0
- package/src/style/light.js +130 -0
- package/src/style/load_glyph_range.js +38 -0
- package/src/style/load_sprite.js +67 -0
- package/src/style/parse_glyph_pbf.js +44 -0
- package/src/style/pauseable_placement.js +132 -0
- package/src/style/properties.js +753 -0
- package/src/style/query_utils.js +43 -0
- package/src/style/style.js +1361 -0
- package/src/style/style_glyph.js +17 -0
- package/src/style/style_image.js +137 -0
- package/src/style/style_layer/background_style_layer.js +21 -0
- package/src/style/style_layer/background_style_layer_properties.js +40 -0
- package/src/style/style_layer/circle_style_layer.js +98 -0
- package/src/style/style_layer/circle_style_layer_properties.js +63 -0
- package/src/style/style_layer/custom_style_layer.js +223 -0
- package/src/style/style_layer/fill_extrusion_style_layer.js +224 -0
- package/src/style/style_layer/fill_extrusion_style_layer_properties.js +50 -0
- package/src/style/style_layer/fill_style_layer.js +67 -0
- package/src/style/style_layer/fill_style_layer_properties.js +55 -0
- package/src/style/style_layer/heatmap_style_layer.js +69 -0
- package/src/style/style_layer/heatmap_style_layer_properties.js +44 -0
- package/src/style/style_layer/hillshade_style_layer.js +25 -0
- package/src/style/style_layer/hillshade_style_layer_properties.js +46 -0
- package/src/style/style_layer/layer_properties.js.ejs +69 -0
- package/src/style/style_layer/line_style_layer.js +151 -0
- package/src/style/style_layer/line_style_layer_properties.js +71 -0
- package/src/style/style_layer/raster_style_layer.js +21 -0
- package/src/style/style_layer/raster_style_layer_properties.js +50 -0
- package/src/style/style_layer/symbol_style_layer.js +190 -0
- package/src/style/style_layer/symbol_style_layer_properties.js +153 -0
- package/src/style/style_layer/typed_style_layer.js +17 -0
- package/src/style/style_layer.js +281 -0
- package/src/style/style_layer_index.js +80 -0
- package/src/style/validate_style.js +42 -0
- package/src/style/zoom_history.js +44 -0
- package/src/style-spec/.eslintrc +5 -0
- package/src/style-spec/CHANGELOG.md +438 -0
- package/src/style-spec/README.md +59 -0
- package/src/style-spec/bin/gl-style-composite +9 -0
- package/src/style-spec/bin/gl-style-format +22 -0
- package/src/style-spec/bin/gl-style-migrate +9 -0
- package/src/style-spec/bin/gl-style-validate +50 -0
- package/src/style-spec/composite.js +50 -0
- package/src/style-spec/declass.js +42 -0
- package/src/style-spec/deref.js +52 -0
- package/src/style-spec/diff.js +393 -0
- package/src/style-spec/dist/.gitkeep +0 -0
- package/src/style-spec/empty.js +29 -0
- package/src/style-spec/error/parsing_error.js +16 -0
- package/src/style-spec/error/validation_error.js +18 -0
- package/src/style-spec/expression/compound_expression.js +162 -0
- package/src/style-spec/expression/definitions/assertion.js +130 -0
- package/src/style-spec/expression/definitions/at.js +70 -0
- package/src/style-spec/expression/definitions/case.js +85 -0
- package/src/style-spec/expression/definitions/coalesce.js +93 -0
- package/src/style-spec/expression/definitions/coercion.js +133 -0
- package/src/style-spec/expression/definitions/collator.js +78 -0
- package/src/style-spec/expression/definitions/comparison.js +184 -0
- package/src/style-spec/expression/definitions/format.js +144 -0
- package/src/style-spec/expression/definitions/format_section_override.js +54 -0
- package/src/style-spec/expression/definitions/image.js +52 -0
- package/src/style-spec/expression/definitions/in.js +92 -0
- package/src/style-spec/expression/definitions/index.js +561 -0
- package/src/style-spec/expression/definitions/interpolate.js +267 -0
- package/src/style-spec/expression/definitions/length.js +61 -0
- package/src/style-spec/expression/definitions/let.js +72 -0
- package/src/style-spec/expression/definitions/literal.js +77 -0
- package/src/style-spec/expression/definitions/match.js +158 -0
- package/src/style-spec/expression/definitions/number_format.js +142 -0
- package/src/style-spec/expression/definitions/step.js +120 -0
- package/src/style-spec/expression/definitions/var.js +46 -0
- package/src/style-spec/expression/definitions/within.js +333 -0
- package/src/style-spec/expression/evaluation_context.js +59 -0
- package/src/style-spec/expression/expression.js +27 -0
- package/src/style-spec/expression/index.js +392 -0
- package/src/style-spec/expression/is_constant.js +59 -0
- package/src/style-spec/expression/parsing_context.js +233 -0
- package/src/style-spec/expression/parsing_error.js +13 -0
- package/src/style-spec/expression/runtime_error.js +17 -0
- package/src/style-spec/expression/scope.js +36 -0
- package/src/style-spec/expression/stops.js +39 -0
- package/src/style-spec/expression/types/collator.js +61 -0
- package/src/style-spec/expression/types/formatted.js +73 -0
- package/src/style-spec/expression/types/resolved_image.js +29 -0
- package/src/style-spec/expression/types.js +106 -0
- package/src/style-spec/expression/values.js +123 -0
- package/src/style-spec/feature_filter/README.md +55 -0
- package/src/style-spec/feature_filter/convert.js +208 -0
- package/src/style-spec/feature_filter/index.js +165 -0
- package/src/style-spec/format.js +51 -0
- package/src/style-spec/function/convert.js +254 -0
- package/src/style-spec/function/index.js +262 -0
- package/src/style-spec/group_by_layout.js +75 -0
- package/src/style-spec/migrate/expressions.js +39 -0
- package/src/style-spec/migrate/v8.js +203 -0
- package/src/style-spec/migrate/v9.js +26 -0
- package/src/style-spec/migrate.js +36 -0
- package/src/style-spec/package.json +41 -0
- package/src/style-spec/read_style.js +14 -0
- package/src/style-spec/reference/latest.js +3 -0
- package/src/style-spec/reference/v8.json +5808 -0
- package/src/style-spec/rollup.config.js +45 -0
- package/src/style-spec/style-spec.js +122 -0
- package/src/style-spec/types.js +438 -0
- package/src/style-spec/util/color.js +95 -0
- package/src/style-spec/util/color_spaces.js +139 -0
- package/src/style-spec/util/deep_equal.js +28 -0
- package/src/style-spec/util/extend.js +10 -0
- package/src/style-spec/util/get_type.js +17 -0
- package/src/style-spec/util/interpolate.js +22 -0
- package/src/style-spec/util/properties.js +15 -0
- package/src/style-spec/util/ref_properties.js +2 -0
- package/src/style-spec/util/result.js +19 -0
- package/src/style-spec/util/unbundle_jsonlint.js +24 -0
- package/src/style-spec/validate/latest.js +11 -0
- package/src/style-spec/validate/validate.js +75 -0
- package/src/style-spec/validate/validate_array.js +52 -0
- package/src/style-spec/validate/validate_boolean.js +15 -0
- package/src/style-spec/validate/validate_color.js +20 -0
- package/src/style-spec/validate/validate_constants.js +13 -0
- package/src/style-spec/validate/validate_enum.js +21 -0
- package/src/style-spec/validate/validate_expression.js +43 -0
- package/src/style-spec/validate/validate_filter.js +111 -0
- package/src/style-spec/validate/validate_formatted.js +11 -0
- package/src/style-spec/validate/validate_function.js +207 -0
- package/src/style-spec/validate/validate_glyphs_url.js +21 -0
- package/src/style-spec/validate/validate_image.js +11 -0
- package/src/style-spec/validate/validate_layer.js +134 -0
- package/src/style-spec/validate/validate_layout_property.js +6 -0
- package/src/style-spec/validate/validate_light.js +47 -0
- package/src/style-spec/validate/validate_number.js +29 -0
- package/src/style-spec/validate/validate_object.js +61 -0
- package/src/style-spec/validate/validate_paint_property.js +6 -0
- package/src/style-spec/validate/validate_property.js +64 -0
- package/src/style-spec/validate/validate_source.js +111 -0
- package/src/style-spec/validate/validate_string.js +15 -0
- package/src/style-spec/validate_mapbox_api_supported.js +171 -0
- package/src/style-spec/validate_style.js +39 -0
- package/src/style-spec/validate_style.min.js +78 -0
- package/src/style-spec/visit.js +77 -0
- package/src/symbol/anchor.js +26 -0
- package/src/symbol/check_max_angle.js +81 -0
- package/src/symbol/clip_line.js +71 -0
- package/src/symbol/collision_feature.js +217 -0
- package/src/symbol/collision_index.js +372 -0
- package/src/symbol/cross_tile_symbol_index.js +301 -0
- package/src/symbol/get_anchors.js +167 -0
- package/src/symbol/grid_index.js +335 -0
- package/src/symbol/mergelines.js +82 -0
- package/src/symbol/one_em.js +4 -0
- package/src/symbol/opacity_state.js +27 -0
- package/src/symbol/placement.js +1062 -0
- package/src/symbol/projection.js +450 -0
- package/src/symbol/quads.js +334 -0
- package/src/symbol/shaping.js +816 -0
- package/src/symbol/symbol_layout.js +772 -0
- package/src/symbol/symbol_size.js +113 -0
- package/src/symbol/transform_text.js +29 -0
- package/src/types/callback.js +17 -0
- package/src/types/cancelable.js +3 -0
- package/src/types/tilejson.js +17 -0
- package/src/types/transferable.js +3 -0
- package/src/types/window.js +172 -0
- package/src/ui/anchor.js +32 -0
- package/src/ui/bind_handlers.js +202 -0
- package/src/ui/camera.js +1152 -0
- package/src/ui/control/attribution_control.js +189 -0
- package/src/ui/control/fps_control.js +185 -0
- package/src/ui/control/fullscreen_control.js +147 -0
- package/src/ui/control/geolocate_control.js +594 -0
- package/src/ui/control/logo_control.js +92 -0
- package/src/ui/control/navigation_control.js +148 -0
- package/src/ui/control/scale_control.js +142 -0
- package/src/ui/crs.js +64 -0
- package/src/ui/default_locale.js +20 -0
- package/src/ui/events.js +806 -0
- package/src/ui/handler/box_zoom.js +175 -0
- package/src/ui/handler/dblclick_zoom.js +139 -0
- package/src/ui/handler/drag_pan.js +416 -0
- package/src/ui/handler/drag_rotate.js +378 -0
- package/src/ui/handler/keyboard.js +161 -0
- package/src/ui/handler/scroll_zoom.js +333 -0
- package/src/ui/handler/touch_zoom_rotate.js +293 -0
- package/src/ui/hash.js +147 -0
- package/src/ui/map.js +2883 -0
- package/src/ui/marker.js +607 -0
- package/src/ui/offline_map.js +91 -0
- package/src/ui/popup.js +530 -0
- package/src/util/actor.js +212 -0
- package/src/util/ajax.js +371 -0
- package/src/util/browser/web_worker.js +10 -0
- package/src/util/browser/window.js +5 -0
- package/src/util/browser.js +70 -0
- package/src/util/classify_rings.js +52 -0
- package/src/util/color_ramp.js +28 -0
- package/src/util/config.js +30 -0
- package/src/util/debug.js +12 -0
- package/src/util/dictionary_coder.js +30 -0
- package/src/util/dispatcher.js +70 -0
- package/src/util/dom.js +144 -0
- package/src/util/evented.js +174 -0
- package/src/util/find_pole_of_inaccessibility.js +129 -0
- package/src/util/global_worker_pool.js +17 -0
- package/src/util/image.js +142 -0
- package/src/util/intersection_tests.js +208 -0
- package/src/util/is_char_in_unicode_block.js +311 -0
- package/src/util/mapbox.js +486 -0
- package/src/util/offscreen_canvas_supported.js +14 -0
- package/src/util/performance.js +112 -0
- package/src/util/primitives.js +145 -0
- package/src/util/resolve_tokens.js +16 -0
- package/src/util/script_detection.js +328 -0
- package/src/util/sku_token.js +42 -0
- package/src/util/smart_wrap.js +55 -0
- package/src/util/struct_array.js +243 -0
- package/src/util/struct_array.js.ejs +112 -0
- package/src/util/struct_array_layout.js.ejs +98 -0
- package/src/util/task_queue.js +68 -0
- package/src/util/throttle.js +28 -0
- package/src/util/throttled_invoker.js +46 -0
- package/src/util/tile_cover.js +101 -0
- package/src/util/tile_request_cache.js +172 -0
- package/src/util/util.js +504 -0
- package/src/util/vectortile_to_geojson.js +54 -0
- package/src/util/verticalize_punctuation.js +114 -0
- package/src/util/web_worker.js +91 -0
- package/src/util/web_worker_transfer.js +266 -0
- package/src/util/webp_supported.js +69 -0
- package/src/util/window.js +102 -0
- package/src/util/worker_pool.js +47 -0
- package/postcss.config.js +0 -16
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import {clamp} from '../util/util';
|
|
4
|
+
|
|
5
|
+
import ImageSource from '../source/image_source';
|
|
6
|
+
import browser from '../util/browser';
|
|
7
|
+
import StencilMode from '../gl/stencil_mode';
|
|
8
|
+
import DepthMode from '../gl/depth_mode';
|
|
9
|
+
import CullFaceMode from '../gl/cull_face_mode';
|
|
10
|
+
import {rasterUniformValues} from './program/raster_program';
|
|
11
|
+
|
|
12
|
+
import type Painter from './painter';
|
|
13
|
+
import type SourceCache from '../source/source_cache';
|
|
14
|
+
import type RasterStyleLayer from '../style/style_layer/raster_style_layer';
|
|
15
|
+
import type {OverscaledTileID} from '../source/tile_id';
|
|
16
|
+
|
|
17
|
+
export default drawRaster;
|
|
18
|
+
|
|
19
|
+
function drawRaster(painter: Painter, sourceCache: SourceCache, layer: RasterStyleLayer, tileIDs: Array<OverscaledTileID>) {
|
|
20
|
+
if (painter.renderPass !== 'translucent') return;
|
|
21
|
+
if (layer.paint.get('raster-opacity') === 0) return;
|
|
22
|
+
if (!tileIDs.length) return;
|
|
23
|
+
|
|
24
|
+
const context = painter.context;
|
|
25
|
+
const gl = context.gl;
|
|
26
|
+
const source = sourceCache.getSource();
|
|
27
|
+
const program = painter.useProgram('raster');
|
|
28
|
+
|
|
29
|
+
const colorMode = painter.colorModeForRenderPass();
|
|
30
|
+
|
|
31
|
+
const [stencilModes, coords] = source instanceof ImageSource ? [{}, tileIDs] :
|
|
32
|
+
painter.stencilConfigForOverlap(tileIDs);
|
|
33
|
+
|
|
34
|
+
const minTileZ = coords[coords.length - 1].overscaledZ;
|
|
35
|
+
|
|
36
|
+
const align = !painter.options.moving;
|
|
37
|
+
for (const coord of coords) {
|
|
38
|
+
// Set the lower zoom level to sublayer 0, and higher zoom levels to higher sublayers
|
|
39
|
+
// Use gl.LESS to prevent double drawing in areas where tiles overlap.
|
|
40
|
+
const depthMode = painter.depthModeForSublayer(coord.overscaledZ - minTileZ,
|
|
41
|
+
layer.paint.get('raster-opacity') === 1 ? DepthMode.ReadWrite : DepthMode.ReadOnly, gl.LESS);
|
|
42
|
+
|
|
43
|
+
const tile = sourceCache.getTile(coord);
|
|
44
|
+
const posMatrix = painter.transform.calculatePosMatrix(coord.toUnwrapped(), align);
|
|
45
|
+
|
|
46
|
+
tile.registerFadeDuration(layer.paint.get('raster-fade-duration'));
|
|
47
|
+
|
|
48
|
+
const parentTile = sourceCache.findLoadedParent(coord, 0),
|
|
49
|
+
fade = getFadeValues(tile, parentTile, sourceCache, layer, painter.transform);
|
|
50
|
+
|
|
51
|
+
let parentScaleBy, parentTL;
|
|
52
|
+
|
|
53
|
+
const textureFilter = layer.paint.get('raster-resampling') === 'nearest' ? gl.NEAREST : gl.LINEAR;
|
|
54
|
+
|
|
55
|
+
context.activeTexture.set(gl.TEXTURE0);
|
|
56
|
+
tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);
|
|
57
|
+
|
|
58
|
+
context.activeTexture.set(gl.TEXTURE1);
|
|
59
|
+
|
|
60
|
+
if (parentTile) {
|
|
61
|
+
parentTile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);
|
|
62
|
+
parentScaleBy = Math.pow(2, parentTile.tileID.overscaledZ - tile.tileID.overscaledZ);
|
|
63
|
+
parentTL = [tile.tileID.canonical.x * parentScaleBy % 1, tile.tileID.canonical.y * parentScaleBy % 1];
|
|
64
|
+
|
|
65
|
+
} else {
|
|
66
|
+
tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const uniformValues = rasterUniformValues(posMatrix, parentTL || [0, 0], parentScaleBy || 1, fade, layer);
|
|
70
|
+
|
|
71
|
+
if (source instanceof ImageSource) {
|
|
72
|
+
program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.disabled,
|
|
73
|
+
uniformValues, layer.id, source.boundsBuffer,
|
|
74
|
+
painter.quadTriangleIndexBuffer, source.boundsSegments);
|
|
75
|
+
} else {
|
|
76
|
+
program.draw(context, gl.TRIANGLES, depthMode, stencilModes[coord.overscaledZ], colorMode, CullFaceMode.disabled,
|
|
77
|
+
uniformValues, layer.id, painter.rasterBoundsBuffer,
|
|
78
|
+
painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getFadeValues(tile, parentTile, sourceCache, layer, transform) {
|
|
84
|
+
const fadeDuration = layer.paint.get('raster-fade-duration');
|
|
85
|
+
|
|
86
|
+
if (fadeDuration > 0) {
|
|
87
|
+
const now = browser.now();
|
|
88
|
+
const sinceTile = (now - tile.timeAdded) / fadeDuration;
|
|
89
|
+
const sinceParent = parentTile ? (now - parentTile.timeAdded) / fadeDuration : -1;
|
|
90
|
+
|
|
91
|
+
const source = sourceCache.getSource();
|
|
92
|
+
const idealZ = transform.coveringZoomLevel({
|
|
93
|
+
tileSize: source.tileSize,
|
|
94
|
+
roundZoom: source.roundZoom
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// if no parent or parent is older, fade in; if parent is younger, fade out
|
|
98
|
+
const fadeIn = !parentTile || Math.abs(parentTile.tileID.overscaledZ - idealZ) > Math.abs(tile.tileID.overscaledZ - idealZ);
|
|
99
|
+
|
|
100
|
+
const childOpacity = (fadeIn && tile.refreshedUponExpiration) ? 1 : clamp(fadeIn ? sinceTile : 1 - sinceParent, 0, 1);
|
|
101
|
+
|
|
102
|
+
// we don't crossfade tiles that were just refreshed upon expiring:
|
|
103
|
+
// once they're old enough to pass the crossfading threshold
|
|
104
|
+
// (fadeDuration), unset the `refreshedUponExpiration` flag so we don't
|
|
105
|
+
// incorrectly fail to crossfade them when zooming
|
|
106
|
+
if (tile.refreshedUponExpiration && sinceTile >= 1) tile.refreshedUponExpiration = false;
|
|
107
|
+
|
|
108
|
+
if (parentTile) {
|
|
109
|
+
return {
|
|
110
|
+
opacity: 1,
|
|
111
|
+
mix: 1 - childOpacity
|
|
112
|
+
};
|
|
113
|
+
} else {
|
|
114
|
+
return {
|
|
115
|
+
opacity: childOpacity,
|
|
116
|
+
mix: 0
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
return {
|
|
121
|
+
opacity: 1,
|
|
122
|
+
mix: 0
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import Point from '@mapbox/point-geometry';
|
|
4
|
+
import drawCollisionDebug from './draw_collision_debug';
|
|
5
|
+
|
|
6
|
+
import SegmentVector from '../data/segment';
|
|
7
|
+
import pixelsToTileUnits from '../source/pixels_to_tile_units';
|
|
8
|
+
import * as symbolProjection from '../symbol/projection';
|
|
9
|
+
import * as symbolSize from '../symbol/symbol_size';
|
|
10
|
+
import {mat4} from 'gl-matrix';
|
|
11
|
+
const identityMat4 = mat4.identity(new Float32Array(16));
|
|
12
|
+
import StencilMode from '../gl/stencil_mode';
|
|
13
|
+
import DepthMode from '../gl/depth_mode';
|
|
14
|
+
import CullFaceMode from '../gl/cull_face_mode';
|
|
15
|
+
import {addDynamicAttributes} from '../data/bucket/symbol_bucket';
|
|
16
|
+
|
|
17
|
+
import {getAnchorAlignment, WritingMode} from '../symbol/shaping';
|
|
18
|
+
import ONE_EM from '../symbol/one_em';
|
|
19
|
+
import {evaluateVariableOffset} from '../symbol/symbol_layout';
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
symbolIconUniformValues,
|
|
23
|
+
symbolSDFUniformValues,
|
|
24
|
+
symbolTextAndIconUniformValues
|
|
25
|
+
} from './program/symbol_program';
|
|
26
|
+
|
|
27
|
+
import type Painter from './painter';
|
|
28
|
+
import type SourceCache from '../source/source_cache';
|
|
29
|
+
import type SymbolStyleLayer from '../style/style_layer/symbol_style_layer';
|
|
30
|
+
import type SymbolBucket, {SymbolBuffers} from '../data/bucket/symbol_bucket';
|
|
31
|
+
import type Texture from '../render/texture';
|
|
32
|
+
import type {OverscaledTileID} from '../source/tile_id';
|
|
33
|
+
import type {UniformValues} from './uniform_binding';
|
|
34
|
+
import type {SymbolSDFUniformsType} from '../render/program/symbol_program';
|
|
35
|
+
import type {CrossTileID, VariableOffset} from '../symbol/placement';
|
|
36
|
+
|
|
37
|
+
export default drawSymbols;
|
|
38
|
+
|
|
39
|
+
type SymbolTileRenderState = {
|
|
40
|
+
segments: SegmentVector,
|
|
41
|
+
sortKey: number,
|
|
42
|
+
state: {
|
|
43
|
+
program: any,
|
|
44
|
+
buffers: SymbolBuffers,
|
|
45
|
+
uniformValues: any,
|
|
46
|
+
atlasTexture: Texture,
|
|
47
|
+
atlasTextureIcon: Texture | null,
|
|
48
|
+
atlasInterpolation: any,
|
|
49
|
+
atlasInterpolationIcon: any,
|
|
50
|
+
isSDF: boolean,
|
|
51
|
+
hasHalo: boolean
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
function drawSymbols(painter: Painter, sourceCache: SourceCache, layer: SymbolStyleLayer, coords: Array<OverscaledTileID>, variableOffsets: {[_: CrossTileID]: VariableOffset}) {
|
|
56
|
+
if (painter.renderPass !== 'translucent') return;
|
|
57
|
+
|
|
58
|
+
// Disable the stencil test so that labels aren't clipped to tile boundaries.
|
|
59
|
+
const stencilMode = StencilMode.disabled;
|
|
60
|
+
const colorMode = painter.colorModeForRenderPass();
|
|
61
|
+
const variablePlacement = layer.layout.get('text-variable-anchor');
|
|
62
|
+
|
|
63
|
+
//Compute variable-offsets before painting since icons and text data positioning
|
|
64
|
+
//depend on each other in this case.
|
|
65
|
+
if (variablePlacement) {
|
|
66
|
+
updateVariableAnchors(coords, painter, layer, sourceCache,
|
|
67
|
+
layer.layout.get('text-rotation-alignment'),
|
|
68
|
+
layer.layout.get('text-pitch-alignment'),
|
|
69
|
+
variableOffsets
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (layer.paint.get('icon-opacity').constantOr(1) !== 0) {
|
|
74
|
+
drawLayerSymbols(painter, sourceCache, layer, coords, false,
|
|
75
|
+
layer.paint.get('icon-translate'),
|
|
76
|
+
layer.paint.get('icon-translate-anchor'),
|
|
77
|
+
layer.layout.get('icon-rotation-alignment'),
|
|
78
|
+
layer.layout.get('icon-pitch-alignment'),
|
|
79
|
+
layer.layout.get('icon-keep-upright'),
|
|
80
|
+
stencilMode, colorMode
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (layer.paint.get('text-opacity').constantOr(1) !== 0) {
|
|
85
|
+
drawLayerSymbols(painter, sourceCache, layer, coords, true,
|
|
86
|
+
layer.paint.get('text-translate'),
|
|
87
|
+
layer.paint.get('text-translate-anchor'),
|
|
88
|
+
layer.layout.get('text-rotation-alignment'),
|
|
89
|
+
layer.layout.get('text-pitch-alignment'),
|
|
90
|
+
layer.layout.get('text-keep-upright'),
|
|
91
|
+
stencilMode, colorMode
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (sourceCache.map.showCollisionBoxes) {
|
|
96
|
+
drawCollisionDebug(painter, sourceCache, layer, coords, layer.paint.get('text-translate'),
|
|
97
|
+
layer.paint.get('text-translate-anchor'), true);
|
|
98
|
+
drawCollisionDebug(painter, sourceCache, layer, coords, layer.paint.get('icon-translate'),
|
|
99
|
+
layer.paint.get('icon-translate-anchor'), false);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function calculateVariableRenderShift(anchor, width, height, textOffset, textBoxScale, renderTextSize): Point {
|
|
104
|
+
const {horizontalAlign, verticalAlign} = getAnchorAlignment(anchor);
|
|
105
|
+
const shiftX = -(horizontalAlign - 0.5) * width;
|
|
106
|
+
const shiftY = -(verticalAlign - 0.5) * height;
|
|
107
|
+
const variableOffset = evaluateVariableOffset(anchor, textOffset);
|
|
108
|
+
return new Point(
|
|
109
|
+
(shiftX / textBoxScale + variableOffset[0]) * renderTextSize,
|
|
110
|
+
(shiftY / textBoxScale + variableOffset[1]) * renderTextSize
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function updateVariableAnchors(coords, painter, layer, sourceCache, rotationAlignment, pitchAlignment, variableOffsets) {
|
|
115
|
+
const tr = painter.transform;
|
|
116
|
+
const rotateWithMap = rotationAlignment === 'map';
|
|
117
|
+
const pitchWithMap = pitchAlignment === 'map';
|
|
118
|
+
|
|
119
|
+
for (const coord of coords) {
|
|
120
|
+
const tile = sourceCache.getTile(coord);
|
|
121
|
+
const bucket: SymbolBucket = (tile.getBucket(layer): any);
|
|
122
|
+
if (!bucket || !bucket.text || !bucket.text.segments.get().length) continue;
|
|
123
|
+
|
|
124
|
+
const sizeData = bucket.textSizeData;
|
|
125
|
+
const size = symbolSize.evaluateSizeForZoom(sizeData, tr.zoom);
|
|
126
|
+
|
|
127
|
+
const pixelToTileScale = pixelsToTileUnits(tile, 1, painter.transform.zoom);
|
|
128
|
+
const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, pixelToTileScale);
|
|
129
|
+
const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' && bucket.hasIconData();
|
|
130
|
+
|
|
131
|
+
if (size) {
|
|
132
|
+
const tileScale = Math.pow(2, tr.zoom - tile.tileID.overscaledZ);
|
|
133
|
+
updateVariableAnchorsForBucket(bucket, rotateWithMap, pitchWithMap, variableOffsets, symbolSize,
|
|
134
|
+
tr, labelPlaneMatrix, coord.posMatrix, tileScale, size, updateTextFitIcon);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function updateVariableAnchorsForBucket(bucket, rotateWithMap, pitchWithMap, variableOffsets, symbolSize,
|
|
140
|
+
transform, labelPlaneMatrix, posMatrix, tileScale, size, updateTextFitIcon) {
|
|
141
|
+
const placedSymbols = bucket.text.placedSymbolArray;
|
|
142
|
+
const dynamicTextLayoutVertexArray = bucket.text.dynamicLayoutVertexArray;
|
|
143
|
+
const dynamicIconLayoutVertexArray = bucket.icon.dynamicLayoutVertexArray;
|
|
144
|
+
const placedTextShifts = {};
|
|
145
|
+
|
|
146
|
+
dynamicTextLayoutVertexArray.clear();
|
|
147
|
+
for (let s = 0; s < placedSymbols.length; s++) {
|
|
148
|
+
const symbol: any = placedSymbols.get(s);
|
|
149
|
+
const skipOrientation = bucket.allowVerticalPlacement && !symbol.placedOrientation;
|
|
150
|
+
const variableOffset = (!symbol.hidden && symbol.crossTileID && !skipOrientation) ? variableOffsets[symbol.crossTileID] : null;
|
|
151
|
+
|
|
152
|
+
if (!variableOffset) {
|
|
153
|
+
// These symbols are from a justification that is not being used, or a label that wasn't placed
|
|
154
|
+
// so we don't need to do the extra math to figure out what incremental shift to apply.
|
|
155
|
+
symbolProjection.hideGlyphs(symbol.numGlyphs, dynamicTextLayoutVertexArray);
|
|
156
|
+
} else {
|
|
157
|
+
const tileAnchor = new Point(symbol.anchorX, symbol.anchorY);
|
|
158
|
+
const projectedAnchor = symbolProjection.project(tileAnchor, pitchWithMap ? posMatrix : labelPlaneMatrix);
|
|
159
|
+
const perspectiveRatio = 0.5 + 0.5 * (transform.cameraToCenterDistance / projectedAnchor.signedDistanceFromCamera);
|
|
160
|
+
let renderTextSize = symbolSize.evaluateSizeForFeature(bucket.textSizeData, size, symbol) * perspectiveRatio / ONE_EM;
|
|
161
|
+
if (pitchWithMap) {
|
|
162
|
+
// Go from size in pixels to equivalent size in tile units
|
|
163
|
+
renderTextSize *= bucket.tilePixelRatio / tileScale;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const {width, height, anchor, textOffset, textBoxScale} = variableOffset;
|
|
167
|
+
|
|
168
|
+
const shift = calculateVariableRenderShift(
|
|
169
|
+
anchor, width, height, textOffset, textBoxScale, renderTextSize);
|
|
170
|
+
|
|
171
|
+
// Usual case is that we take the projected anchor and add the pixel-based shift
|
|
172
|
+
// calculated above. In the (somewhat weird) case of pitch-aligned text, we add an equivalent
|
|
173
|
+
// tile-unit based shift to the anchor before projecting to the label plane.
|
|
174
|
+
const shiftedAnchor = pitchWithMap ?
|
|
175
|
+
symbolProjection.project(tileAnchor.add(shift), labelPlaneMatrix).point :
|
|
176
|
+
projectedAnchor.point.add(rotateWithMap ?
|
|
177
|
+
shift.rotate(-transform.angle) :
|
|
178
|
+
shift);
|
|
179
|
+
|
|
180
|
+
const angle = (bucket.allowVerticalPlacement && symbol.placedOrientation === WritingMode.vertical) ? Math.PI / 2 : 0;
|
|
181
|
+
for (let g = 0; g < symbol.numGlyphs; g++) {
|
|
182
|
+
addDynamicAttributes(dynamicTextLayoutVertexArray, shiftedAnchor, angle);
|
|
183
|
+
}
|
|
184
|
+
//Only offset horizontal text icons
|
|
185
|
+
if (updateTextFitIcon && symbol.associatedIconIndex >= 0) {
|
|
186
|
+
placedTextShifts[symbol.associatedIconIndex] = {shiftedAnchor, angle};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (updateTextFitIcon) {
|
|
192
|
+
dynamicIconLayoutVertexArray.clear();
|
|
193
|
+
const placedIcons = bucket.icon.placedSymbolArray;
|
|
194
|
+
for (let i = 0; i < placedIcons.length; i++) {
|
|
195
|
+
const placedIcon = placedIcons.get(i);
|
|
196
|
+
if (placedIcon.hidden) {
|
|
197
|
+
symbolProjection.hideGlyphs(placedIcon.numGlyphs, dynamicIconLayoutVertexArray);
|
|
198
|
+
} else {
|
|
199
|
+
const shift = placedTextShifts[i];
|
|
200
|
+
if (!shift) {
|
|
201
|
+
symbolProjection.hideGlyphs(placedIcon.numGlyphs, dynamicIconLayoutVertexArray);
|
|
202
|
+
} else {
|
|
203
|
+
for (let g = 0; g < placedIcon.numGlyphs; g++) {
|
|
204
|
+
addDynamicAttributes(dynamicIconLayoutVertexArray, shift.shiftedAnchor, shift.angle);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
bucket.icon.dynamicLayoutVertexBuffer.updateData(dynamicIconLayoutVertexArray);
|
|
210
|
+
}
|
|
211
|
+
bucket.text.dynamicLayoutVertexBuffer.updateData(dynamicTextLayoutVertexArray);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function getSymbolProgramName(isSDF: boolean, isText: boolean, bucket: SymbolBucket) {
|
|
215
|
+
if (bucket.iconsInText && isText) {
|
|
216
|
+
return 'symbolTextAndIcon';
|
|
217
|
+
} else if (isSDF) {
|
|
218
|
+
return 'symbolSDF';
|
|
219
|
+
} else {
|
|
220
|
+
return 'symbolIcon';
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function drawLayerSymbols(painter, sourceCache, layer, coords, isText, translate, translateAnchor,
|
|
225
|
+
rotationAlignment, pitchAlignment, keepUpright, stencilMode, colorMode) {
|
|
226
|
+
|
|
227
|
+
const context = painter.context;
|
|
228
|
+
const gl = context.gl;
|
|
229
|
+
const tr = painter.transform;
|
|
230
|
+
|
|
231
|
+
const rotateWithMap = rotationAlignment === 'map';
|
|
232
|
+
const pitchWithMap = pitchAlignment === 'map';
|
|
233
|
+
const alongLine = rotateWithMap && layer.layout.get('symbol-placement') !== 'point';
|
|
234
|
+
// Line label rotation happens in `updateLineLabels`
|
|
235
|
+
// Pitched point labels are automatically rotated by the labelPlaneMatrix projection
|
|
236
|
+
// Unpitched point labels need to have their rotation applied after projection
|
|
237
|
+
const rotateInShader = rotateWithMap && !pitchWithMap && !alongLine;
|
|
238
|
+
|
|
239
|
+
const sortFeaturesByKey = layer.layout.get('symbol-sort-key').constantOr(1) !== undefined;
|
|
240
|
+
|
|
241
|
+
const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);
|
|
242
|
+
|
|
243
|
+
let program;
|
|
244
|
+
let size;
|
|
245
|
+
const variablePlacement = layer.layout.get('text-variable-anchor');
|
|
246
|
+
|
|
247
|
+
const tileRenderState: Array<SymbolTileRenderState> = [];
|
|
248
|
+
|
|
249
|
+
for (const coord of coords) {
|
|
250
|
+
const tile = sourceCache.getTile(coord);
|
|
251
|
+
const bucket: SymbolBucket = (tile.getBucket(layer): any);
|
|
252
|
+
if (!bucket) continue;
|
|
253
|
+
const buffers = isText ? bucket.text : bucket.icon;
|
|
254
|
+
if (!buffers || !buffers.segments.get().length) continue;
|
|
255
|
+
const programConfiguration = buffers.programConfigurations.get(layer.id);
|
|
256
|
+
|
|
257
|
+
const isSDF = isText || bucket.sdfIcons;
|
|
258
|
+
|
|
259
|
+
const sizeData = isText ? bucket.textSizeData : bucket.iconSizeData;
|
|
260
|
+
const transformed = pitchWithMap || tr.pitch !== 0;
|
|
261
|
+
|
|
262
|
+
if (!program) {
|
|
263
|
+
program = painter.useProgram(getSymbolProgramName(isSDF, isText, bucket), programConfiguration);
|
|
264
|
+
size = symbolSize.evaluateSizeForZoom(sizeData, tr.zoom);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
let texSize: [number, number];
|
|
268
|
+
let texSizeIcon: [number, number] = [0, 0];
|
|
269
|
+
let atlasTexture;
|
|
270
|
+
let atlasInterpolation;
|
|
271
|
+
let atlasTextureIcon = null;
|
|
272
|
+
let atlasInterpolationIcon;
|
|
273
|
+
if (isText) {
|
|
274
|
+
atlasTexture = tile.glyphAtlasTexture;
|
|
275
|
+
atlasInterpolation = gl.LINEAR;
|
|
276
|
+
texSize = tile.glyphAtlasTexture.size;
|
|
277
|
+
if (bucket.iconsInText) {
|
|
278
|
+
texSizeIcon = tile.imageAtlasTexture.size;
|
|
279
|
+
atlasTextureIcon = tile.imageAtlasTexture;
|
|
280
|
+
const zoomDependentSize = sizeData.kind === 'composite' || sizeData.kind === 'camera';
|
|
281
|
+
atlasInterpolationIcon = transformed || painter.options.rotating || painter.options.zooming || zoomDependentSize ? gl.LINEAR : gl.NEAREST;
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
const iconScaled = layer.layout.get('icon-size').constantOr(0) !== 1 || bucket.iconsNeedLinear;
|
|
285
|
+
atlasTexture = tile.imageAtlasTexture;
|
|
286
|
+
atlasInterpolation = isSDF || painter.options.rotating || painter.options.zooming || iconScaled || transformed ?
|
|
287
|
+
gl.LINEAR :
|
|
288
|
+
gl.NEAREST;
|
|
289
|
+
texSize = tile.imageAtlasTexture.size;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const s = pixelsToTileUnits(tile, 1, painter.transform.zoom);
|
|
293
|
+
const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s);
|
|
294
|
+
const glCoordMatrix = symbolProjection.getGlCoordMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s);
|
|
295
|
+
|
|
296
|
+
const hasVariableAnchors = variablePlacement && bucket.hasTextData();
|
|
297
|
+
const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' &&
|
|
298
|
+
hasVariableAnchors &&
|
|
299
|
+
bucket.hasIconData();
|
|
300
|
+
|
|
301
|
+
if (alongLine) {
|
|
302
|
+
symbolProjection.updateLineLabels(bucket, coord.posMatrix, painter, isText, labelPlaneMatrix, glCoordMatrix, pitchWithMap, keepUpright);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const matrix = painter.translatePosMatrix(coord.posMatrix, tile, translate, translateAnchor),
|
|
306
|
+
uLabelPlaneMatrix = (alongLine || (isText && variablePlacement) || updateTextFitIcon) ? identityMat4 : labelPlaneMatrix,
|
|
307
|
+
uglCoordMatrix = painter.translatePosMatrix(glCoordMatrix, tile, translate, translateAnchor, true);
|
|
308
|
+
|
|
309
|
+
const hasHalo = isSDF && layer.paint.get(isText ? 'text-halo-width' : 'icon-halo-width').constantOr(1) !== 0;
|
|
310
|
+
|
|
311
|
+
let uniformValues;
|
|
312
|
+
if (isSDF) {
|
|
313
|
+
if (!bucket.iconsInText) {
|
|
314
|
+
uniformValues = symbolSDFUniformValues(sizeData.kind,
|
|
315
|
+
size, rotateInShader, pitchWithMap, painter, matrix,
|
|
316
|
+
uLabelPlaneMatrix, uglCoordMatrix, isText, texSize, true);
|
|
317
|
+
} else {
|
|
318
|
+
uniformValues = symbolTextAndIconUniformValues(sizeData.kind,
|
|
319
|
+
size, rotateInShader, pitchWithMap, painter, matrix,
|
|
320
|
+
uLabelPlaneMatrix, uglCoordMatrix, texSize, texSizeIcon);
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
uniformValues = symbolIconUniformValues(sizeData.kind,
|
|
324
|
+
size, rotateInShader, pitchWithMap, painter, matrix,
|
|
325
|
+
uLabelPlaneMatrix, uglCoordMatrix, isText, texSize);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const state = {
|
|
329
|
+
program,
|
|
330
|
+
buffers,
|
|
331
|
+
uniformValues,
|
|
332
|
+
atlasTexture,
|
|
333
|
+
atlasTextureIcon,
|
|
334
|
+
atlasInterpolation,
|
|
335
|
+
atlasInterpolationIcon,
|
|
336
|
+
isSDF,
|
|
337
|
+
hasHalo
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
if (sortFeaturesByKey) {
|
|
341
|
+
const oldSegments = buffers.segments.get();
|
|
342
|
+
for (const segment of oldSegments) {
|
|
343
|
+
tileRenderState.push({
|
|
344
|
+
segments: new SegmentVector([segment]),
|
|
345
|
+
sortKey: ((segment.sortKey: any): number),
|
|
346
|
+
state
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
} else {
|
|
350
|
+
tileRenderState.push({
|
|
351
|
+
segments: buffers.segments,
|
|
352
|
+
sortKey: 0,
|
|
353
|
+
state
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (sortFeaturesByKey) {
|
|
359
|
+
tileRenderState.sort((a, b) => a.sortKey - b.sortKey);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
for (const segmentState of tileRenderState) {
|
|
363
|
+
const state = segmentState.state;
|
|
364
|
+
|
|
365
|
+
context.activeTexture.set(gl.TEXTURE0);
|
|
366
|
+
state.atlasTexture.bind(state.atlasInterpolation, gl.CLAMP_TO_EDGE);
|
|
367
|
+
if (state.atlasTextureIcon) {
|
|
368
|
+
context.activeTexture.set(gl.TEXTURE1);
|
|
369
|
+
if (state.atlasTextureIcon) {
|
|
370
|
+
state.atlasTextureIcon.bind(state.atlasInterpolationIcon, gl.CLAMP_TO_EDGE);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (state.isSDF) {
|
|
375
|
+
const uniformValues = ((state.uniformValues: any): UniformValues<SymbolSDFUniformsType>);
|
|
376
|
+
if (state.hasHalo) {
|
|
377
|
+
uniformValues['u_is_halo'] = 1;
|
|
378
|
+
drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, uniformValues);
|
|
379
|
+
}
|
|
380
|
+
uniformValues['u_is_halo'] = 0;
|
|
381
|
+
}
|
|
382
|
+
drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, state.uniformValues);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function drawSymbolElements(buffers, segments, layer, painter, program, depthMode, stencilMode, colorMode, uniformValues) {
|
|
387
|
+
const context = painter.context;
|
|
388
|
+
const gl = context.gl;
|
|
389
|
+
program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,
|
|
390
|
+
uniformValues, layer.id, buffers.layoutVertexBuffer,
|
|
391
|
+
buffers.indexBuffer, segments, layer.paint,
|
|
392
|
+
painter.transform.zoom, buffers.programConfigurations.get(layer.id),
|
|
393
|
+
buffers.dynamicLayoutVertexBuffer, buffers.opacityVertexBuffer);
|
|
394
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import {AlphaImage} from '../util/image';
|
|
4
|
+
import {register} from '../util/web_worker_transfer';
|
|
5
|
+
import potpack from 'potpack';
|
|
6
|
+
|
|
7
|
+
import type {GlyphMetrics, StyleGlyph} from '../style/style_glyph';
|
|
8
|
+
|
|
9
|
+
const padding = 1;
|
|
10
|
+
|
|
11
|
+
export type Rect = {
|
|
12
|
+
x: number,
|
|
13
|
+
y: number,
|
|
14
|
+
w: number,
|
|
15
|
+
h: number
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type GlyphPosition = {
|
|
19
|
+
rect: Rect,
|
|
20
|
+
metrics: GlyphMetrics
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type GlyphPositions = {[_: string]: {[_: number]: GlyphPosition } }
|
|
24
|
+
|
|
25
|
+
export default class GlyphAtlas {
|
|
26
|
+
image: AlphaImage;
|
|
27
|
+
positions: GlyphPositions;
|
|
28
|
+
|
|
29
|
+
constructor(stacks: {[_: string]: {[_: number]: ?StyleGlyph } }) {
|
|
30
|
+
const positions = {};
|
|
31
|
+
const bins = [];
|
|
32
|
+
|
|
33
|
+
for (const stack in stacks) {
|
|
34
|
+
const glyphs = stacks[stack];
|
|
35
|
+
const stackPositions = positions[stack] = {};
|
|
36
|
+
|
|
37
|
+
for (const id in glyphs) {
|
|
38
|
+
const src = glyphs[+id];
|
|
39
|
+
if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;
|
|
40
|
+
|
|
41
|
+
const bin = {
|
|
42
|
+
x: 0,
|
|
43
|
+
y: 0,
|
|
44
|
+
w: src.bitmap.width + 2 * padding,
|
|
45
|
+
h: src.bitmap.height + 2 * padding
|
|
46
|
+
};
|
|
47
|
+
bins.push(bin);
|
|
48
|
+
stackPositions[id] = {rect: bin, metrics: src.metrics};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const {w, h} = potpack(bins);
|
|
53
|
+
const image = new AlphaImage({width: w || 1, height: h || 1});
|
|
54
|
+
|
|
55
|
+
for (const stack in stacks) {
|
|
56
|
+
const glyphs = stacks[stack];
|
|
57
|
+
|
|
58
|
+
for (const id in glyphs) {
|
|
59
|
+
const src = glyphs[+id];
|
|
60
|
+
if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;
|
|
61
|
+
const bin = positions[stack][id].rect;
|
|
62
|
+
AlphaImage.copy(src.bitmap, image, {x: 0, y: 0}, {x: bin.x + padding, y: bin.y + padding}, src.bitmap);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
this.image = image;
|
|
67
|
+
this.positions = positions;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
register('GlyphAtlas', GlyphAtlas);
|