maplibre-gl 2.0.4 → 2.1.2
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 +1583 -1023
- package/dist/maplibre-gl.js +3 -3
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +99 -141
- package/src/css/maplibre-gl.css +36 -36
- 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 +56 -56
- 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 +47 -47
- 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_debug.ts +1 -1
- 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 +34 -33
- package/src/render/image_manager.ts +4 -4
- package/src/render/painter.ts +16 -14
- package/src/render/program/background_program.ts +29 -29
- package/src/render/program/circle_program.ts +11 -11
- 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 +41 -41
- package/src/render/program/pattern.ts +28 -28
- package/src/render/program/raster_program.ts +21 -21
- package/src/render/program/symbol_program.ts +97 -97
- 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_source.test.ts +2 -1
- package/src/source/geojson_source.ts +1 -1
- package/src/source/geojson_worker_source.ts +23 -23
- package/src/source/geojson_wrapper.ts +8 -8
- package/src/source/image_source.test.ts +153 -0
- 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 +4 -3
- package/src/source/raster_dem_tile_source.ts +1 -1
- package/src/source/raster_tile_source.test.ts +4 -3
- package/src/source/raster_tile_source.ts +1 -1
- package/src/source/rtl_text_plugin.ts +10 -10
- package/src/source/source.ts +29 -29
- package/src/source/source_cache.test.ts +33 -1
- 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 +10 -13
- package/src/source/tile_id.ts +2 -2
- package/src/source/vector_tile_source.test.ts +17 -5
- package/src/source/vector_tile_source.ts +4 -5
- 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 +5 -4
- package/src/style/pauseable_placement.ts +1 -1
- package/src/style/properties.ts +70 -70
- package/src/style/query_utils.ts +7 -7
- package/src/style/style.test.ts +26 -15
- package/src/style/style.ts +30 -30
- 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 +19 -19
- package/src/style/style_layer/fill_extrusion_style_layer.ts +11 -11
- 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 +26 -7
- package/src/style/style_layer/{symbol_style_layer_properties.ts → symbol_style_layer_properties.g.ts} +6 -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/CHANGELOG.md +6 -0
- 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/package.json +1 -1
- package/src/style-spec/reference/v8.json +68 -2
- package/src/style-spec/style-spec.ts +44 -44
- package/src/style-spec/types.ts +2 -0
- 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 +43 -43
- package/src/symbol/cross_tile_symbol_index.ts +17 -17
- package/src/symbol/get_anchors.ts +16 -16
- package/src/symbol/grid_index.test.ts +42 -19
- package/src/symbol/grid_index.ts +69 -40
- package/src/symbol/placement.ts +124 -95
- 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 +49 -2
- 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 +26 -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 +87 -14
- package/src/ui/map.ts +138 -108
- 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 +214 -0
- 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/test/util.ts +14 -0
- 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
|
@@ -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
|
|
|
@@ -1144,7 +1144,10 @@
|
|
|
1144
1144
|
"default": false,
|
|
1145
1145
|
"doc": "If true, the icon will be visible even if it collides with other previously drawn symbols.",
|
|
1146
1146
|
"requires": [
|
|
1147
|
-
"icon-image"
|
|
1147
|
+
"icon-image",
|
|
1148
|
+
{
|
|
1149
|
+
"!": "icon-overlap"
|
|
1150
|
+
}
|
|
1148
1151
|
],
|
|
1149
1152
|
"sdk-support": {
|
|
1150
1153
|
"basic functionality": {
|
|
@@ -1162,6 +1165,36 @@
|
|
|
1162
1165
|
},
|
|
1163
1166
|
"property-type": "data-constant"
|
|
1164
1167
|
},
|
|
1168
|
+
"icon-overlap": {
|
|
1169
|
+
"type": "enum",
|
|
1170
|
+
"values": {
|
|
1171
|
+
"never": {
|
|
1172
|
+
"doc": "The icon will be hidden if it collides with any other previously drawn symbol."
|
|
1173
|
+
},
|
|
1174
|
+
"always": {
|
|
1175
|
+
"doc": "The icon will be visible even if it collides with any other previously drawn symbol."
|
|
1176
|
+
},
|
|
1177
|
+
"cooperative": {
|
|
1178
|
+
"doc": "If the icon collides with another previously drawn symbol, the overlap mode for that symbol is checked. If the previous symbol was placed using `never` overlap mode, the new icon is hidden. If the previous symbol was placed using `always` or `cooperative` overlap mode, the new icon is visible."
|
|
1179
|
+
}
|
|
1180
|
+
},
|
|
1181
|
+
"doc": "Allows for control over whether to show an icon when it overlaps other symbols on the map. If `icon-overlap` is not set, `icon-allow-overlap` is used instead.",
|
|
1182
|
+
"requires": [
|
|
1183
|
+
"icon-image"
|
|
1184
|
+
],
|
|
1185
|
+
"sdk-support": {
|
|
1186
|
+
"basic functionality": {
|
|
1187
|
+
"js": "2.1.0"
|
|
1188
|
+
}
|
|
1189
|
+
},
|
|
1190
|
+
"expression": {
|
|
1191
|
+
"interpolated": false,
|
|
1192
|
+
"parameters": [
|
|
1193
|
+
"zoom"
|
|
1194
|
+
]
|
|
1195
|
+
},
|
|
1196
|
+
"property-type": "data-constant"
|
|
1197
|
+
},
|
|
1165
1198
|
"icon-ignore-placement": {
|
|
1166
1199
|
"type": "boolean",
|
|
1167
1200
|
"default": false,
|
|
@@ -2309,7 +2342,10 @@
|
|
|
2309
2342
|
"default": false,
|
|
2310
2343
|
"doc": "If true, the text will be visible even if it collides with other previously drawn symbols.",
|
|
2311
2344
|
"requires": [
|
|
2312
|
-
"text-field"
|
|
2345
|
+
"text-field",
|
|
2346
|
+
{
|
|
2347
|
+
"!": "text-overlap"
|
|
2348
|
+
}
|
|
2313
2349
|
],
|
|
2314
2350
|
"sdk-support": {
|
|
2315
2351
|
"basic functionality": {
|
|
@@ -2327,6 +2363,36 @@
|
|
|
2327
2363
|
},
|
|
2328
2364
|
"property-type": "data-constant"
|
|
2329
2365
|
},
|
|
2366
|
+
"text-overlap": {
|
|
2367
|
+
"type": "enum",
|
|
2368
|
+
"values": {
|
|
2369
|
+
"never": {
|
|
2370
|
+
"doc": "The text will be hidden if it collides with any other previously drawn symbol."
|
|
2371
|
+
},
|
|
2372
|
+
"always": {
|
|
2373
|
+
"doc": "The text will be visible even if it collides with any other previously drawn symbol."
|
|
2374
|
+
},
|
|
2375
|
+
"cooperative": {
|
|
2376
|
+
"doc": "If the text collides with another previously drawn symbol, the overlap mode for that symbol is checked. If the previous symbol was placed using `never` overlap mode, the new text is hidden. If the previous symbol was placed using `always` or `cooperative` overlap mode, the new text is visible."
|
|
2377
|
+
}
|
|
2378
|
+
},
|
|
2379
|
+
"doc": "Allows for control over whether to show symbol text when it overlaps other symbols on the map. If `text-overlap` is not set, `text-allow-overlap` is used instead",
|
|
2380
|
+
"requires": [
|
|
2381
|
+
"text-field"
|
|
2382
|
+
],
|
|
2383
|
+
"sdk-support": {
|
|
2384
|
+
"basic functionality": {
|
|
2385
|
+
"js": "2.1.0"
|
|
2386
|
+
}
|
|
2387
|
+
},
|
|
2388
|
+
"expression": {
|
|
2389
|
+
"interpolated": false,
|
|
2390
|
+
"parameters": [
|
|
2391
|
+
"zoom"
|
|
2392
|
+
]
|
|
2393
|
+
},
|
|
2394
|
+
"property-type": "data-constant"
|
|
2395
|
+
},
|
|
2330
2396
|
"text-ignore-placement": {
|
|
2331
2397
|
"type": "boolean",
|
|
2332
2398
|
"default": false,
|
|
@@ -2,59 +2,59 @@ type ExpressionType = 'data-driven' | 'cross-faded' | 'cross-faded-data-driven'
|
|
|
2
2
|
type ExpressionParameters = Array<'zoom' | 'feature' | 'feature-state' | 'heatmap-density' | 'line-progress'>;
|
|
3
3
|
|
|
4
4
|
type ExpressionSpecification = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
interpolated: boolean;
|
|
6
|
+
parameters: ExpressionParameters;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export type StylePropertySpecification = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
type: 'number';
|
|
11
|
+
'property-type': ExpressionType;
|
|
12
|
+
expression?: ExpressionSpecification;
|
|
13
|
+
transition: boolean;
|
|
14
|
+
default?: number;
|
|
15
15
|
} | {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
type: 'string';
|
|
17
|
+
'property-type': ExpressionType;
|
|
18
|
+
expression?: ExpressionSpecification;
|
|
19
|
+
transition: boolean;
|
|
20
|
+
default?: string;
|
|
21
|
+
tokens?: boolean;
|
|
22
22
|
} | {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
type: 'boolean';
|
|
24
|
+
'property-type': ExpressionType;
|
|
25
|
+
expression?: ExpressionSpecification;
|
|
26
|
+
transition: boolean;
|
|
27
|
+
default?: boolean;
|
|
28
28
|
} | {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
type: 'enum';
|
|
30
|
+
'property-type': ExpressionType;
|
|
31
|
+
expression?: ExpressionSpecification;
|
|
32
|
+
values: {[_: string]: {}};
|
|
33
|
+
transition: boolean;
|
|
34
|
+
default?: string;
|
|
35
35
|
} | {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
type: 'color';
|
|
37
|
+
'property-type': ExpressionType;
|
|
38
|
+
expression?: ExpressionSpecification;
|
|
39
|
+
transition: boolean;
|
|
40
|
+
default?: string;
|
|
41
|
+
overridable: boolean;
|
|
42
42
|
} | {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
type: 'array';
|
|
44
|
+
value: 'number';
|
|
45
|
+
'property-type': ExpressionType;
|
|
46
|
+
expression?: ExpressionSpecification;
|
|
47
|
+
length?: number;
|
|
48
|
+
transition: boolean;
|
|
49
|
+
default?: Array<number>;
|
|
50
50
|
} | {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
type: 'array';
|
|
52
|
+
value: 'string';
|
|
53
|
+
'property-type': ExpressionType;
|
|
54
|
+
expression?: ExpressionSpecification;
|
|
55
|
+
length?: number;
|
|
56
|
+
transition: boolean;
|
|
57
|
+
default?: Array<string>;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
import v8 from './reference/v8.json';
|
package/src/style-spec/types.ts
CHANGED
|
@@ -248,6 +248,7 @@ export type SymbolLayerSpecification = {
|
|
|
248
248
|
"symbol-sort-key"?: DataDrivenPropertyValueSpecification<number>,
|
|
249
249
|
"symbol-z-order"?: PropertyValueSpecification<"auto" | "viewport-y" | "source">,
|
|
250
250
|
"icon-allow-overlap"?: PropertyValueSpecification<boolean>,
|
|
251
|
+
"icon-overlap"?: PropertyValueSpecification<"never" | "always" | "cooperative">,
|
|
251
252
|
"icon-ignore-placement"?: PropertyValueSpecification<boolean>,
|
|
252
253
|
"icon-optional"?: PropertyValueSpecification<boolean>,
|
|
253
254
|
"icon-rotation-alignment"?: PropertyValueSpecification<"map" | "viewport" | "auto">,
|
|
@@ -281,6 +282,7 @@ export type SymbolLayerSpecification = {
|
|
|
281
282
|
"text-transform"?: DataDrivenPropertyValueSpecification<"none" | "uppercase" | "lowercase">,
|
|
282
283
|
"text-offset"?: DataDrivenPropertyValueSpecification<[number, number]>,
|
|
283
284
|
"text-allow-overlap"?: PropertyValueSpecification<boolean>,
|
|
285
|
+
"text-overlap"?: PropertyValueSpecification<"never" | "always" | "cooperative">,
|
|
284
286
|
"text-ignore-placement"?: PropertyValueSpecification<boolean>,
|
|
285
287
|
"text-optional"?: PropertyValueSpecification<boolean>,
|
|
286
288
|
"visibility"?: "visible" | "none"
|
|
@@ -3,17 +3,17 @@ import Color from './color';
|
|
|
3
3
|
import {number as interpolateNumber} from './interpolate';
|
|
4
4
|
|
|
5
5
|
type LABColor = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
l: number;
|
|
7
|
+
a: number;
|
|
8
|
+
b: number;
|
|
9
|
+
alpha: number;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
type HCLColor = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
h: number;
|
|
14
|
+
c: number;
|
|
15
|
+
l: number;
|
|
16
|
+
alpha: number;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
// Constants
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* @private
|
|
6
6
|
*/
|
|
7
7
|
export type Result<T, E> = {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
result: 'success';
|
|
9
|
+
value: T;
|
|
10
10
|
} | {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
result: 'error';
|
|
12
|
+
value: E;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export function success<T, E>(value: T): Result<T, E> {
|
|
@@ -44,74 +44,74 @@ function validateNonExpressionFilter(options) {
|
|
|
44
44
|
}));
|
|
45
45
|
|
|
46
46
|
switch (unbundle(value[0])) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
case '<':
|
|
48
|
+
case '<=':
|
|
49
|
+
case '>':
|
|
50
|
+
case '>=':
|
|
51
|
+
if (value.length >= 2 && unbundle(value[1]) === '$type') {
|
|
52
|
+
errors.push(new ValidationError(key, value, `"$type" cannot be use with operator "${value[0]}"`));
|
|
53
|
+
}
|
|
54
54
|
/* falls through */
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
case '==':
|
|
56
|
+
case '!=':
|
|
57
|
+
if (value.length !== 3) {
|
|
58
|
+
errors.push(new ValidationError(key, value, `filter array for operator "${value[0]}" must have 3 elements`));
|
|
59
|
+
}
|
|
60
60
|
/* falls through */
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
case 'in':
|
|
62
|
+
case '!in':
|
|
63
|
+
if (value.length >= 2) {
|
|
64
|
+
type = getType(value[1]);
|
|
65
|
+
if (type !== 'string') {
|
|
66
|
+
errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (let i = 2; i < value.length; i++) {
|
|
70
|
+
type = getType(value[i]);
|
|
71
|
+
if (unbundle(value[1]) === '$type') {
|
|
72
|
+
errors = errors.concat(validateEnum({
|
|
73
|
+
key: `${key}[${i}]`,
|
|
74
|
+
value: value[i],
|
|
75
|
+
valueSpec: styleSpec.geometry_type,
|
|
76
|
+
style: options.style,
|
|
77
|
+
styleSpec: options.styleSpec
|
|
78
|
+
}));
|
|
79
|
+
} else if (type !== 'string' && type !== 'number' && type !== 'boolean') {
|
|
80
|
+
errors.push(new ValidationError(`${key}[${i}]`, value[i], `string, number, or boolean expected, ${type} found`));
|
|
81
|
+
}
|
|
67
82
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
83
|
+
break;
|
|
84
|
+
|
|
85
|
+
case 'any':
|
|
86
|
+
case 'all':
|
|
87
|
+
case 'none':
|
|
88
|
+
for (let i = 1; i < value.length; i++) {
|
|
89
|
+
errors = errors.concat(validateNonExpressionFilter({
|
|
73
90
|
key: `${key}[${i}]`,
|
|
74
91
|
value: value[i],
|
|
75
|
-
valueSpec: styleSpec.geometry_type,
|
|
76
92
|
style: options.style,
|
|
77
93
|
styleSpec: options.styleSpec
|
|
78
94
|
}));
|
|
79
|
-
} else if (type !== 'string' && type !== 'number' && type !== 'boolean') {
|
|
80
|
-
errors.push(new ValidationError(`${key}[${i}]`, value[i], `string, number, or boolean expected, ${type} found`));
|
|
81
95
|
}
|
|
82
|
-
|
|
83
|
-
break;
|
|
96
|
+
break;
|
|
84
97
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
errors.push(new ValidationError(key, value, `filter array for "${value[0]}" operator must have 2 elements`));
|
|
103
|
-
} else if (type !== 'string') {
|
|
104
|
-
errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
case 'within':
|
|
108
|
-
type = getType(value[1]);
|
|
109
|
-
if (value.length !== 2) {
|
|
110
|
-
errors.push(new ValidationError(key, value, `filter array for "${value[0]}" operator must have 2 elements`));
|
|
111
|
-
} else if (type !== 'object') {
|
|
112
|
-
errors.push(new ValidationError(`${key}[1]`, value[1], `object expected, ${type} found`));
|
|
113
|
-
}
|
|
114
|
-
break;
|
|
98
|
+
case 'has':
|
|
99
|
+
case '!has':
|
|
100
|
+
type = getType(value[1]);
|
|
101
|
+
if (value.length !== 2) {
|
|
102
|
+
errors.push(new ValidationError(key, value, `filter array for "${value[0]}" operator must have 2 elements`));
|
|
103
|
+
} else if (type !== 'string') {
|
|
104
|
+
errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
case 'within':
|
|
108
|
+
type = getType(value[1]);
|
|
109
|
+
if (value.length !== 2) {
|
|
110
|
+
errors.push(new ValidationError(key, value, `filter array for "${value[0]}" operator must have 2 elements`));
|
|
111
|
+
} else if (type !== 'object') {
|
|
112
|
+
errors.push(new ValidationError(`${key}[1]`, value[1], `object expected, ${type} found`));
|
|
113
|
+
}
|
|
114
|
+
break;
|
|
115
115
|
}
|
|
116
116
|
return errors;
|
|
117
117
|
}
|