@@ -1,6 +1,6 @@
|
|||||||
import Feature from '../src/ol/Feature.js';
|
import Feature from '../src/ol/Feature.js';
|
||||||
import Map from '../src/ol/Map.js';
|
import Map from '../src/ol/Map.js';
|
||||||
import Observable from '../src/ol/Observable.js';
|
import {unByKey} from '../src/ol/Observable.js';
|
||||||
import View from '../src/ol/View.js';
|
import View from '../src/ol/View.js';
|
||||||
import {defaults as defaultControls} from '../src/ol/control.js';
|
import {defaults as defaultControls} from '../src/ol/control.js';
|
||||||
import {easeOut} from '../src/ol/easing.js';
|
import {easeOut} from '../src/ol/easing.js';
|
||||||
@@ -80,7 +80,7 @@ function flash(feature) {
|
|||||||
vectorContext.setStyle(style);
|
vectorContext.setStyle(style);
|
||||||
vectorContext.drawGeometry(flashGeom);
|
vectorContext.drawGeometry(flashGeom);
|
||||||
if (elapsed > duration) {
|
if (elapsed > duration) {
|
||||||
Observable.unByKey(listenerKey);
|
unByKey(listenerKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// tell OpenLayers to continue postcompose animation
|
// tell OpenLayers to continue postcompose animation
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
import Map from '../src/ol/Map.js';
|
||||||
import Observable from '../src/ol/Observable.js';
|
import {unByKey} from '../src/ol/Observable.js';
|
||||||
import Overlay from '../src/ol/Overlay.js';
|
import Overlay from '../src/ol/Overlay.js';
|
||||||
import {getArea, getLength} from '../src/ol/sphere.js';
|
import {getArea, getLength} from '../src/ol/sphere.js';
|
||||||
import View from '../src/ol/View.js';
|
import View from '../src/ol/View.js';
|
||||||
@@ -238,7 +238,7 @@ function addInteraction() {
|
|||||||
// unset tooltip so that a new one can be created
|
// unset tooltip so that a new one can be created
|
||||||
measureTooltipElement = null;
|
measureTooltipElement = null;
|
||||||
createMeasureTooltip();
|
createMeasureTooltip();
|
||||||
Observable.unByKey(listener);
|
unByKey(listener);
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ inherits(Observable, EventTarget);
|
|||||||
* or `once()` (or an array of keys).
|
* or `once()` (or an array of keys).
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
Observable.unByKey = function(key) {
|
export function unByKey(key) {
|
||||||
if (Array.isArray(key)) {
|
if (Array.isArray(key)) {
|
||||||
for (let i = 0, ii = key.length; i < ii; ++i) {
|
for (let i = 0, ii = key.length; i < ii; ++i) {
|
||||||
unlistenByKey(key[i]);
|
unlistenByKey(key[i]);
|
||||||
@@ -49,7 +49,7 @@ Observable.unByKey = function(key) {
|
|||||||
} else {
|
} else {
|
||||||
unlistenByKey(/** @type {ol.EventsKey} */ (key));
|
unlistenByKey(/** @type {ol.EventsKey} */ (key));
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+2
-2
@@ -45,7 +45,7 @@ const TileRange = function(minX, maxX, minY, maxY) {
|
|||||||
* @param {ol.TileRange|undefined} tileRange TileRange.
|
* @param {ol.TileRange|undefined} tileRange TileRange.
|
||||||
* @return {ol.TileRange} Tile range.
|
* @return {ol.TileRange} Tile range.
|
||||||
*/
|
*/
|
||||||
TileRange.createOrUpdate = function(minX, maxX, minY, maxY, tileRange) {
|
export function createOrUpdate(minX, maxX, minY, maxY, tileRange) {
|
||||||
if (tileRange !== undefined) {
|
if (tileRange !== undefined) {
|
||||||
tileRange.minX = minX;
|
tileRange.minX = minX;
|
||||||
tileRange.maxX = maxX;
|
tileRange.maxX = maxX;
|
||||||
@@ -55,7 +55,7 @@ TileRange.createOrUpdate = function(minX, maxX, minY, maxY, tileRange) {
|
|||||||
} else {
|
} else {
|
||||||
return new TileRange(minX, maxX, minY, maxY);
|
return new TileRange(minX, maxX, minY, maxY);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+4
-3
@@ -339,7 +339,7 @@ View.prototype.animate = function(var_args) {
|
|||||||
animation.callback = callback;
|
animation.callback = callback;
|
||||||
|
|
||||||
// check if animation is a no-op
|
// check if animation is a no-op
|
||||||
if (View.isNoopAnimation(animation)) {
|
if (isNoopAnimation(animation)) {
|
||||||
animation.complete = true;
|
animation.complete = true;
|
||||||
// we still push it onto the series for callback handling
|
// we still push it onto the series for callback handling
|
||||||
} else {
|
} else {
|
||||||
@@ -1204,7 +1204,7 @@ export function createRotationConstraint(options) {
|
|||||||
* @param {ol.ViewAnimation} animation The animation.
|
* @param {ol.ViewAnimation} animation The animation.
|
||||||
* @return {boolean} The animation involves no view change.
|
* @return {boolean} The animation involves no view change.
|
||||||
*/
|
*/
|
||||||
View.isNoopAnimation = function(animation) {
|
export function isNoopAnimation(animation) {
|
||||||
if (animation.sourceCenter && animation.targetCenter) {
|
if (animation.sourceCenter && animation.targetCenter) {
|
||||||
if (!coordinatesEqual(animation.sourceCenter, animation.targetCenter)) {
|
if (!coordinatesEqual(animation.sourceCenter, animation.targetCenter)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1217,5 +1217,6 @@ View.isNoopAnimation = function(animation) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
export default View;
|
export default View;
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ export function getCircleArray(radius) {
|
|||||||
* @param {CanvasRenderingContext2D} context Context.
|
* @param {CanvasRenderingContext2D} context Context.
|
||||||
* @param {number} rotation Rotation.
|
* @param {number} rotation Rotation.
|
||||||
*/
|
*/
|
||||||
CanvasReplayGroup.replayDeclutter = function(declutterReplays, context, rotation) {
|
export function replayDeclutter(declutterReplays, context, rotation) {
|
||||||
const zs = Object.keys(declutterReplays).map(Number).sort(numberSafeCompareFunction);
|
const zs = Object.keys(declutterReplays).map(Number).sort(numberSafeCompareFunction);
|
||||||
const skippedFeatureUids = {};
|
const skippedFeatureUids = {};
|
||||||
for (let z = 0, zz = zs.length; z < zz; ++z) {
|
for (let z = 0, zz = zs.length; z < zz; ++z) {
|
||||||
@@ -215,7 +215,7 @@ CanvasReplayGroup.replayDeclutter = function(declutterReplays, context, rotation
|
|||||||
replay.replay(context, transform, rotation, skippedFeatureUids);
|
replay.replay(context, transform, rotation, skippedFeatureUids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -143,17 +143,16 @@ inherits(CanvasTextReplay, CanvasReplay);
|
|||||||
* each line.
|
* each line.
|
||||||
* @return {number} Width of the whole text.
|
* @return {number} Width of the whole text.
|
||||||
*/
|
*/
|
||||||
CanvasTextReplay.measureTextWidths = function(font, lines, widths) {
|
export function measureTextWidths(font, lines, widths) {
|
||||||
const numLines = lines.length;
|
const numLines = lines.length;
|
||||||
let width = 0;
|
let width = 0;
|
||||||
let currentWidth, i;
|
for (let i = 0; i < numLines; ++i) {
|
||||||
for (i = 0; i < numLines; ++i) {
|
const currentWidth = measureTextWidth(font, lines[i]);
|
||||||
currentWidth = measureTextWidth(font, lines[i]);
|
|
||||||
width = Math.max(width, currentWidth);
|
width = Math.max(width, currentWidth);
|
||||||
widths.push(currentWidth);
|
widths.push(currentWidth);
|
||||||
}
|
}
|
||||||
return width;
|
return width;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -296,7 +295,7 @@ CanvasTextReplay.prototype.getImage = function(text, textKey, fillKey, strokeKey
|
|||||||
const lines = text.split('\n');
|
const lines = text.split('\n');
|
||||||
const numLines = lines.length;
|
const numLines = lines.length;
|
||||||
const widths = [];
|
const widths = [];
|
||||||
const width = CanvasTextReplay.measureTextWidths(textState.font, lines, widths);
|
const width = measureTextWidths(textState.font, lines, widths);
|
||||||
const lineHeight = measureTextHeight(textState.font);
|
const lineHeight = measureTextHeight(textState.font);
|
||||||
const height = lineHeight * numLines;
|
const height = lineHeight * numLines;
|
||||||
const renderWidth = (width + strokeWidth);
|
const renderWidth = (width + strokeWidth);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {equivalent as equivalentProjection} from '../../proj.js';
|
|||||||
import Units from '../../proj/Units.js';
|
import Units from '../../proj/Units.js';
|
||||||
import ReplayType from '../../render/ReplayType.js';
|
import ReplayType from '../../render/ReplayType.js';
|
||||||
import {labelCache, rotateAtOffset} from '../../render/canvas.js';
|
import {labelCache, rotateAtOffset} from '../../render/canvas.js';
|
||||||
import CanvasReplayGroup from '../../render/canvas/ReplayGroup.js';
|
import CanvasReplayGroup, {replayDeclutter} from '../../render/canvas/ReplayGroup.js';
|
||||||
import {ORDER} from '../../render/replay.js';
|
import {ORDER} from '../../render/replay.js';
|
||||||
import RendererType from '../Type.js';
|
import RendererType from '../Type.js';
|
||||||
import CanvasTileLayerRenderer from '../canvas/TileLayer.js';
|
import CanvasTileLayerRenderer from '../canvas/TileLayer.js';
|
||||||
@@ -436,7 +436,7 @@ CanvasVectorTileLayerRenderer.prototype.postCompose = function(context, frameSta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (declutterReplays) {
|
if (declutterReplays) {
|
||||||
CanvasReplayGroup.replayDeclutter(declutterReplays, context, rotation);
|
replayDeclutter(declutterReplays, context, rotation);
|
||||||
}
|
}
|
||||||
if (rotation) {
|
if (rotation) {
|
||||||
rotateAtOffset(context, rotation,
|
rotateAtOffset(context, rotation,
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
*/
|
*/
|
||||||
import {DEFAULT_TILE_SIZE} from './common.js';
|
import {DEFAULT_TILE_SIZE} from './common.js';
|
||||||
import {assert} from '../asserts.js';
|
import {assert} from '../asserts.js';
|
||||||
import TileRange from '../TileRange.js';
|
import TileRange, {createOrUpdate as createOrUpdateTileRange} from '../TileRange.js';
|
||||||
import {isSorted, linearFindNearest} from '../array.js';
|
import {isSorted, linearFindNearest} from '../array.js';
|
||||||
import {createOrUpdate, getTopLeft} from '../extent.js';
|
import {createOrUpdate, getTopLeft} from '../extent.js';
|
||||||
import {clamp} from '../math.js';
|
import {clamp} from '../math.js';
|
||||||
import {toSize} from '../size.js';
|
import {toSize} from '../size.js';
|
||||||
import {createOrUpdate as tileCoordCreateOrUpdate} from '../tilecoord.js';
|
import {createOrUpdate as createOrUpdateTileCoord} from '../tilecoord.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
@@ -199,7 +199,7 @@ TileGrid.prototype.forEachTileCoordParentTileRange = function(tileCoord, callbac
|
|||||||
if (this.zoomFactor_ === 2) {
|
if (this.zoomFactor_ === 2) {
|
||||||
x = Math.floor(x / 2);
|
x = Math.floor(x / 2);
|
||||||
y = Math.floor(y / 2);
|
y = Math.floor(y / 2);
|
||||||
tileRange = TileRange.createOrUpdate(x, x, y, y, opt_tileRange);
|
tileRange = createOrUpdateTileRange(x, x, y, y, opt_tileRange);
|
||||||
} else {
|
} else {
|
||||||
tileRange = this.getTileRangeForExtentAndZ(tileCoordExtent, z, opt_tileRange);
|
tileRange = this.getTileRangeForExtentAndZ(tileCoordExtent, z, opt_tileRange);
|
||||||
}
|
}
|
||||||
@@ -288,7 +288,7 @@ TileGrid.prototype.getTileCoordChildTileRange = function(tileCoord, opt_tileRang
|
|||||||
if (this.zoomFactor_ === 2) {
|
if (this.zoomFactor_ === 2) {
|
||||||
const minX = tileCoord[1] * 2;
|
const minX = tileCoord[1] * 2;
|
||||||
const minY = tileCoord[2] * 2;
|
const minY = tileCoord[2] * 2;
|
||||||
return TileRange.createOrUpdate(minX, minX + 1, minY, minY + 1, opt_tileRange);
|
return createOrUpdateTileRange(minX, minX + 1, minY, minY + 1, opt_tileRange);
|
||||||
}
|
}
|
||||||
const tileCoordExtent = this.getTileCoordExtent(tileCoord, opt_extent);
|
const tileCoordExtent = this.getTileCoordExtent(tileCoord, opt_extent);
|
||||||
return this.getTileRangeForExtentAndZ(
|
return this.getTileRangeForExtentAndZ(
|
||||||
@@ -330,8 +330,7 @@ TileGrid.prototype.getTileRangeForExtentAndZ = function(extent, z, opt_tileRange
|
|||||||
const minX = tileCoord[1];
|
const minX = tileCoord[1];
|
||||||
const minY = tileCoord[2];
|
const minY = tileCoord[2];
|
||||||
this.getTileCoordForXYAndZ_(extent[2], extent[3], z, true, tileCoord);
|
this.getTileCoordForXYAndZ_(extent[2], extent[3], z, true, tileCoord);
|
||||||
return TileRange.createOrUpdate(
|
return createOrUpdateTileRange(minX, tileCoord[1], minY, tileCoord[2], opt_tileRange);
|
||||||
minX, tileCoord[1], minY, tileCoord[2], opt_tileRange);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -422,7 +421,7 @@ TileGrid.prototype.getTileCoordForXYAndResolution_ = function(
|
|||||||
tileCoordY = Math.floor(tileCoordY);
|
tileCoordY = Math.floor(tileCoordY);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tileCoordCreateOrUpdate(z, tileCoordX, tileCoordY, opt_tileCoord);
|
return createOrUpdateTileCoord(z, tileCoordX, tileCoordY, opt_tileCoord);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -461,7 +460,7 @@ TileGrid.prototype.getTileCoordForXYAndZ_ = function(x, y, z, reverseIntersectio
|
|||||||
tileCoordY = Math.floor(tileCoordY);
|
tileCoordY = Math.floor(tileCoordY);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tileCoordCreateOrUpdate(z, tileCoordX, tileCoordY, opt_tileCoord);
|
return createOrUpdateTileCoord(z, tileCoordX, tileCoordY, opt_tileCoord);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import EventTarget from '../../../src/ol/events/EventTarget.js';
|
import EventTarget from '../../../src/ol/events/EventTarget.js';
|
||||||
import Observable from '../../../src/ol/Observable.js';
|
import Observable, {unByKey} from '../../../src/ol/Observable.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.Observable', function() {
|
describe('ol.Observable', function() {
|
||||||
@@ -138,7 +138,7 @@ describe('ol.Observable', function() {
|
|||||||
observable.dispatchEvent('foo');
|
observable.dispatchEvent('foo');
|
||||||
expect(listener.calledOnce).to.be(true);
|
expect(listener.calledOnce).to.be(true);
|
||||||
|
|
||||||
Observable.unByKey(key);
|
unByKey(key);
|
||||||
observable.dispatchEvent('foo');
|
observable.dispatchEvent('foo');
|
||||||
expect(listener.callCount).to.be(1);
|
expect(listener.callCount).to.be(1);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import BingMaps from '../../../../src/ol/source/BingMaps.js';
|
import BingMaps from '../../../../src/ol/source/BingMaps.js';
|
||||||
import {quadKey} from '../../../../src/ol/tilecoord.js';
|
import {quadKey} from '../../../../src/ol/tilecoord.js';
|
||||||
import Observable from '../../../../src/ol/Observable.js';
|
import {unByKey} from '../../../../src/ol/Observable.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.source.BingMaps', function() {
|
describe('ol.source.BingMaps', function() {
|
||||||
@@ -24,7 +24,7 @@ describe('ol.source.BingMaps', function() {
|
|||||||
|
|
||||||
const key = source.on('change', function() {
|
const key = source.on('change', function() {
|
||||||
if (source.getState() === 'ready') {
|
if (source.getState() === 'ready') {
|
||||||
Observable.unByKey(key);
|
unByKey(key);
|
||||||
tileGrid = source.getTileGrid();
|
tileGrid = source.getTileGrid();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Source from '../../../../src/ol/source/Source.js';
|
import Source from '../../../../src/ol/source/Source.js';
|
||||||
import TileJSON from '../../../../src/ol/source/TileJSON.js';
|
import TileJSON from '../../../../src/ol/source/TileJSON.js';
|
||||||
import Observable from '../../../../src/ol/Observable.js';
|
import {unByKey} from '../../../../src/ol/Observable.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.source.TileJSON', function() {
|
describe('ol.source.TileJSON', function() {
|
||||||
@@ -115,7 +115,7 @@ describe('ol.source.TileJSON', function() {
|
|||||||
});
|
});
|
||||||
const key = source.on('change', function() {
|
const key = source.on('change', function() {
|
||||||
if (source.getState() === 'ready') {
|
if (source.getState() === 'ready') {
|
||||||
Observable.unByKey(key);
|
unByKey(key);
|
||||||
tileGrid = source.getTileGrid();
|
tileGrid = source.getTileGrid();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import Map from '../../../src/ol/Map.js';
|
import Map from '../../../src/ol/Map.js';
|
||||||
import View, {createCenterConstraint, createResolutionConstraint, createRotationConstraint} from '../../../src/ol/View.js';
|
import View, {
|
||||||
|
createCenterConstraint, createResolutionConstraint, createRotationConstraint,
|
||||||
|
isNoopAnimation
|
||||||
|
} from '../../../src/ol/View.js';
|
||||||
import ViewHint from '../../../src/ol/ViewHint.js';
|
import ViewHint from '../../../src/ol/ViewHint.js';
|
||||||
import {createEmpty} from '../../../src/ol/extent.js';
|
import {createEmpty} from '../../../src/ol/extent.js';
|
||||||
import Circle from '../../../src/ol/geom/Circle.js';
|
import Circle from '../../../src/ol/geom/Circle.js';
|
||||||
@@ -1485,7 +1488,7 @@ describe('ol.View.isNoopAnimation()', function() {
|
|||||||
|
|
||||||
cases.forEach(function(c, i) {
|
cases.forEach(function(c, i) {
|
||||||
it('works for case ' + i, function() {
|
it('works for case ' + i, function() {
|
||||||
const noop = View.isNoopAnimation(c.animation);
|
const noop = isNoopAnimation(c.animation);
|
||||||
expect(noop).to.equal(c.noop);
|
expect(noop).to.equal(c.noop);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user