# all files / ol/ loadingstrategy.js

44.44% Statements 8/18
100% Branches 0/0
25% Functions 1/4
44.44% Lines 8/18

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    691×
    1×

    1×

    1×

    1×
    71×

    1×

    1×

     goog.provide('ol.LoadingStrategy');
    goog.provide('ol.loadingstrategy');

    goog.require('ol.TileCoord');

    /**
     * @typedef {function(ol.Extent, number): Array.<ol.Extent>}
     * @api
     */
    ol.LoadingStrategy;

    /**
     * Strategy function for loading all features with a single request.
     * @param {ol.Extent} extent Extent.
     * @param {number} resolution Resolution.
     * @return {Array.<ol.Extent>} Extents.
     * @api
     */
    ol.loadingstrategy.all = function(extent, resolution) {
      return [[-Infinity, -Infinity, Infinity, Infinity]];
    };

    /**
     * Strategy function for loading features based on the view's extent and
     * resolution.
     * @param {ol.Extent} extent Extent.
     * @param {number} resolution Resolution.
     * @return {Array.<ol.Extent>} Extents.
     * @api
     */
    ol.loadingstrategy.bbox = function(extent, resolution) {
      return [extent];
    };

    /**
     * Creates a strategy function for loading features based on a tile grid.
     * @param {ol.tilegrid.TileGrid} tileGrid Tile grid.
     * @return {function(ol.Extent, number): Array.<ol.Extent>} Loading strategy.
     * @api
     */
    ol.loadingstrategy.tile = function(tileGrid) {
      return (
          /**
           * @param {ol.Extent} extent Extent.
           * @param {number} resolution Resolution.
           * @return {Array.<ol.Extent>} Extents.
           */
          function(extent, resolution) {
            var z = tileGrid.getZForResolution(resolution);
            var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
            /** @type {Array.<ol.Extent>} */
            var extents = [];
            /** @type {ol.TileCoord} */
            var tileCoord = [z, 0, 0];
            for (tileCoord[1] = tileRange.minX; tileCoord[1] <= tileRange.maxX;
                 ++tileCoord[1]) {
              for (tileCoord[2] = tileRange.minY; tileCoord[2] <= tileRange.maxY;
                   ++tileCoord[2]) {
                extents.push(tileGrid.getTileCoordExtent(tileCoord));
              }
            }
            return extents;
          });
    };