maplibre-gl 2.1.0 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/{banner.js → banner.ts} +1 -1
- package/build/generate-query-test-fixtures.ts +123 -0
- package/build/generate-shaders.ts +35 -0
- package/build/generate-struct-arrays.ts +7 -7
- package/build/generate-style-code.ts +8 -8
- package/build/generate-style-spec.ts +5 -4
- package/build/generate-typings.ts +16 -0
- package/build/readme.md +8 -18
- package/build/release-notes.js +9 -13
- package/build/{rollup_plugin_minify_style_spec.js → rollup_plugin_minify_style_spec.ts} +4 -3
- package/build/{rollup_plugins.js → rollup_plugins.ts} +12 -26
- package/dist/maplibre-gl-dev.js +54885 -0
- package/dist/maplibre-gl.css +1 -1
- package/dist/maplibre-gl.d.ts +1537 -1011
- package/dist/maplibre-gl.js +3 -3
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +83 -107
- package/postinstall.js +5 -0
- package/src/css/maplibre-gl.css +28 -28
- package/src/data/{array_types.ts → array_types.g.ts} +0 -0
- package/src/data/bucket/circle_bucket.ts +1 -1
- package/src/data/bucket/fill_bucket.test.ts +1 -1
- package/src/data/bucket/fill_bucket.ts +4 -4
- package/src/data/bucket/fill_extrusion_bucket.ts +1 -1
- package/src/data/bucket/line_bucket.test.ts +1 -1
- package/src/data/bucket/line_bucket.ts +6 -6
- package/src/data/bucket/symbol_bucket.test.ts +16 -16
- package/src/data/bucket/symbol_bucket.ts +53 -53
- package/src/data/bucket.ts +43 -43
- package/src/data/dem_data.ts +12 -12
- package/src/data/evaluation_feature.ts +10 -10
- package/src/data/feature_index.ts +37 -37
- package/src/data/feature_position_map.ts +5 -5
- package/src/data/index_array_type.ts +1 -1
- package/src/data/load_geometry.test.ts +1 -1
- package/src/data/program_configuration.ts +46 -46
- package/src/data/segment.ts +14 -14
- package/src/geo/edge_insets.ts +2 -2
- package/src/geo/lng_lat.ts +4 -4
- package/src/geo/lng_lat_bounds.ts +35 -35
- package/src/geo/mercator_coordinate.ts +5 -5
- package/src/geo/transform.test.ts +1 -1
- package/src/geo/transform.ts +14 -14
- package/src/gl/context.ts +3 -3
- package/src/gl/types.ts +19 -19
- package/src/gl/value.ts +6 -6
- package/src/gl/vertex_buffer.test.ts +1 -1
- package/src/index.ts +24 -9
- package/src/render/draw_circle.ts +8 -8
- package/src/render/draw_collision_debug.ts +5 -5
- package/src/render/draw_line.ts +4 -4
- package/src/render/draw_symbol.ts +21 -21
- package/src/render/glyph_atlas.ts +12 -12
- package/src/render/glyph_manager.test.ts +10 -21
- package/src/render/glyph_manager.ts +33 -32
- package/src/render/image_manager.ts +4 -4
- package/src/render/painter.ts +11 -11
- package/src/render/program/background_program.ts +29 -29
- package/src/render/program/circle_program.ts +10 -10
- package/src/render/program/clipping_mask_program.ts +1 -1
- package/src/render/program/collision_program.ts +9 -9
- package/src/render/program/debug_program.ts +4 -4
- package/src/render/program/fill_extrusion_program.ts +31 -31
- package/src/render/program/fill_program.ts +29 -29
- package/src/render/program/heatmap_program.ts +12 -12
- package/src/render/program/hillshade_program.ts +12 -12
- package/src/render/program/line_program.ts +38 -38
- package/src/render/program/pattern.ts +28 -28
- package/src/render/program/raster_program.ts +21 -21
- package/src/render/program/symbol_program.ts +96 -96
- package/src/render/program.ts +25 -25
- package/src/render/texture.ts +9 -9
- package/src/render/uniform_binding.ts +1 -1
- package/src/render/vertex_array_object.ts +13 -13
- package/src/shaders/_prelude.fragment.glsl.g.ts +2 -0
- package/src/shaders/_prelude.vertex.glsl.g.ts +2 -0
- package/src/shaders/background.fragment.glsl.g.ts +2 -0
- package/src/shaders/background.vertex.glsl.g.ts +2 -0
- package/src/shaders/background_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/background_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/circle.fragment.glsl.g.ts +2 -0
- package/src/shaders/circle.vertex.glsl.g.ts +2 -0
- package/src/shaders/clipping_mask.fragment.glsl.g.ts +2 -0
- package/src/shaders/clipping_mask.vertex.glsl.g.ts +2 -0
- package/src/shaders/collision_box.fragment.glsl.g.ts +2 -0
- package/src/shaders/collision_box.vertex.glsl.g.ts +2 -0
- package/src/shaders/collision_circle.fragment.glsl.g.ts +2 -0
- package/src/shaders/collision_circle.vertex.glsl.g.ts +2 -0
- package/src/shaders/debug.fragment.glsl.g.ts +2 -0
- package/src/shaders/debug.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_outline.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_outline.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_outline_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_outline_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/heatmap.fragment.glsl.g.ts +2 -0
- package/src/shaders/heatmap.vertex.glsl.g.ts +2 -0
- package/src/shaders/heatmap_texture.fragment.glsl.g.ts +2 -0
- package/src/shaders/heatmap_texture.vertex.glsl.g.ts +2 -0
- package/src/shaders/hillshade.fragment.glsl.g.ts +2 -0
- package/src/shaders/hillshade.vertex.glsl.g.ts +2 -0
- package/src/shaders/hillshade_prepare.fragment.glsl.g.ts +2 -0
- package/src/shaders/hillshade_prepare.vertex.glsl.g.ts +2 -0
- package/src/shaders/line.fragment.glsl.g.ts +2 -0
- package/src/shaders/line.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_gradient.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_gradient.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_sdf.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_sdf.vertex.glsl.g.ts +2 -0
- package/src/shaders/raster.fragment.glsl.g.ts +2 -0
- package/src/shaders/raster.vertex.glsl.g.ts +2 -0
- package/src/shaders/shaders.ts +52 -55
- package/src/shaders/symbol_icon.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_icon.vertex.glsl.g.ts +2 -0
- package/src/shaders/symbol_sdf.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_sdf.vertex.glsl.g.ts +2 -0
- package/src/shaders/symbol_text_and_icon.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_text_and_icon.vertex.glsl.g.ts +2 -0
- package/src/source/canvas_source.test.ts +11 -12
- package/src/source/canvas_source.ts +4 -4
- package/src/source/geojson_worker_source.ts +23 -23
- package/src/source/geojson_wrapper.ts +8 -8
- package/src/source/image_source.test.ts +2 -2
- package/src/source/image_source.ts +6 -6
- package/src/source/pixels_to_tile_units.ts +6 -6
- package/src/source/query_features.ts +20 -20
- package/src/source/raster_dem_tile_source.test.ts +2 -2
- package/src/source/raster_tile_source.test.ts +2 -2
- package/src/source/rtl_text_plugin.ts +10 -10
- package/src/source/source.ts +29 -29
- package/src/source/source_cache.test.ts +32 -0
- package/src/source/source_cache.ts +7 -5
- package/src/source/source_state.ts +1 -1
- package/src/source/tile.test.ts +3 -3
- package/src/source/tile.ts +15 -15
- package/src/source/tile_cache.test.ts +6 -4
- package/src/source/tile_cache.ts +6 -6
- package/src/source/tile_id.test.ts +0 -1
- package/src/source/vector_tile_source.test.ts +16 -5
- package/src/source/vector_tile_source.ts +2 -3
- package/src/source/vector_tile_worker_source.test.ts +4 -4
- package/src/source/vector_tile_worker_source.ts +5 -5
- package/src/source/worker.test.ts +1 -1
- package/src/source/worker.ts +22 -22
- package/src/source/worker_source.ts +56 -56
- package/src/source/worker_tile.ts +4 -4
- package/src/style/evaluation_parameters.ts +3 -3
- package/src/style/format_section_override.test.ts +1 -1
- package/src/style/light.ts +10 -10
- package/src/style/load_glyph_range.test.ts +3 -5
- package/src/style/load_glyph_range.ts +6 -6
- package/src/style/load_sprite.ts +4 -4
- package/src/style/pauseable_placement.ts +1 -1
- package/src/style/properties.ts +69 -69
- package/src/style/query_utils.ts +7 -7
- package/src/style/style.test.ts +22 -15
- package/src/style/style.ts +29 -29
- package/src/style/style_glyph.ts +8 -8
- package/src/style/style_image.ts +58 -58
- package/src/style/style_layer/background_style_layer.ts +2 -2
- package/src/style/style_layer/{background_style_layer_properties.ts → background_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/circle_style_layer.ts +10 -10
- package/src/style/style_layer/{circle_style_layer_properties.ts → circle_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/custom_style_layer.ts +17 -17
- package/src/style/style_layer/fill_extrusion_style_layer.ts +10 -10
- package/src/style/style_layer/{fill_extrusion_style_layer_properties.ts → fill_extrusion_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/fill_style_layer.ts +9 -9
- package/src/style/style_layer/{fill_style_layer_properties.ts → fill_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/heatmap_style_layer.ts +2 -2
- package/src/style/style_layer/{heatmap_style_layer_properties.ts → heatmap_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/hillshade_style_layer.ts +2 -2
- package/src/style/style_layer/{hillshade_style_layer_properties.ts → hillshade_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/line_style_layer.ts +9 -9
- package/src/style/style_layer/{line_style_layer_properties.ts → line_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/raster_style_layer.ts +2 -2
- package/src/style/style_layer/{raster_style_layer_properties.ts → raster_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/symbol_style_layer.ts +7 -7
- package/src/style/style_layer/{symbol_style_layer_properties.ts → symbol_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer.ts +10 -10
- package/src/style/style_layer_index.ts +3 -3
- package/src/style/validate_style.ts +15 -15
- package/src/style-spec/error/validation_error.ts +1 -1
- package/src/style-spec/expression/compound_expression.ts +3 -3
- package/src/style-spec/expression/definitions/format.ts +11 -11
- package/src/style-spec/expression/definitions/interpolate.ts +5 -5
- package/src/style-spec/expression/definitions/match.ts +2 -2
- package/src/style-spec/expression/definitions/number_format.ts +11 -11
- package/src/style-spec/expression/expression.ts +8 -8
- package/src/style-spec/expression/index.ts +97 -97
- package/src/style-spec/expression/parsing_context.ts +11 -11
- package/src/style-spec/expression/types/collator.ts +9 -9
- package/src/style-spec/expression/types/resolved_image.ts +2 -2
- package/src/style-spec/expression/types.ts +14 -14
- package/src/style-spec/expression/values.ts +1 -1
- package/src/style-spec/feature_filter/index.ts +66 -66
- package/src/style-spec/function/convert.ts +3 -3
- package/src/style-spec/style-spec.ts +44 -44
- package/src/style-spec/util/color_spaces.ts +8 -8
- package/src/style-spec/util/result.ts +4 -4
- package/src/style-spec/validate/validate_filter.ts +58 -58
- package/src/style-spec/validate/validate_source.ts +63 -63
- package/src/style-spec/visit.ts +11 -11
- package/src/symbol/collision_feature.test.ts +1 -1
- package/src/symbol/collision_feature.ts +10 -10
- package/src/symbol/collision_index.ts +26 -26
- package/src/symbol/cross_tile_symbol_index.ts +17 -17
- package/src/symbol/get_anchors.ts +16 -16
- package/src/symbol/grid_index.ts +7 -7
- package/src/symbol/placement.ts +72 -72
- package/src/symbol/projection.ts +30 -30
- package/src/symbol/quads.ts +30 -30
- package/src/symbol/shaping.ts +160 -160
- package/src/symbol/symbol_layout.ts +119 -119
- package/src/symbol/symbol_size.ts +29 -29
- package/src/symbol/symbol_style_layer.test.ts +1 -1
- package/src/types/cancelable.ts +1 -1
- package/src/types/tilejson.ts +13 -13
- package/src/ui/anchor.ts +1 -1
- package/src/ui/camera.test.ts +9 -9
- package/src/ui/camera.ts +18 -18
- package/src/ui/control/attribution_control.test.ts +51 -16
- package/src/ui/control/attribution_control.ts +35 -16
- package/src/ui/control/control.ts +40 -40
- package/src/ui/control/fullscreen_control.ts +1 -1
- package/src/ui/control/geolocate_control.test.ts +1 -1
- package/src/ui/control/geolocate_control.ts +102 -102
- package/src/ui/control/logo_control.test.ts +5 -4
- package/src/ui/control/navigation_control.ts +3 -3
- package/src/ui/control/scale_control.test.ts +2 -2
- package/src/ui/control/scale_control.ts +5 -5
- package/src/ui/events.ts +289 -200
- package/src/ui/handler/box_zoom.test.ts +1 -1
- package/src/ui/handler/box_zoom.ts +1 -1
- package/src/ui/handler/dblclick_zoom.test.ts +1 -1
- package/src/ui/handler/drag_pan.test.ts +1 -1
- package/src/ui/handler/drag_rotate.test.ts +1 -1
- package/src/ui/handler/keyboard.test.ts +1 -1
- package/src/ui/handler/keyboard.ts +51 -51
- package/src/ui/handler/map_event.test.ts +1 -1
- package/src/ui/handler/map_event.ts +1 -1
- package/src/ui/handler/mouse.ts +1 -1
- package/src/ui/handler/mouse_rotate.test.ts +1 -1
- package/src/ui/handler/scroll_zoom.test.ts +3 -2
- package/src/ui/handler/scroll_zoom.ts +9 -9
- package/src/ui/handler/shim/drag_pan.ts +4 -4
- package/src/ui/handler/shim/drag_rotate.ts +1 -1
- package/src/ui/handler/shim/touch_zoom_rotate.ts +1 -1
- package/src/ui/handler/tap_recognizer.ts +4 -4
- package/src/ui/handler/touch_pan.ts +2 -2
- package/src/ui/handler/touch_zoom_rotate.test.ts +1 -1
- package/src/ui/handler/touch_zoom_rotate.ts +1 -1
- package/src/ui/handler_inertia.ts +6 -6
- package/src/ui/handler_manager.ts +44 -44
- package/src/ui/map/isMoving.test.ts +1 -1
- package/src/ui/map/isRotating.test.ts +1 -1
- package/src/ui/map/isZooming.test.ts +1 -1
- package/src/ui/map.test.ts +26 -14
- package/src/ui/map.ts +107 -102
- package/src/ui/map_events.test.ts +1 -1
- package/src/ui/marker.test.ts +12 -12
- package/src/ui/marker.ts +37 -37
- package/src/ui/popup.test.ts +7 -7
- package/src/ui/popup.ts +9 -9
- package/src/util/actor.test.ts +41 -10
- package/src/util/actor.ts +8 -8
- package/src/util/ajax.test.ts +29 -21
- package/src/util/ajax.ts +51 -30
- package/src/util/browser.ts +1 -1
- package/src/util/classify_rings.test.ts +1 -1
- package/src/util/color_ramp.ts +5 -5
- package/src/util/config.ts +2 -2
- package/src/util/dispatcher.ts +1 -1
- package/src/util/dom.ts +2 -2
- package/src/util/evented.ts +1 -1
- package/src/util/find_pole_of_inaccessibility.ts +3 -3
- package/src/util/image.ts +5 -5
- package/src/util/performance.ts +7 -7
- package/src/util/request_manager.ts +4 -4
- package/src/util/resolve_tokens.ts +4 -4
- package/src/util/struct_array.test.ts +1 -1
- package/src/util/struct_array.ts +15 -15
- package/src/util/task_queue.ts +3 -3
- package/src/util/tile_request_cache.ts +3 -3
- package/src/util/transferable_grid_index.ts +4 -4
- package/src/util/util.ts +8 -8
- package/src/util/web_worker.ts +4 -68
- package/src/util/web_worker_transfer.test.ts +3 -0
- package/src/util/web_worker_transfer.ts +21 -17
- package/src/util/worker_pool.ts +1 -1
- package/build/.eslintrc +0 -21
- package/build/glsl_to_js.js +0 -12
- package/build/post-ts-build.js +0 -43
- package/build/release-notes.md.ejs +0 -8
- package/build/test/build-tape.js +0 -17
- package/build/web_worker_replacement.js +0 -5
- package/dist/package.json +0 -1
- package/src/style-spec/validate_spec.test.ts +0 -29
- package/src/symbol/shaping.test.ts +0 -392
- package/src/types/glsl.d.ts +0 -4
|
@@ -27,27 +27,27 @@ import type Point from '@mapbox/point-geometry';
|
|
|
27
27
|
import type {CanonicalTileID} from '../../source/tile_id';
|
|
28
28
|
|
|
29
29
|
export type Feature = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
readonly type: 1 | 2 | 3 | 'Unknown' | 'Point' | 'MultiPoint' | 'LineString' | 'MultiLineString' | 'Polygon' | 'MultiPolygon';
|
|
31
|
+
readonly id?: any;
|
|
32
|
+
readonly properties: {[_: string]: any};
|
|
33
|
+
readonly patterns?: {
|
|
34
|
+
[_: string]: {
|
|
35
|
+
'min': string;
|
|
36
|
+
'mid': string;
|
|
37
|
+
'max': string;
|
|
38
|
+
};
|
|
38
39
|
};
|
|
39
|
-
|
|
40
|
-
readonly geometry?: Array<Array<Point>>;
|
|
40
|
+
readonly geometry?: Array<Array<Point>>;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
export type FeatureState = {[_: string]: any};
|
|
44
44
|
|
|
45
45
|
export type GlobalProperties = Readonly<{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
zoom: number;
|
|
47
|
+
heatmapDensity?: number;
|
|
48
|
+
lineProgress?: number;
|
|
49
|
+
isSupportedScript?: (_: string) => boolean;
|
|
50
|
+
accumulated?: Value;
|
|
51
51
|
}>;
|
|
52
52
|
|
|
53
53
|
export class StyleExpression {
|
|
@@ -67,12 +67,12 @@ export class StyleExpression {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
evaluateWithoutErrorHandling(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
globals: GlobalProperties,
|
|
71
|
+
feature?: Feature,
|
|
72
|
+
featureState?: FeatureState,
|
|
73
|
+
canonical?: CanonicalTileID,
|
|
74
|
+
availableImages?: Array<string>,
|
|
75
|
+
formattedSection?: FormattedSection
|
|
76
76
|
): any {
|
|
77
77
|
this._evaluator.globals = globals;
|
|
78
78
|
this._evaluator.feature = feature;
|
|
@@ -85,12 +85,12 @@ export class StyleExpression {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
evaluate(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
globals: GlobalProperties,
|
|
89
|
+
feature?: Feature,
|
|
90
|
+
featureState?: FeatureState,
|
|
91
|
+
canonical?: CanonicalTileID,
|
|
92
|
+
availableImages?: Array<string>,
|
|
93
|
+
formattedSection?: FormattedSection
|
|
94
94
|
): any {
|
|
95
95
|
this._evaluator.globals = globals;
|
|
96
96
|
this._evaluator.feature = feature || null;
|
|
@@ -162,23 +162,23 @@ export class ZoomConstantExpression<Kind extends EvaluationKind> {
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
evaluateWithoutErrorHandling(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
165
|
+
globals: GlobalProperties,
|
|
166
|
+
feature?: Feature,
|
|
167
|
+
featureState?: FeatureState,
|
|
168
|
+
canonical?: CanonicalTileID,
|
|
169
|
+
availableImages?: Array<string>,
|
|
170
|
+
formattedSection?: FormattedSection
|
|
171
171
|
): any {
|
|
172
172
|
return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
evaluate(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
176
|
+
globals: GlobalProperties,
|
|
177
|
+
feature?: Feature,
|
|
178
|
+
featureState?: FeatureState,
|
|
179
|
+
canonical?: CanonicalTileID,
|
|
180
|
+
availableImages?: Array<string>,
|
|
181
|
+
formattedSection?: FormattedSection
|
|
182
182
|
): any {
|
|
183
183
|
return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);
|
|
184
184
|
}
|
|
@@ -201,23 +201,23 @@ export class ZoomDependentExpression<Kind extends EvaluationKind> {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
evaluateWithoutErrorHandling(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
204
|
+
globals: GlobalProperties,
|
|
205
|
+
feature?: Feature,
|
|
206
|
+
featureState?: FeatureState,
|
|
207
|
+
canonical?: CanonicalTileID,
|
|
208
|
+
availableImages?: Array<string>,
|
|
209
|
+
formattedSection?: FormattedSection
|
|
210
210
|
): any {
|
|
211
211
|
return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
evaluate(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
215
|
+
globals: GlobalProperties,
|
|
216
|
+
feature?: Feature,
|
|
217
|
+
featureState?: FeatureState,
|
|
218
|
+
canonical?: CanonicalTileID,
|
|
219
|
+
availableImages?: Array<string>,
|
|
220
|
+
formattedSection?: FormattedSection
|
|
221
221
|
): any {
|
|
222
222
|
return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);
|
|
223
223
|
}
|
|
@@ -232,57 +232,57 @@ export class ZoomDependentExpression<Kind extends EvaluationKind> {
|
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
export type ConstantExpression = {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
235
|
+
kind: 'constant';
|
|
236
|
+
readonly evaluate: (
|
|
237
|
+
globals: GlobalProperties,
|
|
238
|
+
feature?: Feature,
|
|
239
|
+
featureState?: FeatureState,
|
|
240
|
+
canonical?: CanonicalTileID,
|
|
241
|
+
availableImages?: Array<string>
|
|
242
|
+
) => any;
|
|
243
243
|
};
|
|
244
244
|
|
|
245
245
|
export type SourceExpression = {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
246
|
+
kind: 'source';
|
|
247
|
+
isStateDependent: boolean;
|
|
248
|
+
readonly evaluate: (
|
|
249
|
+
globals: GlobalProperties,
|
|
250
|
+
feature?: Feature,
|
|
251
|
+
featureState?: FeatureState,
|
|
252
|
+
canonical?: CanonicalTileID,
|
|
253
|
+
availableImages?: Array<string>,
|
|
254
|
+
formattedSection?: FormattedSection
|
|
255
|
+
) => any;
|
|
256
256
|
};
|
|
257
257
|
|
|
258
258
|
export type CameraExpression = {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
259
|
+
kind: 'camera';
|
|
260
|
+
readonly evaluate: (
|
|
261
|
+
globals: GlobalProperties,
|
|
262
|
+
feature?: Feature,
|
|
263
|
+
featureState?: FeatureState,
|
|
264
|
+
canonical?: CanonicalTileID,
|
|
265
|
+
availableImages?: Array<string>
|
|
266
|
+
) => any;
|
|
267
|
+
readonly interpolationFactor: (input: number, lower: number, upper: number) => number;
|
|
268
|
+
zoomStops: Array<number>;
|
|
269
|
+
interpolationType: InterpolationType;
|
|
270
270
|
};
|
|
271
271
|
|
|
272
272
|
export type CompositeExpression = {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
273
|
+
kind: 'composite';
|
|
274
|
+
isStateDependent: boolean;
|
|
275
|
+
readonly evaluate: (
|
|
276
|
+
globals: GlobalProperties,
|
|
277
|
+
feature?: Feature,
|
|
278
|
+
featureState?: FeatureState,
|
|
279
|
+
canonical?: CanonicalTileID,
|
|
280
|
+
availableImages?: Array<string>,
|
|
281
|
+
formattedSection?: FormattedSection
|
|
282
|
+
) => any;
|
|
283
|
+
readonly interpolationFactor: (input: number, lower: number, upper: number) => number;
|
|
284
|
+
zoomStops: Array<number>;
|
|
285
|
+
interpolationType: InterpolationType;
|
|
286
286
|
};
|
|
287
287
|
|
|
288
288
|
export type StylePropertyExpression = ConstantExpression | SourceExpression | CameraExpression | CompositeExpression;
|
|
@@ -348,8 +348,8 @@ export class StylePropertyFunction<T> {
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
static deserialize<T>(serialized: {
|
|
351
|
-
|
|
352
|
-
|
|
351
|
+
_parameters: PropertyValueSpecification<T>;
|
|
352
|
+
_specification: StylePropertySpecification;
|
|
353
353
|
}) {
|
|
354
354
|
return new StylePropertyFunction(serialized._parameters, serialized._specification) as StylePropertyFunction<T>;
|
|
355
355
|
}
|
|
@@ -363,8 +363,8 @@ export class StylePropertyFunction<T> {
|
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
export function normalizePropertyExpression<T>(
|
|
366
|
-
|
|
367
|
-
|
|
366
|
+
value: PropertyValueSpecification<T>,
|
|
367
|
+
specification: StylePropertySpecification
|
|
368
368
|
): StylePropertyExpression {
|
|
369
369
|
if (isFunction(value)) {
|
|
370
370
|
return new StylePropertyFunction(value, specification) as any;
|
|
@@ -54,13 +54,13 @@ class ParsingContext {
|
|
|
54
54
|
* @private
|
|
55
55
|
*/
|
|
56
56
|
parse(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
expr: unknown,
|
|
58
|
+
index?: number,
|
|
59
|
+
expectedType?: Type | null,
|
|
60
|
+
bindings?: Array<[string, Expression]>,
|
|
61
|
+
options: {
|
|
62
|
+
typeAnnotation?: 'assert' | 'coerce' | 'omit';
|
|
63
|
+
} = {}
|
|
64
64
|
): Expression {
|
|
65
65
|
if (index) {
|
|
66
66
|
return this.concat(index, expectedType, bindings)._parse(expr, options);
|
|
@@ -69,10 +69,10 @@ class ParsingContext {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
_parse(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
expr: unknown,
|
|
73
|
+
options: {
|
|
74
|
+
typeAnnotation?: 'assert' | 'coerce' | 'omit';
|
|
75
|
+
}
|
|
76
76
|
): Expression {
|
|
77
77
|
if (expr === null || typeof expr === 'string' || typeof expr === 'boolean' || typeof expr === 'number') {
|
|
78
78
|
expr = ['literal', expr];
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// https://github.com/facebook/flow/issues/1270
|
|
3
3
|
|
|
4
4
|
declare let Intl: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Collator: {
|
|
6
|
+
new (...args: any): Intl$Collator;
|
|
7
|
+
};
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
declare class Intl$Collator {
|
|
@@ -14,12 +14,12 @@ declare class Intl$Collator {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
type CollatorOptions = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
localeMatcher?: 'lookup' | 'best fit';
|
|
18
|
+
usage?: 'sort' | 'search';
|
|
19
|
+
sensitivity?: 'base' | 'accent' | 'case' | 'variant';
|
|
20
|
+
ignorePunctuation?: boolean;
|
|
21
|
+
numeric?: boolean;
|
|
22
|
+
caseFirst?: 'upper' | 'lower' | 'false';
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export default class Collator {
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
export type NullTypeT = {
|
|
2
|
-
|
|
2
|
+
kind: 'null';
|
|
3
3
|
};
|
|
4
4
|
export type NumberTypeT = {
|
|
5
|
-
|
|
5
|
+
kind: 'number';
|
|
6
6
|
};
|
|
7
7
|
export type StringTypeT = {
|
|
8
|
-
|
|
8
|
+
kind: 'string';
|
|
9
9
|
};
|
|
10
10
|
export type BooleanTypeT = {
|
|
11
|
-
|
|
11
|
+
kind: 'boolean';
|
|
12
12
|
};
|
|
13
13
|
export type ColorTypeT = {
|
|
14
|
-
|
|
14
|
+
kind: 'color';
|
|
15
15
|
};
|
|
16
16
|
export type ObjectTypeT = {
|
|
17
|
-
|
|
17
|
+
kind: 'object';
|
|
18
18
|
};
|
|
19
19
|
export type ValueTypeT = {
|
|
20
|
-
|
|
20
|
+
kind: 'value';
|
|
21
21
|
};
|
|
22
22
|
export type ErrorTypeT = {
|
|
23
|
-
|
|
23
|
+
kind: 'error';
|
|
24
24
|
};
|
|
25
25
|
export type CollatorTypeT = {
|
|
26
|
-
|
|
26
|
+
kind: 'collator';
|
|
27
27
|
};
|
|
28
28
|
export type FormattedTypeT = {
|
|
29
|
-
|
|
29
|
+
kind: 'formatted';
|
|
30
30
|
};
|
|
31
31
|
export type ResolvedImageTypeT = {
|
|
32
|
-
|
|
32
|
+
kind: 'resolvedImage';
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
export type EvaluationKind = 'constant' | 'source' | 'camera' | 'composite';
|
|
@@ -38,9 +38,9 @@ export type Type = NullTypeT | NumberTypeT | StringTypeT | BooleanTypeT | ColorT
|
|
|
38
38
|
ArrayType | ErrorTypeT | CollatorTypeT | FormattedTypeT | ResolvedImageTypeT;
|
|
39
39
|
|
|
40
40
|
export type ArrayType = {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
kind: 'array';
|
|
42
|
+
itemType: Type;
|
|
43
|
+
N: number;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
export type NativeType = 'number' | 'string' | 'boolean' | 'null' | 'array' | 'object';
|
|
@@ -28,7 +28,7 @@ export function validateRGBA(r: unknown, g: unknown, b: unknown, a?: unknown): s
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export type Value = null | string | boolean | number | Color | Collator | Formatted | ResolvedImage | ReadonlyArray<Value> | {
|
|
31
|
-
|
|
31
|
+
readonly [x: string]: Value;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export function isValue(mixed: unknown): boolean {
|
|
@@ -4,14 +4,14 @@ import type {CanonicalTileID} from '../../source/tile_id';
|
|
|
4
4
|
import {StylePropertySpecification} from '../style-spec';
|
|
5
5
|
|
|
6
6
|
type FilterExpression = (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
globalProperties: GlobalProperties,
|
|
8
|
+
feature: Feature,
|
|
9
|
+
canonical?: CanonicalTileID
|
|
10
10
|
) => boolean;
|
|
11
11
|
|
|
12
12
|
export type FeatureFilter = {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
filter: FilterExpression;
|
|
14
|
+
needGeometry: boolean;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export default createFilter;
|
|
@@ -26,36 +26,36 @@ function isExpressionFilter(filter: any) {
|
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
28
|
switch (filter[0]) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
29
|
+
case 'has':
|
|
30
|
+
return filter.length >= 2 && filter[1] !== '$id' && filter[1] !== '$type';
|
|
31
|
+
|
|
32
|
+
case 'in':
|
|
33
|
+
return filter.length >= 3 && (typeof filter[1] !== 'string' || Array.isArray(filter[2]));
|
|
34
|
+
|
|
35
|
+
case '!in':
|
|
36
|
+
case '!has':
|
|
37
|
+
case 'none':
|
|
38
|
+
return false;
|
|
39
|
+
|
|
40
|
+
case '==':
|
|
41
|
+
case '!=':
|
|
42
|
+
case '>':
|
|
43
|
+
case '>=':
|
|
44
|
+
case '<':
|
|
45
|
+
case '<=':
|
|
46
|
+
return filter.length !== 3 || (Array.isArray(filter[1]) || Array.isArray(filter[2]));
|
|
47
|
+
|
|
48
|
+
case 'any':
|
|
49
|
+
case 'all':
|
|
50
|
+
for (const f of filter.slice(1)) {
|
|
51
|
+
if (!isExpressionFilter(f) && typeof f !== 'boolean') {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
return true;
|
|
55
|
+
return true;
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
default:
|
|
58
|
+
return true;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -118,31 +118,31 @@ function convertFilter(filter?: Array<any> | null): unknown {
|
|
|
118
118
|
if (filter.length <= 1) return (op !== 'any');
|
|
119
119
|
const converted =
|
|
120
120
|
op === '==' ? convertComparisonOp(filter[1], filter[2], '==') :
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
op === '!=' ? convertNegation(convertComparisonOp(filter[1], filter[2], '==')) :
|
|
122
|
+
op === '<' ||
|
|
123
123
|
op === '>' ||
|
|
124
124
|
op === '<=' ||
|
|
125
125
|
op === '>=' ? convertComparisonOp(filter[1], filter[2], op) :
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
126
|
+
op === 'any' ? convertDisjunctionOp(filter.slice(1)) :
|
|
127
|
+
op === 'all' ? ['all' as unknown].concat(filter.slice(1).map(convertFilter)) :
|
|
128
|
+
op === 'none' ? ['all' as unknown].concat(filter.slice(1).map(convertFilter).map(convertNegation)) :
|
|
129
|
+
op === 'in' ? convertInOp(filter[1], filter.slice(2)) :
|
|
130
|
+
op === '!in' ? convertNegation(convertInOp(filter[1], filter.slice(2))) :
|
|
131
|
+
op === 'has' ? convertHasOp(filter[1]) :
|
|
132
|
+
op === '!has' ? convertNegation(convertHasOp(filter[1])) :
|
|
133
|
+
op === 'within' ? filter :
|
|
134
|
+
true;
|
|
135
135
|
return converted;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
function convertComparisonOp(property: string, value: any, op: string) {
|
|
139
139
|
switch (property) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
case '$type':
|
|
141
|
+
return [`filter-type-${op}`, value];
|
|
142
|
+
case '$id':
|
|
143
|
+
return [`filter-id-${op}`, value];
|
|
144
|
+
default:
|
|
145
|
+
return [`filter-${op}`, property, value];
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
@@ -153,27 +153,27 @@ function convertDisjunctionOp(filters: Array<Array<any>>) {
|
|
|
153
153
|
function convertInOp(property: string, values: Array<any>) {
|
|
154
154
|
if (values.length === 0) { return false; }
|
|
155
155
|
switch (property) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
156
|
+
case '$type':
|
|
157
|
+
return ['filter-type-in', ['literal', values]];
|
|
158
|
+
case '$id':
|
|
159
|
+
return ['filter-id-in', ['literal', values]];
|
|
160
|
+
default:
|
|
161
|
+
if (values.length > 200 && !values.some(v => typeof v !== typeof values[0])) {
|
|
162
|
+
return ['filter-in-large', property, ['literal', values.sort(compare)]];
|
|
163
|
+
} else {
|
|
164
|
+
return ['filter-in-small', property, ['literal', values]];
|
|
165
|
+
}
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
function convertHasOp(property: string) {
|
|
170
170
|
switch (property) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
case '$type':
|
|
172
|
+
return true;
|
|
173
|
+
case '$id':
|
|
174
|
+
return ['filter-has-id'];
|
|
175
|
+
default:
|
|
176
|
+
return ['filter-has', property];
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
|
|
@@ -60,9 +60,9 @@ function convertIdentityFunction(parameters, propertySpec): Array<unknown> {
|
|
|
60
60
|
|
|
61
61
|
function getInterpolateOperator(parameters) {
|
|
62
62
|
switch (parameters.colorSpace) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
case 'hcl': return 'interpolate-hcl';
|
|
64
|
+
case 'lab': return 'interpolate-lab';
|
|
65
|
+
default: return 'interpolate';
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|