@mapgis/mapbox-gl 16.0.1 → 16.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mapbox-gl.js +3 -3
- package/dist/mapbox-gl.js.map +1 -1
- package/package.json +1 -1
- package/.flowconfig +0 -61
- package/LICENSE.txt +0 -84
- package/README.md +0 -34
- package/build/banner.js +0 -4
- package/build/check-bundle-size.js +0 -140
- package/build/generate-access-token-script.js +0 -11
- package/build/generate-flow-typed-style-spec.js +0 -188
- package/build/generate-release-list.js +0 -21
- package/build/generate-struct-arrays.js +0 -237
- package/build/generate-style-code.js +0 -159
- package/build/mapbox-gl.js.flow +0 -3
- package/build/print-release-url.js +0 -6
- package/build/rollup_plugin_minify_style_spec.js +0 -20
- package/build/rollup_plugins.js +0 -80
- package/build/run-node +0 -3
- package/build/run-tap +0 -8
- package/build/test/build-tape.js +0 -19
- package/flow-typed/gl.js +0 -5
- package/flow-typed/jsdom.js +0 -18
- package/flow-typed/mapbox-gl-supported.js +0 -9
- package/flow-typed/mapbox-unitbezier.js +0 -14
- package/flow-typed/offscreen-canvas.js +0 -9
- package/flow-typed/pbf.js +0 -25
- package/flow-typed/point-geometry.js +0 -44
- package/flow-typed/potpack.js +0 -12
- package/flow-typed/sinon.js +0 -28
- package/flow-typed/vector-tile.js +0 -41
- package/src/css/mapbox-gl.css +0 -798
- package/src/css/svg/mapboxgl-ctrl-attrib.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-compass.svg +0 -4
- package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-geolocate.svg +0 -5
- package/src/css/svg/mapboxgl-ctrl-logo.svg +0 -20
- package/src/css/svg/mapboxgl-ctrl-shrink.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +0 -3
- package/src/data/array_types.js +0 -1095
- package/src/data/bucket/circle_attributes.js +0 -9
- package/src/data/bucket/circle_bucket.js +0 -204
- package/src/data/bucket/fill_attributes.js +0 -9
- package/src/data/bucket/fill_bucket.js +0 -233
- package/src/data/bucket/fill_extrusion_attributes.js +0 -10
- package/src/data/bucket/fill_extrusion_bucket.js +0 -289
- package/src/data/bucket/heatmap_bucket.js +0 -17
- package/src/data/bucket/line_attributes.js +0 -10
- package/src/data/bucket/line_bucket.js +0 -556
- package/src/data/bucket/pattern_attributes.js +0 -10
- package/src/data/bucket/pattern_bucket_features.js +0 -60
- package/src/data/bucket/symbol_attributes.js +0 -117
- package/src/data/bucket/symbol_bucket.js +0 -972
- package/src/data/bucket.js +0 -123
- package/src/data/dem_data.js +0 -125
- package/src/data/extent.js +0 -18
- package/src/data/feature_index.js +0 -321
- package/src/data/feature_position_map.js +0 -125
- package/src/data/index_array_type.js +0 -16
- package/src/data/load_geometry.js +0 -48
- package/src/data/pos_attributes.js +0 -6
- package/src/data/program_configuration.js +0 -687
- package/src/data/raster_bounds_attributes.js +0 -7
- package/src/data/segment.js +0 -76
- package/src/geo/edge_insets.js +0 -102
- package/src/geo/lng_lat.js +0 -165
- package/src/geo/lng_lat_bounds.js +0 -267
- package/src/geo/mercator_coordinate.js +0 -153
- package/src/geo/transform.js +0 -864
- package/src/gl/color_mode.js +0 -34
- package/src/gl/context.js +0 -298
- package/src/gl/cull_face_mode.js +0 -26
- package/src/gl/depth_mode.js +0 -29
- package/src/gl/framebuffer.js +0 -44
- package/src/gl/index_buffer.js +0 -55
- package/src/gl/stencil_mode.js +0 -30
- package/src/gl/types.js +0 -84
- package/src/gl/value.js +0 -520
- package/src/gl/vertex_buffer.js +0 -119
- package/src/index.js +0 -201
- package/src/render/draw_background.js +0 -57
- package/src/render/draw_circle.js +0 -113
- package/src/render/draw_collision_debug.js +0 -49
- package/src/render/draw_custom.js +0 -49
- package/src/render/draw_debug.js +0 -127
- package/src/render/draw_fill.js +0 -126
- package/src/render/draw_fill_extrusion.js +0 -96
- package/src/render/draw_heatmap.js +0 -140
- package/src/render/draw_hillshade.js +0 -108
- package/src/render/draw_line.js +0 -98
- package/src/render/draw_raster.js +0 -125
- package/src/render/draw_symbol.js +0 -394
- package/src/render/glyph_atlas.js +0 -71
- package/src/render/glyph_manager.js +0 -182
- package/src/render/image_atlas.js +0 -149
- package/src/render/image_manager.js +0 -306
- package/src/render/line_atlas.js +0 -210
- package/src/render/painter.js +0 -653
- package/src/render/program/background_program.js +0 -103
- package/src/render/program/circle_program.js +0 -69
- package/src/render/program/clipping_mask_program.js +0 -20
- package/src/render/program/collision_program.js +0 -49
- package/src/render/program/debug_program.js +0 -35
- package/src/render/program/fill_extrusion_program.js +0 -122
- package/src/render/program/fill_program.js +0 -126
- package/src/render/program/heatmap_program.js +0 -83
- package/src/render/program/hillshade_program.js +0 -122
- package/src/render/program/line_program.js +0 -207
- package/src/render/program/pattern.js +0 -102
- package/src/render/program/program_uniforms.js +0 -42
- package/src/render/program/raster_program.js +0 -92
- package/src/render/program/symbol_program.js +0 -224
- package/src/render/program.js +0 -168
- package/src/render/texture.js +0 -122
- package/src/render/uniform_binding.js +0 -147
- package/src/render/vertex_array_object.js +0 -163
- package/src/shaders/README.md +0 -42
- package/src/shaders/_prelude.fragment.glsl +0 -17
- package/src/shaders/_prelude.vertex.glsl +0 -73
- package/src/shaders/background.fragment.glsl +0 -10
- package/src/shaders/background.vertex.glsl +0 -7
- package/src/shaders/background_pattern.fragment.glsl +0 -28
- package/src/shaders/background_pattern.vertex.glsl +0 -20
- package/src/shaders/circle.fragment.glsl +0 -39
- package/src/shaders/circle.vertex.glsl +0 -64
- package/src/shaders/clipping_mask.fragment.glsl +0 -3
- package/src/shaders/clipping_mask.vertex.glsl +0 -7
- package/src/shaders/collision_box.fragment.glsl +0 -21
- package/src/shaders/collision_box.vertex.glsl +0 -27
- package/src/shaders/collision_circle.fragment.glsl +0 -34
- package/src/shaders/collision_circle.vertex.glsl +0 -36
- package/src/shaders/debug.fragment.glsl +0 -9
- package/src/shaders/debug.vertex.glsl +0 -12
- package/src/shaders/encode_attribute.js +0 -17
- package/src/shaders/fill.fragment.glsl +0 -13
- package/src/shaders/fill.vertex.glsl +0 -13
- package/src/shaders/fill_extrusion.fragment.glsl +0 -9
- package/src/shaders/fill_extrusion.vertex.glsl +0 -66
- package/src/shaders/fill_extrusion_pattern.fragment.glsl +0 -45
- package/src/shaders/fill_extrusion_pattern.vertex.glsl +0 -79
- package/src/shaders/fill_outline.fragment.glsl +0 -17
- package/src/shaders/fill_outline.vertex.glsl +0 -17
- package/src/shaders/fill_outline_pattern.fragment.glsl +0 -43
- package/src/shaders/fill_outline_pattern.vertex.glsl +0 -44
- package/src/shaders/fill_pattern.fragment.glsl +0 -36
- package/src/shaders/fill_pattern.vertex.glsl +0 -39
- package/src/shaders/heatmap.fragment.glsl +0 -22
- package/src/shaders/heatmap.vertex.glsl +0 -54
- package/src/shaders/heatmap_texture.fragment.glsl +0 -14
- package/src/shaders/heatmap_texture.vertex.glsl +0 -11
- package/src/shaders/hillshade.fragment.glsl +0 -52
- package/src/shaders/hillshade.vertex.glsl +0 -11
- package/src/shaders/hillshade_prepare.fragment.glsl +0 -74
- package/src/shaders/hillshade_prepare.vertex.glsl +0 -15
- package/src/shaders/index.js +0 -20
- package/src/shaders/line.fragment.glsl +0 -30
- package/src/shaders/line.vertex.glsl +0 -85
- package/src/shaders/line_gradient.fragment.glsl +0 -34
- package/src/shaders/line_gradient.vertex.glsl +0 -87
- package/src/shaders/line_pattern.fragment.glsl +0 -74
- package/src/shaders/line_pattern.vertex.glsl +0 -99
- package/src/shaders/line_sdf.fragment.glsl +0 -45
- package/src/shaders/line_sdf.vertex.glsl +0 -98
- package/src/shaders/raster.fragment.glsl +0 -52
- package/src/shaders/raster.vertex.glsl +0 -21
- package/src/shaders/shaders.js +0 -180
- package/src/shaders/symbol_icon.fragment.glsl +0 -17
- package/src/shaders/symbol_icon.vertex.glsl +0 -94
- package/src/shaders/symbol_sdf.fragment.glsl +0 -52
- package/src/shaders/symbol_sdf.vertex.glsl +0 -115
- package/src/shaders/symbol_text_and_icon.fragment.glsl +0 -68
- package/src/shaders/symbol_text_and_icon.vertex.glsl +0 -116
- package/src/source/canvas_source.js +0 -238
- package/src/source/geojson_helper.js +0 -92
- package/src/source/geojson_source.js +0 -374
- package/src/source/geojson_worker_source.js +0 -357
- package/src/source/geojson_wrapper.js +0 -94
- package/src/source/image_source.js +0 -307
- package/src/source/load_tilejson.js +0 -39
- package/src/source/mbtiles_source.js +0 -115
- package/src/source/offline_database.js +0 -61
- package/src/source/offline_database_root.js +0 -62
- package/src/source/pixels_to_tile_units.js +0 -21
- package/src/source/query_features.js +0 -208
- package/src/source/raster_dem_tile_source.js +0 -138
- package/src/source/raster_dem_tile_worker_source.js +0 -62
- package/src/source/raster_tile_offline_source.js +0 -136
- package/src/source/raster_tile_source.js +0 -177
- package/src/source/rtl_text_plugin.js +0 -138
- package/src/source/source.js +0 -137
- package/src/source/source_cache.js +0 -957
- package/src/source/source_state.js +0 -159
- package/src/source/tile.js +0 -465
- package/src/source/tile_bounds.js +0 -38
- package/src/source/tile_cache.js +0 -212
- package/src/source/tile_id.js +0 -402
- package/src/source/vector_tile_source.js +0 -192
- package/src/source/vector_tile_worker_source.js +0 -216
- package/src/source/video_source.js +0 -203
- package/src/source/worker.js +0 -237
- package/src/source/worker_source.js +0 -106
- package/src/source/worker_tile.js +0 -224
- package/src/style/create_style_layer.js +0 -36
- package/src/style/evaluation_parameters.js +0 -62
- package/src/style/light.js +0 -130
- package/src/style/load_glyph_range.js +0 -38
- package/src/style/load_sprite.js +0 -67
- package/src/style/parse_glyph_pbf.js +0 -44
- package/src/style/pauseable_placement.js +0 -132
- package/src/style/properties.js +0 -753
- package/src/style/query_utils.js +0 -43
- package/src/style/style.js +0 -1361
- package/src/style/style_glyph.js +0 -17
- package/src/style/style_image.js +0 -137
- package/src/style/style_layer/background_style_layer.js +0 -21
- package/src/style/style_layer/background_style_layer_properties.js +0 -40
- package/src/style/style_layer/circle_style_layer.js +0 -98
- package/src/style/style_layer/circle_style_layer_properties.js +0 -63
- package/src/style/style_layer/custom_style_layer.js +0 -223
- package/src/style/style_layer/fill_extrusion_style_layer.js +0 -224
- package/src/style/style_layer/fill_extrusion_style_layer_properties.js +0 -50
- package/src/style/style_layer/fill_style_layer.js +0 -67
- package/src/style/style_layer/fill_style_layer_properties.js +0 -55
- package/src/style/style_layer/heatmap_style_layer.js +0 -69
- package/src/style/style_layer/heatmap_style_layer_properties.js +0 -44
- package/src/style/style_layer/hillshade_style_layer.js +0 -25
- package/src/style/style_layer/hillshade_style_layer_properties.js +0 -46
- package/src/style/style_layer/layer_properties.js.ejs +0 -69
- package/src/style/style_layer/line_style_layer.js +0 -151
- package/src/style/style_layer/line_style_layer_properties.js +0 -71
- package/src/style/style_layer/raster_style_layer.js +0 -21
- package/src/style/style_layer/raster_style_layer_properties.js +0 -50
- package/src/style/style_layer/symbol_style_layer.js +0 -190
- package/src/style/style_layer/symbol_style_layer_properties.js +0 -153
- package/src/style/style_layer/typed_style_layer.js +0 -17
- package/src/style/style_layer.js +0 -281
- package/src/style/style_layer_index.js +0 -80
- package/src/style/validate_style.js +0 -42
- package/src/style/zoom_history.js +0 -44
- package/src/style-spec/.eslintrc +0 -5
- package/src/style-spec/CHANGELOG.md +0 -438
- package/src/style-spec/README.md +0 -59
- package/src/style-spec/bin/gl-style-composite +0 -9
- package/src/style-spec/bin/gl-style-format +0 -22
- package/src/style-spec/bin/gl-style-migrate +0 -9
- package/src/style-spec/bin/gl-style-validate +0 -50
- package/src/style-spec/composite.js +0 -50
- package/src/style-spec/declass.js +0 -42
- package/src/style-spec/deref.js +0 -52
- package/src/style-spec/diff.js +0 -393
- package/src/style-spec/dist/.gitkeep +0 -0
- package/src/style-spec/empty.js +0 -29
- package/src/style-spec/error/parsing_error.js +0 -16
- package/src/style-spec/error/validation_error.js +0 -18
- package/src/style-spec/expression/compound_expression.js +0 -162
- package/src/style-spec/expression/definitions/assertion.js +0 -130
- package/src/style-spec/expression/definitions/at.js +0 -70
- package/src/style-spec/expression/definitions/case.js +0 -85
- package/src/style-spec/expression/definitions/coalesce.js +0 -93
- package/src/style-spec/expression/definitions/coercion.js +0 -133
- package/src/style-spec/expression/definitions/collator.js +0 -78
- package/src/style-spec/expression/definitions/comparison.js +0 -184
- package/src/style-spec/expression/definitions/format.js +0 -144
- package/src/style-spec/expression/definitions/format_section_override.js +0 -54
- package/src/style-spec/expression/definitions/image.js +0 -52
- package/src/style-spec/expression/definitions/in.js +0 -92
- package/src/style-spec/expression/definitions/index.js +0 -561
- package/src/style-spec/expression/definitions/interpolate.js +0 -267
- package/src/style-spec/expression/definitions/length.js +0 -61
- package/src/style-spec/expression/definitions/let.js +0 -72
- package/src/style-spec/expression/definitions/literal.js +0 -77
- package/src/style-spec/expression/definitions/match.js +0 -158
- package/src/style-spec/expression/definitions/number_format.js +0 -142
- package/src/style-spec/expression/definitions/step.js +0 -120
- package/src/style-spec/expression/definitions/var.js +0 -46
- package/src/style-spec/expression/definitions/within.js +0 -333
- package/src/style-spec/expression/evaluation_context.js +0 -59
- package/src/style-spec/expression/expression.js +0 -27
- package/src/style-spec/expression/index.js +0 -392
- package/src/style-spec/expression/is_constant.js +0 -59
- package/src/style-spec/expression/parsing_context.js +0 -233
- package/src/style-spec/expression/parsing_error.js +0 -13
- package/src/style-spec/expression/runtime_error.js +0 -17
- package/src/style-spec/expression/scope.js +0 -36
- package/src/style-spec/expression/stops.js +0 -39
- package/src/style-spec/expression/types/collator.js +0 -61
- package/src/style-spec/expression/types/formatted.js +0 -73
- package/src/style-spec/expression/types/resolved_image.js +0 -29
- package/src/style-spec/expression/types.js +0 -106
- package/src/style-spec/expression/values.js +0 -123
- package/src/style-spec/feature_filter/README.md +0 -55
- package/src/style-spec/feature_filter/convert.js +0 -208
- package/src/style-spec/feature_filter/index.js +0 -165
- package/src/style-spec/format.js +0 -51
- package/src/style-spec/function/convert.js +0 -254
- package/src/style-spec/function/index.js +0 -262
- package/src/style-spec/group_by_layout.js +0 -75
- package/src/style-spec/migrate/expressions.js +0 -39
- package/src/style-spec/migrate/v8.js +0 -203
- package/src/style-spec/migrate/v9.js +0 -26
- package/src/style-spec/migrate.js +0 -36
- package/src/style-spec/package.json +0 -41
- package/src/style-spec/read_style.js +0 -14
- package/src/style-spec/reference/latest.js +0 -3
- package/src/style-spec/reference/v8.json +0 -5808
- package/src/style-spec/rollup.config.js +0 -45
- package/src/style-spec/style-spec.js +0 -122
- package/src/style-spec/types.js +0 -438
- package/src/style-spec/util/color.js +0 -95
- package/src/style-spec/util/color_spaces.js +0 -139
- package/src/style-spec/util/deep_equal.js +0 -28
- package/src/style-spec/util/extend.js +0 -10
- package/src/style-spec/util/get_type.js +0 -17
- package/src/style-spec/util/interpolate.js +0 -22
- package/src/style-spec/util/properties.js +0 -15
- package/src/style-spec/util/ref_properties.js +0 -2
- package/src/style-spec/util/result.js +0 -19
- package/src/style-spec/util/unbundle_jsonlint.js +0 -24
- package/src/style-spec/validate/latest.js +0 -11
- package/src/style-spec/validate/validate.js +0 -75
- package/src/style-spec/validate/validate_array.js +0 -52
- package/src/style-spec/validate/validate_boolean.js +0 -15
- package/src/style-spec/validate/validate_color.js +0 -20
- package/src/style-spec/validate/validate_constants.js +0 -13
- package/src/style-spec/validate/validate_enum.js +0 -21
- package/src/style-spec/validate/validate_expression.js +0 -43
- package/src/style-spec/validate/validate_filter.js +0 -111
- package/src/style-spec/validate/validate_formatted.js +0 -11
- package/src/style-spec/validate/validate_function.js +0 -207
- package/src/style-spec/validate/validate_glyphs_url.js +0 -21
- package/src/style-spec/validate/validate_image.js +0 -11
- package/src/style-spec/validate/validate_layer.js +0 -134
- package/src/style-spec/validate/validate_layout_property.js +0 -6
- package/src/style-spec/validate/validate_light.js +0 -47
- package/src/style-spec/validate/validate_number.js +0 -29
- package/src/style-spec/validate/validate_object.js +0 -61
- package/src/style-spec/validate/validate_paint_property.js +0 -6
- package/src/style-spec/validate/validate_property.js +0 -64
- package/src/style-spec/validate/validate_source.js +0 -111
- package/src/style-spec/validate/validate_string.js +0 -15
- package/src/style-spec/validate_mapbox_api_supported.js +0 -171
- package/src/style-spec/validate_style.js +0 -39
- package/src/style-spec/validate_style.min.js +0 -78
- package/src/style-spec/visit.js +0 -77
- package/src/symbol/anchor.js +0 -26
- package/src/symbol/check_max_angle.js +0 -81
- package/src/symbol/clip_line.js +0 -71
- package/src/symbol/collision_feature.js +0 -217
- package/src/symbol/collision_index.js +0 -372
- package/src/symbol/cross_tile_symbol_index.js +0 -301
- package/src/symbol/get_anchors.js +0 -167
- package/src/symbol/grid_index.js +0 -335
- package/src/symbol/mergelines.js +0 -82
- package/src/symbol/one_em.js +0 -4
- package/src/symbol/opacity_state.js +0 -27
- package/src/symbol/placement.js +0 -1062
- package/src/symbol/projection.js +0 -450
- package/src/symbol/quads.js +0 -334
- package/src/symbol/shaping.js +0 -816
- package/src/symbol/symbol_layout.js +0 -772
- package/src/symbol/symbol_size.js +0 -113
- package/src/symbol/transform_text.js +0 -29
- package/src/types/callback.js +0 -17
- package/src/types/cancelable.js +0 -3
- package/src/types/tilejson.js +0 -17
- package/src/types/transferable.js +0 -3
- package/src/types/window.js +0 -172
- package/src/ui/anchor.js +0 -32
- package/src/ui/bind_handlers.js +0 -202
- package/src/ui/camera.js +0 -1152
- package/src/ui/control/attribution_control.js +0 -189
- package/src/ui/control/fps_control.js +0 -185
- package/src/ui/control/fullscreen_control.js +0 -147
- package/src/ui/control/geolocate_control.js +0 -594
- package/src/ui/control/logo_control.js +0 -92
- package/src/ui/control/navigation_control.js +0 -148
- package/src/ui/control/scale_control.js +0 -142
- package/src/ui/crs.js +0 -64
- package/src/ui/default_locale.js +0 -20
- package/src/ui/events.js +0 -806
- package/src/ui/handler/box_zoom.js +0 -175
- package/src/ui/handler/dblclick_zoom.js +0 -139
- package/src/ui/handler/drag_pan.js +0 -416
- package/src/ui/handler/drag_rotate.js +0 -378
- package/src/ui/handler/keyboard.js +0 -161
- package/src/ui/handler/scroll_zoom.js +0 -333
- package/src/ui/handler/touch_zoom_rotate.js +0 -293
- package/src/ui/hash.js +0 -147
- package/src/ui/map.js +0 -2883
- package/src/ui/marker.js +0 -607
- package/src/ui/offline_map.js +0 -91
- package/src/ui/popup.js +0 -530
- package/src/util/actor.js +0 -212
- package/src/util/ajax.js +0 -371
- package/src/util/browser/web_worker.js +0 -10
- package/src/util/browser/window.js +0 -5
- package/src/util/browser.js +0 -70
- package/src/util/classify_rings.js +0 -52
- package/src/util/color_ramp.js +0 -28
- package/src/util/config.js +0 -30
- package/src/util/debug.js +0 -12
- package/src/util/dictionary_coder.js +0 -30
- package/src/util/dispatcher.js +0 -70
- package/src/util/dom.js +0 -144
- package/src/util/evented.js +0 -174
- package/src/util/find_pole_of_inaccessibility.js +0 -129
- package/src/util/global_worker_pool.js +0 -17
- package/src/util/image.js +0 -142
- package/src/util/intersection_tests.js +0 -208
- package/src/util/is_char_in_unicode_block.js +0 -311
- package/src/util/mapbox.js +0 -486
- package/src/util/offscreen_canvas_supported.js +0 -14
- package/src/util/performance.js +0 -112
- package/src/util/primitives.js +0 -145
- package/src/util/resolve_tokens.js +0 -16
- package/src/util/script_detection.js +0 -328
- package/src/util/sku_token.js +0 -42
- package/src/util/smart_wrap.js +0 -55
- package/src/util/struct_array.js +0 -243
- package/src/util/struct_array.js.ejs +0 -112
- package/src/util/struct_array_layout.js.ejs +0 -98
- package/src/util/task_queue.js +0 -68
- package/src/util/throttle.js +0 -28
- package/src/util/throttled_invoker.js +0 -46
- package/src/util/tile_cover.js +0 -101
- package/src/util/tile_request_cache.js +0 -172
- package/src/util/util.js +0 -504
- package/src/util/vectortile_to_geojson.js +0 -54
- package/src/util/verticalize_punctuation.js +0 -114
- package/src/util/web_worker.js +0 -91
- package/src/util/web_worker_transfer.js +0 -266
- package/src/util/webp_supported.js +0 -69
- package/src/util/window.js +0 -102
- package/src/util/worker_pool.js +0 -47
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import {StringType, NumberType} from '../types';
|
|
4
|
-
|
|
5
|
-
import type {Expression} from '../expression';
|
|
6
|
-
import type EvaluationContext from '../evaluation_context';
|
|
7
|
-
import type ParsingContext from '../parsing_context';
|
|
8
|
-
import type {Type} from '../types';
|
|
9
|
-
|
|
10
|
-
declare var Intl: {
|
|
11
|
-
NumberFormat: Class<Intl$NumberFormat>
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
declare class Intl$NumberFormat {
|
|
15
|
-
constructor (
|
|
16
|
-
locales?: string | string[],
|
|
17
|
-
options?: NumberFormatOptions
|
|
18
|
-
): Intl$NumberFormat;
|
|
19
|
-
|
|
20
|
-
static (
|
|
21
|
-
locales?: string | string[],
|
|
22
|
-
options?: NumberFormatOptions
|
|
23
|
-
): Intl$NumberFormat;
|
|
24
|
-
|
|
25
|
-
format(a: number): string;
|
|
26
|
-
|
|
27
|
-
resolvedOptions(): any;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
type NumberFormatOptions = {
|
|
31
|
-
style?: 'decimal' | 'currency' | 'percent';
|
|
32
|
-
currency?: null | string;
|
|
33
|
-
minimumFractionDigits?: null | string;
|
|
34
|
-
maximumFractionDigits?: null | string;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default class NumberFormat implements Expression {
|
|
38
|
-
type: Type;
|
|
39
|
-
number: Expression;
|
|
40
|
-
locale: Expression | null; // BCP 47 language tag
|
|
41
|
-
currency: Expression | null; // ISO 4217 currency code, required if style=currency
|
|
42
|
-
minFractionDigits: Expression | null; // Default 0
|
|
43
|
-
maxFractionDigits: Expression | null; // Default 3
|
|
44
|
-
|
|
45
|
-
constructor(number: Expression,
|
|
46
|
-
locale: Expression | null,
|
|
47
|
-
currency: Expression | null,
|
|
48
|
-
minFractionDigits: Expression | null,
|
|
49
|
-
maxFractionDigits: Expression | null) {
|
|
50
|
-
this.type = StringType;
|
|
51
|
-
this.number = number;
|
|
52
|
-
this.locale = locale;
|
|
53
|
-
this.currency = currency;
|
|
54
|
-
this.minFractionDigits = minFractionDigits;
|
|
55
|
-
this.maxFractionDigits = maxFractionDigits;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
static parse(args: $ReadOnlyArray<mixed>, context: ParsingContext): ?Expression {
|
|
59
|
-
if (args.length !== 3)
|
|
60
|
-
return context.error(`Expected two arguments.`);
|
|
61
|
-
|
|
62
|
-
const number = context.parse(args[1], 1, NumberType);
|
|
63
|
-
if (!number) return null;
|
|
64
|
-
|
|
65
|
-
const options = (args[2]: any);
|
|
66
|
-
if (typeof options !== "object" || Array.isArray(options))
|
|
67
|
-
return context.error(`NumberFormat options argument must be an object.`);
|
|
68
|
-
|
|
69
|
-
let locale = null;
|
|
70
|
-
if (options['locale']) {
|
|
71
|
-
locale = context.parse(options['locale'], 1, StringType);
|
|
72
|
-
if (!locale) return null;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
let currency = null;
|
|
76
|
-
if (options['currency']) {
|
|
77
|
-
currency = context.parse(options['currency'], 1, StringType);
|
|
78
|
-
if (!currency) return null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
let minFractionDigits = null;
|
|
82
|
-
if (options['min-fraction-digits']) {
|
|
83
|
-
minFractionDigits = context.parse(options['min-fraction-digits'], 1, NumberType);
|
|
84
|
-
if (!minFractionDigits) return null;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
let maxFractionDigits = null;
|
|
88
|
-
if (options['max-fraction-digits']) {
|
|
89
|
-
maxFractionDigits = context.parse(options['max-fraction-digits'], 1, NumberType);
|
|
90
|
-
if (!maxFractionDigits) return null;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return new NumberFormat(number, locale, currency, minFractionDigits, maxFractionDigits);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
evaluate(ctx: EvaluationContext) {
|
|
97
|
-
return new Intl.NumberFormat(this.locale ? this.locale.evaluate(ctx) : [],
|
|
98
|
-
{
|
|
99
|
-
style: this.currency ? "currency" : "decimal",
|
|
100
|
-
currency: this.currency ? this.currency.evaluate(ctx) : undefined,
|
|
101
|
-
minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(ctx) : undefined,
|
|
102
|
-
maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(ctx) : undefined,
|
|
103
|
-
}).format(this.number.evaluate(ctx));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
eachChild(fn: (_: Expression) => void) {
|
|
107
|
-
fn(this.number);
|
|
108
|
-
if (this.locale) {
|
|
109
|
-
fn(this.locale);
|
|
110
|
-
}
|
|
111
|
-
if (this.currency) {
|
|
112
|
-
fn(this.currency);
|
|
113
|
-
}
|
|
114
|
-
if (this.minFractionDigits) {
|
|
115
|
-
fn(this.minFractionDigits);
|
|
116
|
-
}
|
|
117
|
-
if (this.maxFractionDigits) {
|
|
118
|
-
fn(this.maxFractionDigits);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
outputDefined() {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
serialize() {
|
|
127
|
-
const options = {};
|
|
128
|
-
if (this.locale) {
|
|
129
|
-
options['locale'] = this.locale.serialize();
|
|
130
|
-
}
|
|
131
|
-
if (this.currency) {
|
|
132
|
-
options['currency'] = this.currency.serialize();
|
|
133
|
-
}
|
|
134
|
-
if (this.minFractionDigits) {
|
|
135
|
-
options['min-fraction-digits'] = this.minFractionDigits.serialize();
|
|
136
|
-
}
|
|
137
|
-
if (this.maxFractionDigits) {
|
|
138
|
-
options['max-fraction-digits'] = this.maxFractionDigits.serialize();
|
|
139
|
-
}
|
|
140
|
-
return ["number-format", this.number.serialize(), options];
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import {NumberType} from '../types';
|
|
4
|
-
|
|
5
|
-
import {findStopLessThanOrEqualTo} from '../stops';
|
|
6
|
-
|
|
7
|
-
import type {Stops} from '../stops';
|
|
8
|
-
import type {Expression} from '../expression';
|
|
9
|
-
import type ParsingContext from '../parsing_context';
|
|
10
|
-
import type EvaluationContext from '../evaluation_context';
|
|
11
|
-
import type {Type} from '../types';
|
|
12
|
-
|
|
13
|
-
class Step implements Expression {
|
|
14
|
-
type: Type;
|
|
15
|
-
|
|
16
|
-
input: Expression;
|
|
17
|
-
labels: Array<number>;
|
|
18
|
-
outputs: Array<Expression>;
|
|
19
|
-
|
|
20
|
-
constructor(type: Type, input: Expression, stops: Stops) {
|
|
21
|
-
this.type = type;
|
|
22
|
-
this.input = input;
|
|
23
|
-
|
|
24
|
-
this.labels = [];
|
|
25
|
-
this.outputs = [];
|
|
26
|
-
for (const [label, expression] of stops) {
|
|
27
|
-
this.labels.push(label);
|
|
28
|
-
this.outputs.push(expression);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
static parse(args: $ReadOnlyArray<mixed>, context: ParsingContext) {
|
|
33
|
-
if (args.length - 1 < 4) {
|
|
34
|
-
return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if ((args.length - 1) % 2 !== 0) {
|
|
38
|
-
return context.error(`Expected an even number of arguments.`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const input = context.parse(args[1], 1, NumberType);
|
|
42
|
-
if (!input) return null;
|
|
43
|
-
|
|
44
|
-
const stops: Stops = [];
|
|
45
|
-
|
|
46
|
-
let outputType: Type = (null: any);
|
|
47
|
-
if (context.expectedType && context.expectedType.kind !== 'value') {
|
|
48
|
-
outputType = context.expectedType;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
for (let i = 1; i < args.length; i += 2) {
|
|
52
|
-
const label = i === 1 ? -Infinity : args[i];
|
|
53
|
-
const value = args[i + 1];
|
|
54
|
-
|
|
55
|
-
const labelKey = i;
|
|
56
|
-
const valueKey = i + 1;
|
|
57
|
-
|
|
58
|
-
if (typeof label !== 'number') {
|
|
59
|
-
return context.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (stops.length && stops[stops.length - 1][0] >= label) {
|
|
63
|
-
return context.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.', labelKey);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const parsed = context.parse(value, valueKey, outputType);
|
|
67
|
-
if (!parsed) return null;
|
|
68
|
-
outputType = outputType || parsed.type;
|
|
69
|
-
stops.push([label, parsed]);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return new Step(outputType, input, stops);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
evaluate(ctx: EvaluationContext) {
|
|
76
|
-
const labels = this.labels;
|
|
77
|
-
const outputs = this.outputs;
|
|
78
|
-
|
|
79
|
-
if (labels.length === 1) {
|
|
80
|
-
return outputs[0].evaluate(ctx);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const value = ((this.input.evaluate(ctx): any): number);
|
|
84
|
-
if (value <= labels[0]) {
|
|
85
|
-
return outputs[0].evaluate(ctx);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const stopCount = labels.length;
|
|
89
|
-
if (value >= labels[stopCount - 1]) {
|
|
90
|
-
return outputs[stopCount - 1].evaluate(ctx);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const index = findStopLessThanOrEqualTo(labels, value);
|
|
94
|
-
return outputs[index].evaluate(ctx);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
eachChild(fn: (_: Expression) => void) {
|
|
98
|
-
fn(this.input);
|
|
99
|
-
for (const expression of this.outputs) {
|
|
100
|
-
fn(expression);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
outputDefined(): boolean {
|
|
105
|
-
return this.outputs.every(out => out.outputDefined());
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
serialize() {
|
|
109
|
-
const serialized = ["step", this.input.serialize()];
|
|
110
|
-
for (let i = 0; i < this.labels.length; i++) {
|
|
111
|
-
if (i > 0) {
|
|
112
|
-
serialized.push(this.labels[i]);
|
|
113
|
-
}
|
|
114
|
-
serialized.push(this.outputs[i].serialize());
|
|
115
|
-
}
|
|
116
|
-
return serialized;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export default Step;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import type {Type} from '../types';
|
|
4
|
-
import type {Expression} from '../expression';
|
|
5
|
-
import type ParsingContext from '../parsing_context';
|
|
6
|
-
import type EvaluationContext from '../evaluation_context';
|
|
7
|
-
|
|
8
|
-
class Var implements Expression {
|
|
9
|
-
type: Type;
|
|
10
|
-
name: string;
|
|
11
|
-
boundExpression: Expression;
|
|
12
|
-
|
|
13
|
-
constructor(name: string, boundExpression: Expression) {
|
|
14
|
-
this.type = boundExpression.type;
|
|
15
|
-
this.name = name;
|
|
16
|
-
this.boundExpression = boundExpression;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static parse(args: $ReadOnlyArray<mixed>, context: ParsingContext) {
|
|
20
|
-
if (args.length !== 2 || typeof args[1] !== 'string')
|
|
21
|
-
return context.error(`'var' expression requires exactly one string literal argument.`);
|
|
22
|
-
|
|
23
|
-
const name = args[1];
|
|
24
|
-
if (!context.scope.has(name)) {
|
|
25
|
-
return context.error(`Unknown variable "${name}". Make sure "${name}" has been bound in an enclosing "let" expression before using it.`, 1);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return new Var(name, context.scope.get(name));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
evaluate(ctx: EvaluationContext) {
|
|
32
|
-
return this.boundExpression.evaluate(ctx);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
eachChild() {}
|
|
36
|
-
|
|
37
|
-
outputDefined() {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
serialize() {
|
|
42
|
-
return ["var", this.name];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export default Var;
|
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import {isValue} from '../values';
|
|
4
|
-
import type {Type} from '../types';
|
|
5
|
-
import {BooleanType} from '../types';
|
|
6
|
-
import type {Expression} from '../expression';
|
|
7
|
-
import type ParsingContext from '../parsing_context';
|
|
8
|
-
import type EvaluationContext from '../evaluation_context';
|
|
9
|
-
import type {GeoJSON, GeoJSONPolygon, GeoJSONMultiPolygon} from '@mapbox/geojson-types';
|
|
10
|
-
import MercatorCoordinate from '../../../geo/mercator_coordinate';
|
|
11
|
-
import EXTENT from '../../../data/extent';
|
|
12
|
-
import Point from '@mapbox/point-geometry';
|
|
13
|
-
import type {CanonicalTileID} from '../../../source/tile_id';
|
|
14
|
-
|
|
15
|
-
type GeoJSONPolygons =| GeoJSONPolygon | GeoJSONMultiPolygon;
|
|
16
|
-
|
|
17
|
-
// minX, minY, maxX, maxY
|
|
18
|
-
type BBox = [number, number, number, number];
|
|
19
|
-
function updateBBox(bbox: BBox, coord: Point) {
|
|
20
|
-
bbox[0] = Math.min(bbox[0], coord[0]);
|
|
21
|
-
bbox[1] = Math.min(bbox[1], coord[1]);
|
|
22
|
-
bbox[2] = Math.max(bbox[2], coord[0]);
|
|
23
|
-
bbox[3] = Math.max(bbox[3], coord[1]);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function boxWithinBox(bbox1: BBox, bbox2: BBox) {
|
|
27
|
-
if (bbox1[0] <= bbox2[0]) return false;
|
|
28
|
-
if (bbox1[2] >= bbox2[2]) return false;
|
|
29
|
-
if (bbox1[1] <= bbox2[1]) return false;
|
|
30
|
-
if (bbox1[3] >= bbox2[3]) return false;
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function getTileCoordinates(p, canonical: CanonicalTileID) {
|
|
35
|
-
const coord = MercatorCoordinate.fromLngLat({lng: p[0], lat: p[1]}, 0);
|
|
36
|
-
const tilesAtZoom = Math.pow(2, canonical.z);
|
|
37
|
-
return [Math.round(coord.x * tilesAtZoom * EXTENT), Math.round(coord.y * tilesAtZoom * EXTENT)];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function onBoundary(p, p1, p2) {
|
|
41
|
-
const x1 = p[0] - p1[0];
|
|
42
|
-
const y1 = p[1] - p1[1];
|
|
43
|
-
const x2 = p[0] - p2[0];
|
|
44
|
-
const y2 = p[1] - p2[1];
|
|
45
|
-
return (x1 * y2 - x2 * y1 === 0) && (x1 * x2 <= 0) && (y1 * y2 <= 0);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function rayIntersect(p, p1, p2) {
|
|
49
|
-
return ((p1[1] > p[1]) !== (p2[1] > p[1])) && (p[0] < (p2[0] - p1[0]) * (p[1] - p1[1]) / (p2[1] - p1[1]) + p1[0]);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// ray casting algorithm for detecting if point is in polygon
|
|
53
|
-
function pointWithinPolygon(point, rings) {
|
|
54
|
-
let inside = false;
|
|
55
|
-
for (let i = 0, len = rings.length; i < len; i++) {
|
|
56
|
-
const ring = rings[i];
|
|
57
|
-
for (let j = 0, len2 = ring.length; j < len2 - 1; j++) {
|
|
58
|
-
if (onBoundary(point, ring[j], ring[j + 1])) return false;
|
|
59
|
-
if (rayIntersect(point, ring[j], ring[j + 1])) inside = !inside;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return inside;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function pointWithinPolygons(point, polygons) {
|
|
66
|
-
for (let i = 0; i < polygons.length; i++) {
|
|
67
|
-
if (pointWithinPolygon(point, polygons[i])) return true;
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function perp(v1, v2) {
|
|
73
|
-
return (v1[0] * v2[1] - v1[1] * v2[0]);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// check if p1 and p2 are in different sides of line segment q1->q2
|
|
77
|
-
function twoSided(p1, p2, q1, q2) {
|
|
78
|
-
// q1->p1 (x1, y1), q1->p2 (x2, y2), q1->q2 (x3, y3)
|
|
79
|
-
const x1 = p1[0] - q1[0];
|
|
80
|
-
const y1 = p1[1] - q1[1];
|
|
81
|
-
const x2 = p2[0] - q1[0];
|
|
82
|
-
const y2 = p2[1] - q1[1];
|
|
83
|
-
const x3 = q2[0] - q1[0];
|
|
84
|
-
const y3 = q2[1] - q1[1];
|
|
85
|
-
const det1 = (x1 * y3 - x3 * y1);
|
|
86
|
-
const det2 = (x2 * y3 - x3 * y2);
|
|
87
|
-
if ((det1 > 0 && det2 < 0) || (det1 < 0 && det2 > 0)) return true;
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
// a, b are end points for line segment1, c and d are end points for line segment2
|
|
91
|
-
function lineIntersectLine(a, b, c, d) {
|
|
92
|
-
// check if two segments are parallel or not
|
|
93
|
-
// precondition is end point a, b is inside polygon, if line a->b is
|
|
94
|
-
// parallel to polygon edge c->d, then a->b won't intersect with c->d
|
|
95
|
-
const vectorP = [b[0] - a[0], b[1] - a[1]];
|
|
96
|
-
const vectorQ = [d[0] - c[0], d[1] - c[1]];
|
|
97
|
-
if (perp(vectorQ, vectorP) === 0) return false;
|
|
98
|
-
|
|
99
|
-
// If lines are intersecting with each other, the relative location should be:
|
|
100
|
-
// a and b lie in different sides of segment c->d
|
|
101
|
-
// c and d lie in different sides of segment a->b
|
|
102
|
-
if (twoSided(a, b, c, d) && twoSided(c, d, a, b)) return true;
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function lineIntersectPolygon(p1, p2, polygon) {
|
|
107
|
-
for (const ring of polygon) {
|
|
108
|
-
// loop through every edge of the ring
|
|
109
|
-
for (let j = 0; j < ring.length - 1; ++j) {
|
|
110
|
-
if (lineIntersectLine(p1, p2, ring[j], ring[j + 1])) {
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function lineStringWithinPolygon(line, polygon) {
|
|
119
|
-
// First, check if geometry points of line segments are all inside polygon
|
|
120
|
-
for (let i = 0; i < line.length; ++i) {
|
|
121
|
-
if (!pointWithinPolygon(line[i], polygon)) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Second, check if there is line segment intersecting polygon edge
|
|
127
|
-
for (let i = 0; i < line.length - 1; ++i) {
|
|
128
|
-
if (lineIntersectPolygon(line[i], line[i + 1], polygon)) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function lineStringWithinPolygons(line, polygons) {
|
|
136
|
-
for (let i = 0; i < polygons.length; i++) {
|
|
137
|
-
if (lineStringWithinPolygon(line, polygons[i])) return true;
|
|
138
|
-
}
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function getTilePolygon(coordinates, bbox, canonical) {
|
|
143
|
-
const polygon = [];
|
|
144
|
-
for (let i = 0; i < coordinates.length; i++) {
|
|
145
|
-
const ring = [];
|
|
146
|
-
for (let j = 0; j < coordinates[i].length; j++) {
|
|
147
|
-
const coord = getTileCoordinates(coordinates[i][j], canonical);
|
|
148
|
-
updateBBox(bbox, coord);
|
|
149
|
-
ring.push(coord);
|
|
150
|
-
}
|
|
151
|
-
polygon.push(ring);
|
|
152
|
-
}
|
|
153
|
-
return polygon;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function getTilePolygons(coordinates, bbox, canonical) {
|
|
157
|
-
const polygons = [];
|
|
158
|
-
for (let i = 0; i < coordinates.length; i++) {
|
|
159
|
-
const polygon = getTilePolygon(coordinates[i], bbox, canonical);
|
|
160
|
-
polygons.push(polygon);
|
|
161
|
-
}
|
|
162
|
-
return polygons;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function updatePoint(p, bbox, polyBBox, worldSize) {
|
|
166
|
-
if (p[0] < polyBBox[0] || p[0] > polyBBox[2]) {
|
|
167
|
-
const halfWorldSize = worldSize * 0.5;
|
|
168
|
-
let shift = (p[0] - polyBBox[0] > halfWorldSize) ? -worldSize : (polyBBox[0] - p[0] > halfWorldSize) ? worldSize : 0;
|
|
169
|
-
if (shift === 0) {
|
|
170
|
-
shift = (p[0] - polyBBox[2] > halfWorldSize) ? -worldSize : (polyBBox[2] - p[0] > halfWorldSize) ? worldSize : 0;
|
|
171
|
-
}
|
|
172
|
-
p[0] += shift;
|
|
173
|
-
}
|
|
174
|
-
updateBBox(bbox, p);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function resetBBox(bbox) {
|
|
178
|
-
bbox[0] = bbox[1] = Infinity;
|
|
179
|
-
bbox[2] = bbox[3] = -Infinity;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function getTilePoints(geometry, pointBBox, polyBBox, canonical) {
|
|
183
|
-
const worldSize = Math.pow(2, canonical.z) * EXTENT;
|
|
184
|
-
const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];
|
|
185
|
-
const tilePoints = [];
|
|
186
|
-
for (const points of geometry) {
|
|
187
|
-
for (const point of points) {
|
|
188
|
-
const p = [point.x + shifts[0], point.y + shifts[1]];
|
|
189
|
-
updatePoint(p, pointBBox, polyBBox, worldSize);
|
|
190
|
-
tilePoints.push(p);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return tilePoints;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function getTileLines(geometry, lineBBox, polyBBox, canonical) {
|
|
197
|
-
const worldSize = Math.pow(2, canonical.z) * EXTENT;
|
|
198
|
-
const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];
|
|
199
|
-
const tileLines = [];
|
|
200
|
-
for (const line of geometry) {
|
|
201
|
-
const tileLine = [];
|
|
202
|
-
for (const point of line) {
|
|
203
|
-
const p = [point.x + shifts[0], point.y + shifts[1]];
|
|
204
|
-
updateBBox(lineBBox, p);
|
|
205
|
-
tileLine.push(p);
|
|
206
|
-
}
|
|
207
|
-
tileLines.push(tileLine);
|
|
208
|
-
}
|
|
209
|
-
if (lineBBox[2] - lineBBox[0] <= worldSize / 2) {
|
|
210
|
-
resetBBox(lineBBox);
|
|
211
|
-
for (const line of tileLines) {
|
|
212
|
-
for (const p of line) {
|
|
213
|
-
updatePoint(p, lineBBox, polyBBox, worldSize);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return tileLines;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function pointsWithinPolygons(ctx: EvaluationContext, polygonGeometry: GeoJSONPolygons) {
|
|
221
|
-
const pointBBox = [Infinity, Infinity, -Infinity, -Infinity];
|
|
222
|
-
const polyBBox = [Infinity, Infinity, -Infinity, -Infinity];
|
|
223
|
-
|
|
224
|
-
const canonical = ctx.canonicalID();
|
|
225
|
-
|
|
226
|
-
if (polygonGeometry.type === 'Polygon') {
|
|
227
|
-
const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);
|
|
228
|
-
const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);
|
|
229
|
-
if (!boxWithinBox(pointBBox, polyBBox)) return false;
|
|
230
|
-
|
|
231
|
-
for (const point of tilePoints) {
|
|
232
|
-
if (!pointWithinPolygon(point, tilePolygon)) return false;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
if (polygonGeometry.type === 'MultiPolygon') {
|
|
236
|
-
const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);
|
|
237
|
-
const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);
|
|
238
|
-
if (!boxWithinBox(pointBBox, polyBBox)) return false;
|
|
239
|
-
|
|
240
|
-
for (const point of tilePoints) {
|
|
241
|
-
if (!pointWithinPolygons(point, tilePolygons)) return false;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return true;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function linesWithinPolygons(ctx: EvaluationContext, polygonGeometry: GeoJSONPolygons) {
|
|
249
|
-
const lineBBox = [Infinity, Infinity, -Infinity, -Infinity];
|
|
250
|
-
const polyBBox = [Infinity, Infinity, -Infinity, -Infinity];
|
|
251
|
-
|
|
252
|
-
const canonical = ctx.canonicalID();
|
|
253
|
-
|
|
254
|
-
if (polygonGeometry.type === 'Polygon') {
|
|
255
|
-
const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);
|
|
256
|
-
const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);
|
|
257
|
-
if (!boxWithinBox(lineBBox, polyBBox)) return false;
|
|
258
|
-
|
|
259
|
-
for (const line of tileLines) {
|
|
260
|
-
if (!lineStringWithinPolygon(line, tilePolygon)) return false;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
if (polygonGeometry.type === 'MultiPolygon') {
|
|
264
|
-
const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);
|
|
265
|
-
const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);
|
|
266
|
-
if (!boxWithinBox(lineBBox, polyBBox)) return false;
|
|
267
|
-
|
|
268
|
-
for (const line of tileLines) {
|
|
269
|
-
if (!lineStringWithinPolygons(line, tilePolygons)) return false;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return true;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
class Within implements Expression {
|
|
276
|
-
type: Type;
|
|
277
|
-
geojson: GeoJSON
|
|
278
|
-
geometries: GeoJSONPolygons;
|
|
279
|
-
|
|
280
|
-
constructor(geojson: GeoJSON, geometries: GeoJSONPolygons) {
|
|
281
|
-
this.type = BooleanType;
|
|
282
|
-
this.geojson = geojson;
|
|
283
|
-
this.geometries = geometries;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
static parse(args: $ReadOnlyArray<mixed>, context: ParsingContext) {
|
|
287
|
-
if (args.length !== 2)
|
|
288
|
-
return context.error(`'within' expression requires exactly one argument, but found ${args.length - 1} instead.`);
|
|
289
|
-
if (isValue(args[1])) {
|
|
290
|
-
const geojson = (args[1]: Object);
|
|
291
|
-
if (geojson.type === 'FeatureCollection') {
|
|
292
|
-
for (let i = 0; i < geojson.features.length; ++i) {
|
|
293
|
-
const type = geojson.features[i].geometry.type;
|
|
294
|
-
if (type === 'Polygon' || type === 'MultiPolygon') {
|
|
295
|
-
return new Within(geojson, geojson.features[i].geometry);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
} else if (geojson.type === 'Feature') {
|
|
299
|
-
const type = geojson.geometry.type;
|
|
300
|
-
if (type === 'Polygon' || type === 'MultiPolygon') {
|
|
301
|
-
return new Within(geojson, geojson.geometry);
|
|
302
|
-
}
|
|
303
|
-
} else if (geojson.type === 'Polygon' || geojson.type === 'MultiPolygon') {
|
|
304
|
-
return new Within(geojson, geojson);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return context.error(`'within' expression requires valid geojson object that contains polygon geometry type.`);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
evaluate(ctx: EvaluationContext) {
|
|
311
|
-
if (ctx.geometry() != null && ctx.canonicalID() != null) {
|
|
312
|
-
if (ctx.geometryType() === 'Point') {
|
|
313
|
-
return pointsWithinPolygons(ctx, this.geometries);
|
|
314
|
-
} else if (ctx.geometryType() === 'LineString') {
|
|
315
|
-
return linesWithinPolygons(ctx, this.geometries);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
return false;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
eachChild() {}
|
|
322
|
-
|
|
323
|
-
outputDefined(): boolean {
|
|
324
|
-
return true;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
serialize(): Array<mixed> {
|
|
328
|
-
return ["within", this.geojson];
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
export default Within;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import {Color} from './values';
|
|
4
|
-
import type {FormattedSection} from './types/formatted';
|
|
5
|
-
import type {GlobalProperties, Feature, FeatureState} from './index';
|
|
6
|
-
import type {CanonicalTileID} from '../../source/tile_id';
|
|
7
|
-
|
|
8
|
-
const geometryTypes = ['Unknown', 'Point', 'LineString', 'Polygon'];
|
|
9
|
-
|
|
10
|
-
class EvaluationContext {
|
|
11
|
-
globals: GlobalProperties;
|
|
12
|
-
feature: ?Feature;
|
|
13
|
-
featureState: ?FeatureState;
|
|
14
|
-
formattedSection: ?FormattedSection;
|
|
15
|
-
availableImages: ?Array<string>;
|
|
16
|
-
canonical: ?CanonicalTileID;
|
|
17
|
-
|
|
18
|
-
_parseColorCache: {[_: string]: ?Color};
|
|
19
|
-
|
|
20
|
-
constructor() {
|
|
21
|
-
this.globals = (null: any);
|
|
22
|
-
this.feature = null;
|
|
23
|
-
this.featureState = null;
|
|
24
|
-
this.formattedSection = null;
|
|
25
|
-
this._parseColorCache = {};
|
|
26
|
-
this.availableImages = null;
|
|
27
|
-
this.canonical = null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
id() {
|
|
31
|
-
return this.feature && 'id' in this.feature ? this.feature.id : null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
geometryType() {
|
|
35
|
-
return this.feature ? typeof this.feature.type === 'number' ? geometryTypes[this.feature.type] : this.feature.type : null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
geometry() {
|
|
39
|
-
return this.feature && 'geometry' in this.feature ? this.feature.geometry : null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
canonicalID() {
|
|
43
|
-
return this.canonical;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
properties() {
|
|
47
|
-
return this.feature && this.feature.properties || {};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
parseColor(input: string): ?Color {
|
|
51
|
-
let cached = this._parseColorCache[input];
|
|
52
|
-
if (!cached) {
|
|
53
|
-
cached = this._parseColorCache[input] = Color.parse(input);
|
|
54
|
-
}
|
|
55
|
-
return cached;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export default EvaluationContext;
|