Merge branch 'master' into patch-4

This commit is contained in:
mike-000
2020-03-11 17:10:03 +00:00
committed by GitHub
35 changed files with 1034 additions and 1364 deletions

View File

@@ -33,7 +33,7 @@ import ImageSource from './Image.js';
* the value returned by the function is later changed then
* `changed` should be called on the source for the source to
* invalidate the current cached image. See: {@link module:ol/Observable~Observable#changed}
* @property {import("../proj.js").ProjectionLike} projection Projection.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {number} [ratio=1.5] Ratio. 1 means canvases are the size of the map viewport, 2 means twice the
* width and height of the map viewport, and so on. Must be `1` or higher.
* @property {Array<number>} [resolutions] Resolutions.

View File

@@ -20,7 +20,7 @@ import {appendParams} from '../uri.js';
* @property {boolean} [hidpi=true] Use the `ol/Map#pixelRatio` value when requesting
* the image from the remote server.
* @property {boolean} [useOverlay] If `true`, will use `GETDYNAMICMAPOVERLAYIMAGE`.
* @property {import("../proj.js").ProjectionLike} projection Projection.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {number} [ratio=1] Ratio. `1` means image requests are the size of the map viewport, `2` means
* twice the width and height of the map viewport, and so on. Must be `1` or higher.
* @property {Array<number>} [resolutions] Resolutions.

View File

@@ -19,7 +19,7 @@ import ImageSource, {defaultImageLoadFunction} from './Image.js';
* @property {import("../extent.js").Extent} [imageExtent] Extent of the image in map coordinates.
* This is the [left, bottom, right, top] map coordinates of your image.
* @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given a URL.
* @property {import("../proj.js").ProjectionLike} projection Projection.
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
* @property {import("../size.js").Size} [imageSize] Size of the image in pixels. Usually the image size is auto-detected, so this
* only needs to be set if auto-detection fails for some reason.
* @property {string} url Image URL.

View File

@@ -11,6 +11,7 @@ import {createCanvasContext2D} from '../dom.js';
import {toSize} from '../size.js';
import TileImage from './TileImage.js';
import TileGrid from '../tilegrid/TileGrid.js';
import {getCenter} from '../extent.js';
/**
@@ -90,7 +91,7 @@ export class CustomTile extends ImageTile {
* Higher values can increase reprojection performance, but decrease precision.
* @property {object} [reprojectionContextOptions] Optional properties to set on the canvas context used
* for reprojection. For example specify `{imageSmoothingEnabled: false}` to disable image smoothing.
* @property {string} [url] URL template or base URL of the Zoomify service.
* @property {string} url URL template or base URL of the Zoomify service.
* A base URL is the fixed part
* of the URL, excluding the tile group, z, x, and y folder structure, e.g.
* `http://my.zoomify.info/IMAGE.TIF/`. A URL template must include
@@ -102,7 +103,7 @@ export class CustomTile extends ImageTile {
* A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be
* used instead of defining each one separately in the `urls` option.
* @property {string} [tierSizeCalculation] Tier size calculation method: `default` or `truncated`.
* @property {import("../size.js").Size} [size] Size of the image.
* @property {import("../size.js").Size} size
* @property {import("../extent.js").Extent} [extent] Extent for the TileGrid that is created.
* Default sets the TileGrid in the
* fourth quadrant, meaning extent is `[0, -height, width, 0]`. To change the
@@ -127,11 +128,11 @@ export class CustomTile extends ImageTile {
class Zoomify extends TileImage {
/**
* @param {Options=} opt_options Options.
* @param {Options} opt_options Options.
*/
constructor(opt_options) {
const options = opt_options || {};
const options = opt_options;
const size = options.size;
const tierSizeCalculation = options.tierSizeCalculation !== undefined ?
@@ -198,7 +199,7 @@ class Zoomify extends TileImage {
}
const urls = expandUrl(url);
const tileWidth = tileSize * tilePixelRatio;
let tileWidth = tileSize * tilePixelRatio;
/**
* @param {string} template Template.
@@ -262,6 +263,19 @@ class Zoomify extends TileImage {
*/
this.zDirection = options.zDirection;
// Server retina tile detection (non-standard):
// Try loading the center tile for the highest resolution. If it is not
// available, we are dealing with retina tiles, and need to adjust the
// tile url calculation.
const tileUrl = tileGrid.getTileCoordForCoordAndResolution(getCenter(tileGrid.getExtent()), resolutions[resolutions.length - 1]);
const testTileUrl = tileUrlFunction(tileUrl, 1, null);
const image = new Image();
image.addEventListener('error', function() {
tileWidth = tileSize;
this.changed();
}.bind(this));
image.src = testTileUrl;
}
}