APIMethod: getResolutionForZoom

Parameters:
zoom - {Float}

Returns:
{Float} A suitable resolution for the specified zoom.
194264
function(zoom) {
        zoom = Math.max(0, Math.min(zoom, this.resolutions.length - 1));
        var resolution;
        if(this.map.fractionalZoom) {
            var low = Math.floor(zoom);
            var high = Math.ceil(zoom);
            resolution = this.resolutions[low] -
                ((zoom-low) * (this.resolutions[low]-this.resolutions[high]));
        } else {
            resolution = this.resolutions[Math.round(zoom)];
        }
        return resolution;
    }
1111281
def in_scope(self, scope: str):
        
        old_scope = self.resolution_scope
        self.resolution_scope = urlparse.urljoin(old_scope, scope)
        try:
            yield
        finally:
            self.resolution_scope = old_scope
1049214
function(resolution) {
      
        if (this.resolutions != null) {
            return OpenLayers.Layer.prototype.getZoomForResolution.apply(this, arguments);
        } else {
            var extent = OpenLayers.Layer.prototype.getExtent.apply(this, []);
            return this.getZoomForExtent(extent);
        }
    }
244881
def zoom_out(self):
        
        viewer = self.getfocus_viewer()
        if hasattr(viewer, 'zoom_out'):
            viewer.zoom_out()
        return True
469783
def scale_view(self, x, y):
        
        d = self.declaration
        factor = self.widget.transform().scale(x, y).mapRect(
            QRectF(0, 0, 1, 1)).width()
        if (d.min_zoom > factor > d.max_zoom):
            return
        self.widget.scale(x, y)
        return factor
905791
function() {
        var inRange = false;

        if (this.alwaysInRange) {
            inRange = true;
        } else {
            if (this.map) {
                var resolution = this.map.getResolution();
                inRange = ( (resolution >= this.minResolution) &&
                            (resolution <= this.maxResolution) );
            }
        }
        return inRange;
    }
1340608
function zoomCondition(zoom) {
    var zooms = [];
    for (var i = 0; i <= _carto2['default'].tree.Zoom.maxZoom; i++) {
        if (zoom & 1 << i) {
            zooms.push(i);
        }
    }

    var zoomRanges = detectZoomRanges(zooms),
        value,
        operator;
    if (zoomRanges.length > 1) {
        operator = 'IN';
        value = zooms;
    } else {
        var range = zoomRanges[0];
        if (range[0] === 0) {
            operator = '<=';
            value = range[1];
        } else if (range[1] === _carto2['default'].tree.Zoom.maxZoom) {
            operator = '>=';
            value = range[0];
        } else {
            // We're only handling >=, <= and IN right now
            operator = 'IN';
            value = zooms;
        }
    }

    if (value.length === 0) {
        return null;
    }
    return [{
        operator: operator,
        type: 'zoom',
        value: value
    }];
}
425126
function zoomed () {
    // Get the height and width
    height = el.clientHeight
    width = el.clientWidth

    // Set the map tile size
    tile.size([width, height])

    // Get the current display bounds
    var bounds = display.llBounds()

    // Project the bounds based on the current projection
    var psw = projection(bounds[0])
    var pne = projection(bounds[1])

    // Based the new scale and translation vector off the current one
    var scale = projection.scale() * 2 * Math.PI
    var translate = projection.translate()

    var dx = pne[0] - psw[0]
    var dy = pne[1] - psw[1]

    scale = scale * (1 / Math.max(dx / width, dy / height))
    projection
      .translate([width / 2, height / 2])
      .scale(scale / 2 / Math.PI)

    // Reproject the bounds based on the new scale and translation vector
    psw = projection(bounds[0])
    pne = projection(bounds[1])
    var x = (psw[0] + pne[0]) / 2
    var y = (psw[1] + pne[1]) / 2
    translate = [width - x, height - y]

    // Update the Geo tiles
    tile
      .scale(scale)
      .translate(translate)

    // Get the new set of tiles and render
    renderTiles(tile())
  }
577297
def numberOfYTilesAtZoom(self, zoom):
        ""
        [minRow, minCol, maxRow, maxCol] = self.getExtentAddress(zoom)
        return maxRow - minRow + 1
623728
function(size) {
    return function limitResolution(params) {
      if (params.width <= 0 || params.height <= 0) {
        return params;
      }
      var width = params.width;
      var minZoom = pixelRatio() * width / size;
      params.zoom = clamp(params.zoom, minZoom, Infinity);
      return params;
    };
  }
1169319
private double checkResolution(double resolution, ZoomOption zoomOption) {
		double allowedResolution = resolution;
		double maximumResolution = getMaximumResolution();
		double minimumResolution = getMinimumResolution();
		if (allowedResolution > maximumResolution) {
			allowedResolution = maximumResolution;
		} else if (allowedResolution < minimumResolution) {
			allowedResolution = minimumResolution;
		}

		if (zoomOption == ZoomOption.FREE) {
			return allowedResolution;
		}

		for (int i = 0; i < resolutions.size() - 1; i++) {
			double upper = resolutions.get(i);
			double lower = resolutions.get(i + 1);

			if (allowedResolution == upper) {
				return upper;
			} else if (allowedResolution == lower) {
				return lower;
			} else if (allowedResolution < upper && allowedResolution > lower) {
				switch (zoomOption) {
					case LEVEL_FIT:
						return upper;
					case LEVEL_CLOSEST:
						if (Math.abs(upper - allowedResolution) < Math.abs(allowedResolution - lower)) {
							return upper;
						} else {
							return lower;
						}
					default:
						return allowedResolution;
				}
			}
		}
		return allowedResolution;
	}
37756
def _confirm_resolution(self, implemented_res):
        '''  '''

        assert self.ppd in implemented_res, \
            ' Resolution %d ppd not implemented yet\n.\
            Consider using one of the implemented resolutions %s'\
            % (self.ppd, ', '.join([f + ' ppd' for f in map(str, implemented_res)]))

        if self.ppd == 256:
            assert (np.abs(self.latM) < 60) and (np.abs(self.latm) < 60),\
                'This resolution is available in\n \
                in cylindrical geometry only for -60<latitude<60 '
1128168
function (bounds) {
        bounds = this.adjustBounds(bounds);
        var zoom = this.getZoom();
        var extent = this.map.getMaxExtent();
        var deg = this.lzd/Math.pow(2,this.getZoom());
        var x = Math.floor((bounds.left - extent.left)/deg);
        var y = Math.floor((bounds.bottom - extent.bottom)/deg);
        if (this.map.getResolution() <= (this.lzd/512)
            && this.getZoom() <= this.zoomLevels) {
            return this.getFullRequestString(
              { L: zoom, 
                X: x,
                Y: y
              });
        } else {
            return OpenLayers.Util.getImageLocation("blank.gif");
        }

    }
852998
function() {

        if (this.resolutions != null) {
            return OpenLayers.Layer.prototype.getResolution.apply(this, arguments);
        } else {
            var resolution = null;
            
            var viewSize = this.map.getSize();
            var extent = this.getExtent();
            
            if ((viewSize != null) && (extent != null)) {
                resolution = Math.max( extent.getWidth()  / viewSize.w,
                                       extent.getHeight() / viewSize.h );
            }
            return resolution;
        }
     }
51165
public int getResolutionIndex(double resolution) {
		double maximumResolution = getMaximumResolution();
		if (resolution >= maximumResolution) {
			return 0;
		}
		double minimumResolution = getMinimumResolution();
		if (resolution <= minimumResolution) {
			return resolutions.size() - 1;
		}

		for (int i = 0; i < resolutions.size(); i++) {
			double upper = resolutions.get(i);
			double lower = resolutions.get(i + 1);
			if (resolution < upper && resolution >= lower) {
				if (Math.abs(upper - resolution) >= Math.abs(lower - resolution)) {
					return i + 1;
				} else {
					return i;
				}
			}
		}
		return 0;
	}
37256
def pixel_x_size(self, zoom):
        
        validate_zoom(zoom)
        return round(
            (self.grid.right - self.grid.left) /
            (self.grid.shape.width * 2**zoom * self.tile_size),
            ROUND
        )
952146
def nside2resol(nside, arcmin=False):
    """"""
    resolution = nside_to_pixel_resolution(nside)
    if arcmin:
        return resolution.to(u.arcmin).value
    else:
        return resolution.to(u.rad).value