@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,307 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import {CanonicalTileID} from './tile_id';
|
|
4
|
-
import {Event, ErrorEvent, Evented} from '../util/evented';
|
|
5
|
-
import {getImage, ResourceType} from '../util/ajax';
|
|
6
|
-
import EXTENT from '../data/extent';
|
|
7
|
-
import {RasterBoundsArray} from '../data/array_types';
|
|
8
|
-
import rasterBoundsAttributes from '../data/raster_bounds_attributes';
|
|
9
|
-
import SegmentVector from '../data/segment';
|
|
10
|
-
import Texture from '../render/texture';
|
|
11
|
-
import MercatorCoordinate from '../geo/mercator_coordinate';
|
|
12
|
-
|
|
13
|
-
import type {Source} from './source';
|
|
14
|
-
import type {CanvasSourceSpecification} from './canvas_source';
|
|
15
|
-
import type Map from '../ui/map';
|
|
16
|
-
import type Dispatcher from '../util/dispatcher';
|
|
17
|
-
import type Tile from './tile';
|
|
18
|
-
import type {Callback} from '../types/callback';
|
|
19
|
-
import type VertexBuffer from '../gl/vertex_buffer';
|
|
20
|
-
import type {
|
|
21
|
-
ImageSourceSpecification,
|
|
22
|
-
VideoSourceSpecification
|
|
23
|
-
} from '../style-spec/types';
|
|
24
|
-
|
|
25
|
-
type Coordinates = [[number, number], [number, number], [number, number], [number, number]];
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* A data source containing an image.
|
|
29
|
-
* (See the [Style Specification](https://www.mapbox.com/mapbox-gl-style-spec/#sources-image) for detailed documentation of options.)
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* // add to map
|
|
33
|
-
* map.addSource('some id', {
|
|
34
|
-
* type: 'image',
|
|
35
|
-
* url: 'https://www.mapbox.com/images/foo.png',
|
|
36
|
-
* coordinates: [
|
|
37
|
-
* [-76.54, 39.18],
|
|
38
|
-
* [-76.52, 39.18],
|
|
39
|
-
* [-76.52, 39.17],
|
|
40
|
-
* [-76.54, 39.17]
|
|
41
|
-
* ]
|
|
42
|
-
* });
|
|
43
|
-
*
|
|
44
|
-
* // update coordinates
|
|
45
|
-
* var mySource = map.getSource('some id');
|
|
46
|
-
* mySource.setCoordinates([
|
|
47
|
-
* [-76.54335737228394, 39.18579907229748],
|
|
48
|
-
* [-76.52803659439087, 39.1838364847587],
|
|
49
|
-
* [-76.5295386314392, 39.17683392507606],
|
|
50
|
-
* [-76.54520273208618, 39.17876344106642]
|
|
51
|
-
* ]);
|
|
52
|
-
*
|
|
53
|
-
* // update url and coordinates simultaneously
|
|
54
|
-
* mySource.updateImage({
|
|
55
|
-
* url: 'https://www.mapbox.com/images/bar.png',
|
|
56
|
-
* coordinates: [
|
|
57
|
-
* [-76.54335737228394, 39.18579907229748],
|
|
58
|
-
* [-76.52803659439087, 39.1838364847587],
|
|
59
|
-
* [-76.5295386314392, 39.17683392507606],
|
|
60
|
-
* [-76.54520273208618, 39.17876344106642]
|
|
61
|
-
* ]
|
|
62
|
-
* })
|
|
63
|
-
*
|
|
64
|
-
* map.removeSource('some id'); // remove
|
|
65
|
-
* @see [Add an image](https://www.mapbox.com/mapbox-gl-js/example/image-on-a-map/)
|
|
66
|
-
*/
|
|
67
|
-
class ImageSource extends Evented implements Source {
|
|
68
|
-
type: string;
|
|
69
|
-
id: string;
|
|
70
|
-
minzoom: number;
|
|
71
|
-
maxzoom: number;
|
|
72
|
-
tileSize: number;
|
|
73
|
-
url: string;
|
|
74
|
-
|
|
75
|
-
coordinates: Coordinates;
|
|
76
|
-
tiles: {[_: string]: Tile};
|
|
77
|
-
options: any;
|
|
78
|
-
dispatcher: Dispatcher;
|
|
79
|
-
map: Map;
|
|
80
|
-
texture: Texture | null;
|
|
81
|
-
image: HTMLImageElement | ImageBitmap;
|
|
82
|
-
tileID: CanonicalTileID;
|
|
83
|
-
_boundsArray: RasterBoundsArray;
|
|
84
|
-
boundsBuffer: VertexBuffer;
|
|
85
|
-
boundsSegments: SegmentVector;
|
|
86
|
-
_loaded: boolean;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @private
|
|
90
|
-
*/
|
|
91
|
-
constructor(id: string, options: ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented) {
|
|
92
|
-
super();
|
|
93
|
-
this.id = id;
|
|
94
|
-
this.dispatcher = dispatcher;
|
|
95
|
-
this.coordinates = options.coordinates;
|
|
96
|
-
|
|
97
|
-
this.type = 'image';
|
|
98
|
-
this.minzoom = 0;
|
|
99
|
-
this.maxzoom = 22;
|
|
100
|
-
this.tileSize = 512;
|
|
101
|
-
this.tiles = {};
|
|
102
|
-
this._loaded = false;
|
|
103
|
-
|
|
104
|
-
this.setEventedParent(eventedParent);
|
|
105
|
-
|
|
106
|
-
this.options = options;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
load(newCoordinates?: Coordinates, successCallback?: () => void) {
|
|
110
|
-
this._loaded = false;
|
|
111
|
-
this.fire(new Event('dataloading', {dataType: 'source'}));
|
|
112
|
-
|
|
113
|
-
this.url = this.options.url;
|
|
114
|
-
|
|
115
|
-
getImage(this.map._requestManager.transformRequest(this.url, ResourceType.Image), (err, image) => {
|
|
116
|
-
this._loaded = true;
|
|
117
|
-
if (err) {
|
|
118
|
-
this.fire(new ErrorEvent(err));
|
|
119
|
-
} else if (image) {
|
|
120
|
-
this.image = image;
|
|
121
|
-
if (newCoordinates) {
|
|
122
|
-
this.coordinates = newCoordinates;
|
|
123
|
-
}
|
|
124
|
-
if (successCallback) {
|
|
125
|
-
successCallback();
|
|
126
|
-
}
|
|
127
|
-
this._finishLoading();
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
loaded(): boolean {
|
|
133
|
-
return this._loaded;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Updates the image URL and, optionally, the coordinates. To avoid having the image flash after changing,
|
|
138
|
-
* set the `raster-fade-duration` paint property on the raster layer to 0.
|
|
139
|
-
*
|
|
140
|
-
* @param {Object} options Options object.
|
|
141
|
-
* @param {string} [options.url] Required image URL.
|
|
142
|
-
* @param {Array<Array<number>>} [options.coordinates] Four geographical coordinates,
|
|
143
|
-
* represented as arrays of longitude and latitude numbers, which define the corners of the image.
|
|
144
|
-
* The coordinates start at the top left corner of the image and proceed in clockwise order.
|
|
145
|
-
* They do not have to represent a rectangle.
|
|
146
|
-
* @returns {ImageSource} this
|
|
147
|
-
*/
|
|
148
|
-
updateImage(options: {url: string, coordinates?: Coordinates}) {
|
|
149
|
-
if (!this.image || !options.url) {
|
|
150
|
-
return this;
|
|
151
|
-
}
|
|
152
|
-
this.options.url = options.url;
|
|
153
|
-
this.load(options.coordinates, () => { this.texture = null; });
|
|
154
|
-
return this;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
_finishLoading() {
|
|
158
|
-
if (this.map) {
|
|
159
|
-
this.setCoordinates(this.coordinates);
|
|
160
|
-
this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'}));
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
onAdd(map: Map) {
|
|
165
|
-
this.map = map;
|
|
166
|
-
this.load();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Sets the image's coordinates and re-renders the map.
|
|
171
|
-
*
|
|
172
|
-
* @param {Array<Array<number>>} coordinates Four geographical coordinates,
|
|
173
|
-
* represented as arrays of longitude and latitude numbers, which define the corners of the image.
|
|
174
|
-
* The coordinates start at the top left corner of the image and proceed in clockwise order.
|
|
175
|
-
* They do not have to represent a rectangle.
|
|
176
|
-
* @returns {ImageSource} this
|
|
177
|
-
*/
|
|
178
|
-
setCoordinates(coordinates: Coordinates) {
|
|
179
|
-
this.coordinates = coordinates;
|
|
180
|
-
|
|
181
|
-
// Calculate which mercator tile is suitable for rendering the video in
|
|
182
|
-
// and create a buffer with the corner coordinates. These coordinates
|
|
183
|
-
// may be outside the tile, because raster tiles aren't clipped when rendering.
|
|
184
|
-
|
|
185
|
-
// transform the geo coordinates into (zoom 0) tile space coordinates
|
|
186
|
-
const cornerCoords = coordinates.map(MercatorCoordinate.fromLngLat);
|
|
187
|
-
|
|
188
|
-
// Compute the coordinates of the tile we'll use to hold this image's
|
|
189
|
-
// render data
|
|
190
|
-
this.tileID = getCoordinatesCenterTileID(cornerCoords);
|
|
191
|
-
|
|
192
|
-
// Constrain min/max zoom to our tile's zoom level in order to force
|
|
193
|
-
// SourceCache to request this tile (no matter what the map's zoom
|
|
194
|
-
// level)
|
|
195
|
-
this.minzoom = this.maxzoom = this.tileID.z;
|
|
196
|
-
|
|
197
|
-
// Transform the corner coordinates into the coordinate space of our
|
|
198
|
-
// tile.
|
|
199
|
-
const tileCoords = cornerCoords.map((coord) => this.tileID.getTilePoint(coord)._round());
|
|
200
|
-
|
|
201
|
-
this._boundsArray = new RasterBoundsArray();
|
|
202
|
-
this._boundsArray.emplaceBack(tileCoords[0].x, tileCoords[0].y, 0, 0);
|
|
203
|
-
this._boundsArray.emplaceBack(tileCoords[1].x, tileCoords[1].y, EXTENT, 0);
|
|
204
|
-
this._boundsArray.emplaceBack(tileCoords[3].x, tileCoords[3].y, 0, EXTENT);
|
|
205
|
-
this._boundsArray.emplaceBack(tileCoords[2].x, tileCoords[2].y, EXTENT, EXTENT);
|
|
206
|
-
|
|
207
|
-
if (this.boundsBuffer) {
|
|
208
|
-
this.boundsBuffer.destroy();
|
|
209
|
-
delete this.boundsBuffer;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
this.fire(new Event('data', {dataType:'source', sourceDataType: 'content'}));
|
|
213
|
-
return this;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
prepare() {
|
|
217
|
-
if (Object.keys(this.tiles).length === 0 || !this.image) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
const context = this.map.painter.context;
|
|
222
|
-
const gl = context.gl;
|
|
223
|
-
|
|
224
|
-
if (!this.boundsBuffer) {
|
|
225
|
-
this.boundsBuffer = context.createVertexBuffer(this._boundsArray, rasterBoundsAttributes.members);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (!this.boundsSegments) {
|
|
229
|
-
this.boundsSegments = SegmentVector.simpleSegment(0, 0, 4, 2);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (!this.texture) {
|
|
233
|
-
this.texture = new Texture(context, this.image, gl.RGBA);
|
|
234
|
-
this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
for (const w in this.tiles) {
|
|
238
|
-
const tile = this.tiles[w];
|
|
239
|
-
if (tile.state !== 'loaded') {
|
|
240
|
-
tile.state = 'loaded';
|
|
241
|
-
tile.texture = this.texture;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
loadTile(tile: Tile, callback: Callback<void>) {
|
|
247
|
-
// We have a single tile -- whoose coordinates are this.tileID -- that
|
|
248
|
-
// covers the image we want to render. If that's the one being
|
|
249
|
-
// requested, set it up with the image; otherwise, mark the tile as
|
|
250
|
-
// `errored` to indicate that we have no data for it.
|
|
251
|
-
// If the world wraps, we may have multiple "wrapped" copies of the
|
|
252
|
-
// single tile.
|
|
253
|
-
if (this.tileID && this.tileID.equals(tile.tileID.canonical)) {
|
|
254
|
-
this.tiles[String(tile.tileID.wrap)] = tile;
|
|
255
|
-
tile.buckets = {};
|
|
256
|
-
callback(null);
|
|
257
|
-
} else {
|
|
258
|
-
tile.state = 'errored';
|
|
259
|
-
callback(null);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
serialize(): Object {
|
|
264
|
-
return {
|
|
265
|
-
type: 'image',
|
|
266
|
-
url: this.options.url,
|
|
267
|
-
coordinates: this.coordinates
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
hasTransition() {
|
|
272
|
-
return false;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Given a list of coordinates, get their center as a coordinate.
|
|
278
|
-
*
|
|
279
|
-
* @returns centerpoint
|
|
280
|
-
* @private
|
|
281
|
-
*/
|
|
282
|
-
export function getCoordinatesCenterTileID(coords: Array<MercatorCoordinate>) {
|
|
283
|
-
let minX = Infinity;
|
|
284
|
-
let minY = Infinity;
|
|
285
|
-
let maxX = -Infinity;
|
|
286
|
-
let maxY = -Infinity;
|
|
287
|
-
|
|
288
|
-
for (const coord of coords) {
|
|
289
|
-
minX = Math.min(minX, coord.x);
|
|
290
|
-
minY = Math.min(minY, coord.y);
|
|
291
|
-
maxX = Math.max(maxX, coord.x);
|
|
292
|
-
maxY = Math.max(maxY, coord.y);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const dx = maxX - minX;
|
|
296
|
-
const dy = maxY - minY;
|
|
297
|
-
const dMax = Math.max(dx, dy);
|
|
298
|
-
const zoom = Math.max(0, Math.floor(-Math.log(dMax) / Math.LN2));
|
|
299
|
-
const tilesAtZoom = Math.pow(2, zoom);
|
|
300
|
-
|
|
301
|
-
return new CanonicalTileID(
|
|
302
|
-
zoom,
|
|
303
|
-
Math.floor((minX + maxX) / 2 * tilesAtZoom),
|
|
304
|
-
Math.floor((minY + maxY) / 2 * tilesAtZoom));
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
export default ImageSource;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import {pick, extend} from '../util/util';
|
|
4
|
-
|
|
5
|
-
import {getJSON, ResourceType} from '../util/ajax';
|
|
6
|
-
import browser from '../util/browser';
|
|
7
|
-
|
|
8
|
-
import type {RequestManager} from '../util/mapbox';
|
|
9
|
-
import type {Callback} from '../types/callback';
|
|
10
|
-
import type {TileJSON} from '../types/tilejson';
|
|
11
|
-
import type {Cancelable} from '../types/cancelable';
|
|
12
|
-
|
|
13
|
-
export default function(options: any, requestManager: RequestManager, callback: Callback<TileJSON>): Cancelable {
|
|
14
|
-
const loaded = function(err: ?Error, tileJSON: ?Object) {
|
|
15
|
-
if (err) {
|
|
16
|
-
return callback(err);
|
|
17
|
-
} else if (tileJSON) {
|
|
18
|
-
const result: any = pick(
|
|
19
|
-
// explicit source options take precedence over TileJSON
|
|
20
|
-
extend(tileJSON, options),
|
|
21
|
-
['tiles', 'minzoom', 'maxzoom', 'attribution', 'mapbox_logo', 'bounds', 'scheme', 'tileSize', 'encoding']
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
if (tileJSON.vector_layers) {
|
|
25
|
-
result.vectorLayers = tileJSON.vector_layers;
|
|
26
|
-
result.vectorLayerIds = result.vectorLayers.map((layer) => { return layer.id; });
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
result.tiles = requestManager.canonicalizeTileset(result, options.url);
|
|
30
|
-
callback(null, result);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
if (options.url) {
|
|
35
|
-
return getJSON(requestManager.transformRequest(requestManager.normalizeSourceURL(options.url), ResourceType.Source), loaded);
|
|
36
|
-
} else {
|
|
37
|
-
return browser.frame(() => loaded(null, options));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import VectorTileSource from './vector_tile_source'
|
|
2
|
-
import pako from 'pako/lib/inflate'
|
|
3
|
-
import base64js from 'base64-js'
|
|
4
|
-
import Database from './offline_database'
|
|
5
|
-
|
|
6
|
-
class MBTilesSource extends VectorTileSource {
|
|
7
|
-
|
|
8
|
-
constructor(id, options, dispatcher, eventedParent) {
|
|
9
|
-
super(id, options, dispatcher, eventedParent);
|
|
10
|
-
|
|
11
|
-
this.dispatcher = dispatcher;
|
|
12
|
-
this.setEventedParent(eventedParent);
|
|
13
|
-
|
|
14
|
-
this.type = "mbtiles";
|
|
15
|
-
this.db = this.openDatabase(options.path);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
openDatabase(dbLocation) {
|
|
19
|
-
return Database.openDatabase(dbLocation)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
copyDatabaseFile(dbLocation, dbName, targetDir) {
|
|
23
|
-
return Database.copyDatabaseFile(dbLocation, dbName, targetDir)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
readTile(z, x, y, callback) {
|
|
27
|
-
const query = 'SELECT BASE64(tile_data) AS base64_tile_data FROM tiles WHERE zoom_level=? AND tile_column=? AND tile_row=?';
|
|
28
|
-
const params = [z, x, y];
|
|
29
|
-
this.db.then(function(db) {
|
|
30
|
-
db.transaction(function (txn) {
|
|
31
|
-
txn.executeSql(query, params, function (tx, res) {
|
|
32
|
-
if (res.rows.length) {
|
|
33
|
-
const base64Data = res.rows.item(0).base64_tile_data;
|
|
34
|
-
// const tileData = res.rows.item(0).base64_tile_data;
|
|
35
|
-
// gzip 压缩格式
|
|
36
|
-
const rawData = pako.inflate(base64js.toByteArray(base64Data));
|
|
37
|
-
callback(undefined, base64js.fromByteArray(rawData)); // Tile contents read, callback success.
|
|
38
|
-
// m标准不压缩格式
|
|
39
|
-
// callback(undefined, tileData); // Tile contents read, callback success.
|
|
40
|
-
} else {
|
|
41
|
-
callback(new Error('tile ' + params.join(',') + ' not found'));
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}, function (error) {
|
|
45
|
-
callback(error); // Error executing SQL
|
|
46
|
-
});
|
|
47
|
-
}).catch(function(err) {
|
|
48
|
-
callback(err);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
loadTile(tile, callback) {
|
|
53
|
-
const coord = tile.tileID.canonical;
|
|
54
|
-
const overscaling = coord.z > this.maxzoom ? Math.pow(2, coord.z - this.maxzoom) : 1;
|
|
55
|
-
|
|
56
|
-
const z = Math.min(coord.z, this.maxzoom || coord.z); // Don't try to get data over maxzoom
|
|
57
|
-
const x = coord.x;
|
|
58
|
-
const y = Math.pow(2,z)-coord.y-1; // Tiles on database are tms (inverted y axis)
|
|
59
|
-
|
|
60
|
-
this.readTile(z, x, y, dispatch.bind(this));
|
|
61
|
-
|
|
62
|
-
function dispatch(err, base64Data) {
|
|
63
|
-
if (err) {
|
|
64
|
-
return callback(err);
|
|
65
|
-
}
|
|
66
|
-
if (base64Data === undefined) {
|
|
67
|
-
return callback(new Error("empty data"));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const params = {
|
|
71
|
-
request: { url: "data:application/x-protobuf;base64," + base64Data },
|
|
72
|
-
uid: tile.uid,
|
|
73
|
-
tileID: tile.tileID,
|
|
74
|
-
zoom: coord.z,
|
|
75
|
-
tileSize: this.tileSize * overscaling,
|
|
76
|
-
type: this.type,
|
|
77
|
-
source: this.id,
|
|
78
|
-
pixelRatio: window.devicePixelRatio || 1,
|
|
79
|
-
overscaling: overscaling,
|
|
80
|
-
showCollisionBoxes: this.map.showCollisionBoxes
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
if (!tile.actor || tile.state === 'expired') {
|
|
84
|
-
tile.actor = this.dispatcher.getActor();
|
|
85
|
-
tile.request = tile.actor.send('loadTile', params, done.bind(this));
|
|
86
|
-
} else if (tile.state === 'loading') {
|
|
87
|
-
// schedule tile reloading after it has been loaded
|
|
88
|
-
tile.reloadCallback = callback;
|
|
89
|
-
} else {
|
|
90
|
-
tile.request = tile.actor.send('reloadTile', params, done.bind(this));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function done(err, data) {
|
|
94
|
-
if (tile.aborted)
|
|
95
|
-
return;
|
|
96
|
-
|
|
97
|
-
if (err) {
|
|
98
|
-
return callback(err);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (this.map._refreshExpiredTiles) tile.setExpiryData(data);
|
|
102
|
-
tile.loadVectorData(data, this.map.painter);
|
|
103
|
-
|
|
104
|
-
callback(null);
|
|
105
|
-
|
|
106
|
-
if (tile.reloadCallback) {
|
|
107
|
-
this.loadTile(tile, tile.reloadCallback);
|
|
108
|
-
tile.reloadCallback = null;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export default MBTilesSource;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
class Database {
|
|
2
|
-
|
|
3
|
-
static openDatabase(dbLocation) {
|
|
4
|
-
const dbName = dbLocation.split("/").slice(-1)[0]; // Get the DB file basename
|
|
5
|
-
const source = this;
|
|
6
|
-
console.log('openDatabase', self);
|
|
7
|
-
if ('sqlitePlugin' in self) {
|
|
8
|
-
if('device' in self) {
|
|
9
|
-
return new Promise(function (resolve, reject) {
|
|
10
|
-
if(device.platform === 'Android') {
|
|
11
|
-
resolveLocalFileSystemURL(cordova.file.applicationStorageDirectory, function (dir) {
|
|
12
|
-
dir.getDirectory('databases', {create: true}, function (subdir) {
|
|
13
|
-
resolve(subdir);
|
|
14
|
-
});
|
|
15
|
-
}, reject);
|
|
16
|
-
} else if(device.platform === 'iOS') {
|
|
17
|
-
resolveLocalFileSystemURL(cordova.file.documentsDirectory, resolve, reject);
|
|
18
|
-
} else {
|
|
19
|
-
reject("Platform not supported");
|
|
20
|
-
}
|
|
21
|
-
}).then(function (targetDir) {
|
|
22
|
-
return new Promise(function (resolve, reject) {
|
|
23
|
-
targetDir.getFile(dbName, {}, resolve, reject);
|
|
24
|
-
}).catch(function () {
|
|
25
|
-
return source.copyDatabaseFile(dbLocation, dbName, targetDir)
|
|
26
|
-
});
|
|
27
|
-
}).then(function () {
|
|
28
|
-
var params = {name: dbName};
|
|
29
|
-
if(device.platform === 'iOS') {
|
|
30
|
-
params.iosDatabaseLocation = 'Documents';
|
|
31
|
-
} else {
|
|
32
|
-
params.location = 'default';
|
|
33
|
-
}
|
|
34
|
-
return sqlitePlugin.openDatabase(params);
|
|
35
|
-
});
|
|
36
|
-
} else {
|
|
37
|
-
return Promise.reject(new Error("cordova-plugin-device not available. " +
|
|
38
|
-
"Please install the plugin and make sure this code is run after onDeviceReady event"));
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
return Promise.reject(new Error("cordova-sqlite-ext plugin not available. " +
|
|
42
|
-
"Please install the plugin and make sure this code is run after onDeviceReady event"));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static copyDatabaseFile(dbLocation, dbName, targetDir) {
|
|
47
|
-
console.log("Copying database to application storage directory");
|
|
48
|
-
return new Promise(function (resolve, reject) {
|
|
49
|
-
const absPath = cordova.file.externalRootDirectory + '/' + dbLocation;
|
|
50
|
-
resolveLocalFileSystemURL(absPath, resolve, reject);
|
|
51
|
-
}).then(function (sourceFile) {
|
|
52
|
-
return new Promise(function (resolve, reject) {
|
|
53
|
-
sourceFile.copyTo(targetDir, dbName, resolve, reject);
|
|
54
|
-
}).then(function () {
|
|
55
|
-
console.log("Database copied");
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export default Database
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
class Database {
|
|
2
|
-
|
|
3
|
-
static openDatabase(dbLocation) {
|
|
4
|
-
const dbName = dbLocation.split("/").slice(-1)[0]; // Get the DB file basename
|
|
5
|
-
const source = this;
|
|
6
|
-
console.log('openDatabase', self);
|
|
7
|
-
if ('sqlitePlugin' in self) {
|
|
8
|
-
if('device' in self) {
|
|
9
|
-
return new Promise(function (resolve, reject) {
|
|
10
|
-
if(device.platform === 'Android') {
|
|
11
|
-
resolveLocalFileSystemURL(cordova.file.externalRootDirectory, function (dirEntry) {
|
|
12
|
-
let subdir = cordova.file.externalRootDirectory + "/" + dbLocation
|
|
13
|
-
resolve({dirEntry, subdir});
|
|
14
|
-
}, reject);
|
|
15
|
-
} else if(device.platform === 'iOS') {
|
|
16
|
-
resolveLocalFileSystemURL(cordova.file.documentsDirectory, resolve, reject);
|
|
17
|
-
} else {
|
|
18
|
-
reject("Platform not supported");
|
|
19
|
-
}
|
|
20
|
-
}).then(function (opt) {
|
|
21
|
-
let {dirEntry, subdir} = opt;
|
|
22
|
-
return new Promise(function (resolve, reject) {
|
|
23
|
-
console.warn('offline 1', subdir);
|
|
24
|
-
dirEntry.getFile(subdir, {}, resolve, reject);
|
|
25
|
-
}).catch(function () {
|
|
26
|
-
return source.copyDatabaseFile(dbLocation, dbName, dirEntry)
|
|
27
|
-
});
|
|
28
|
-
}).then(function () {
|
|
29
|
-
var params = {name: dbName};
|
|
30
|
-
if(device.platform === 'iOS') {
|
|
31
|
-
params.iosDatabaseLocation = 'Documents';
|
|
32
|
-
} else {
|
|
33
|
-
params.location = 'default';
|
|
34
|
-
}
|
|
35
|
-
return sqlitePlugin.openDatabase(params);
|
|
36
|
-
});
|
|
37
|
-
} else {
|
|
38
|
-
return Promise.reject(new Error("cordova-plugin-device not available. " +
|
|
39
|
-
"Please install the plugin and make sure this code is run after onDeviceReady event"));
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
return Promise.reject(new Error("cordova-sqlite-ext plugin not available. " +
|
|
43
|
-
"Please install the plugin and make sure this code is run after onDeviceReady event"));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static copyDatabaseFile(dbLocation, dbName, targetDir) {
|
|
48
|
-
console.log("Copying database to application storage directory");
|
|
49
|
-
return new Promise(function (resolve, reject) {
|
|
50
|
-
const absPath = cordova.file.externalRootDirectory + dbLocation;
|
|
51
|
-
resolveLocalFileSystemURL(absPath, resolve, reject);
|
|
52
|
-
}).then(function (sourceFile) {
|
|
53
|
-
return new Promise(function (resolve, reject) {
|
|
54
|
-
sourceFile.copyTo(targetDir, dbName, resolve, reject);
|
|
55
|
-
}).then(function () {
|
|
56
|
-
console.log("Database copied");
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default Database
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import EXTENT from '../data/extent';
|
|
4
|
-
|
|
5
|
-
import type {OverscaledTileID} from './tile_id';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Converts a pixel value at a the given zoom level to tile units.
|
|
9
|
-
*
|
|
10
|
-
* The shaders mostly calculate everything in tile units so style
|
|
11
|
-
* properties need to be converted from pixels to tile units using this.
|
|
12
|
-
*
|
|
13
|
-
* For example, a translation by 30 pixels at zoom 6.5 will be a
|
|
14
|
-
* translation by pixelsToTileUnits(30, 6.5) tile units.
|
|
15
|
-
*
|
|
16
|
-
* @returns value in tile units
|
|
17
|
-
* @private
|
|
18
|
-
*/
|
|
19
|
-
export default function(tile: {tileID: OverscaledTileID, tileSize: number}, pixelValue: number, z: number): number {
|
|
20
|
-
return pixelValue * (EXTENT / (tile.tileSize * Math.pow(2, z - tile.tileID.overscaledZ)));
|
|
21
|
-
}
|