Code coverage report for ol/tilegrid/zoomifytilegrid.js

Statements: 29.73% (11 / 37)      Branches: 4.17% (1 / 24)      Functions: 33.33% (1 / 3)      Lines: 29.73% (11 / 37)      Ignored: none     

All files » ol/tilegrid/ » zoomifytilegrid.js
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 69 70 71 72 73 74 75 76 77 78 79 801   1 1 1 1 1                         1 1 1           1           1                                                                                            
goog.provide('ol.tilegrid.Zoomify');
 
goog.require('goog.math');
goog.require('ol.TileCoord');
goog.require('ol.proj');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid.TileGrid');
 
 
 
/**
 * @classdesc
 * Set the grid pattern for sources accessing Zoomify tiled-image servers.
 *
 * @constructor
 * @extends {ol.tilegrid.TileGrid}
 * @param {olx.tilegrid.ZoomifyOptions=} opt_options Options.
 * @api
 */
ol.tilegrid.Zoomify = function(opt_options) {
  var options = goog.isDef(opt_options) ? opt_options : options;
  goog.base(this, {
    origin: [0, 0],
    resolutions: options.resolutions
  });
 
};
goog.inherits(ol.tilegrid.Zoomify, ol.tilegrid.TileGrid);
 
 
/**
 * @inheritDoc
 */
ol.tilegrid.Zoomify.prototype.createTileCoordTransform = function(opt_options) {
  var options = goog.isDef(opt_options) ? opt_options : {};
  var minZ = this.minZoom;
  var maxZ = this.maxZoom;
  /** @type {Array.<ol.TileRange>} */
  var tileRangeByZ = null;
  if (goog.isDef(options.extent)) {
    tileRangeByZ = new Array(maxZ + 1);
    var z;
    for (z = 0; z <= maxZ; ++z) {
      if (z < minZ) {
        tileRangeByZ[z] = null;
      } else {
        tileRangeByZ[z] = this.getTileRangeForExtentAndZ(options.extent, z);
      }
    }
  }
  return (
      /**
       * @param {ol.TileCoord} tileCoord Tile coordinate.
       * @param {ol.proj.Projection} projection Projection.
       * @param {ol.TileCoord=} opt_tileCoord Destination tile coordinate.
       * @return {ol.TileCoord} Tile coordinate.
       */
      function(tileCoord, projection, opt_tileCoord) {
        var z = tileCoord[0];
        if (z < minZ || maxZ < z) {
          return null;
        }
        var n = Math.pow(2, z);
        var x = tileCoord[1];
        if (x < 0 || n <= x) {
          return null;
        }
        var y = tileCoord[2];
        if (y < -n || -1 < y) {
          return null;
        }
        if (!goog.isNull(tileRangeByZ)) {
          if (!tileRangeByZ[z].containsXY(x, -y - 1)) {
            return null;
          }
        }
        return ol.tilecoord.createOrUpdate(z, x, -y - 1, opt_tileCoord);
      });
};