Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d218c4d454 | ||
|
|
81f37708c1 | ||
|
|
8b0c6196e6 | ||
|
|
93a9799e46 | ||
|
|
7f0c8fe899 | ||
|
|
b06efa387c | ||
|
|
48178f0e31 | ||
|
|
d65cabebd6 | ||
|
|
992cf2b2d6 | ||
|
|
f1685cbe4f | ||
|
|
d3c2c7f96d | ||
|
|
bb593eaac8 | ||
|
|
87391e7795 | ||
|
|
87a10200e3 |
9
changelog/v4.3.1.md
Normal file
9
changelog/v4.3.1.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# 4.3.1
|
||||
|
||||
The v4.3.1 release includes a few fixes that didn't make it into v4.3.0. No special upgrade considerations.
|
||||
|
||||
## Fixes
|
||||
|
||||
* [#7122](https://github.com/openlayers/openlayers/pull/7122) - Immediately complete no-op animations ([@tschaub](https://github.com/tschaub))
|
||||
* [#7120](https://github.com/openlayers/openlayers/pull/7120) - Fix hit detection for overzoomed vector tiles ([@ahocevar](https://github.com/ahocevar))
|
||||
* [#7114](https://github.com/openlayers/openlayers/pull/7114) - Immediate WebGL text renderer and other improvements ([@GaborFarkas](https://github.com/GaborFarkas))
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openlayers",
|
||||
"version": "4.3.0",
|
||||
"version": "4.3.1",
|
||||
"description": "Build tools and sources for developing OpenLayers based mapping applications",
|
||||
"keywords": [
|
||||
"map",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ol",
|
||||
"version": "4.3.0",
|
||||
"version": "4.3.1",
|
||||
"description": "OpenLayers as ES2015 modules",
|
||||
"main": "index.js",
|
||||
"module": "index.js",
|
||||
|
||||
@@ -78,10 +78,44 @@ if (ol.ENABLE_WEBGL) {
|
||||
*/
|
||||
this.strokeStyle_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.style.Text}
|
||||
*/
|
||||
this.textStyle_ = null;
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.webgl.Immediate, ol.render.VectorContext);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.render.webgl.ReplayGroup} replayGroup Replay group.
|
||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||
* @param {number} offset Offset.
|
||||
* @param {number} end End.
|
||||
* @param {number} stride Stride.
|
||||
* @private
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.drawText_ = function(replayGroup,
|
||||
flatCoordinates, offset, end, stride) {
|
||||
var context = this.context_;
|
||||
var replay = /** @type {ol.render.webgl.TextReplay} */ (
|
||||
replayGroup.getReplay(0, ol.render.ReplayType.TEXT));
|
||||
replay.setTextStyle(this.textStyle_);
|
||||
replay.drawText(flatCoordinates, offset, end, stride, null, null);
|
||||
replay.finish(context);
|
||||
// default colors
|
||||
var opacity = 1;
|
||||
var skippedFeatures = {};
|
||||
var featureCallback;
|
||||
var oneByOne = false;
|
||||
replay.replay(this.context_, this.center_, this.resolution_, this.rotation_,
|
||||
this.size_, this.pixelRatio_, opacity, skippedFeatures, featureCallback,
|
||||
oneByOne);
|
||||
replay.getDeleteResourcesFunction(context)();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the rendering style. Note that since this is an immediate rendering API,
|
||||
* any `zIndex` on the provided style will be ignored.
|
||||
@@ -93,6 +127,7 @@ if (ol.ENABLE_WEBGL) {
|
||||
ol.render.webgl.Immediate.prototype.setStyle = function(style) {
|
||||
this.setFillStrokeStyle(style.getFill(), style.getStroke());
|
||||
this.setImageStyle(style.getImage());
|
||||
this.setTextStyle(style.getText());
|
||||
};
|
||||
|
||||
|
||||
@@ -184,6 +219,12 @@ if (ol.ENABLE_WEBGL) {
|
||||
this.size_, this.pixelRatio_, opacity, skippedFeatures, featureCallback,
|
||||
oneByOne);
|
||||
replay.getDeleteResourcesFunction(context)();
|
||||
|
||||
if (this.textStyle_) {
|
||||
var flatCoordinates = geometry.getFlatCoordinates();
|
||||
var stride = geometry.getStride();
|
||||
this.drawText_(replayGroup, flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -206,6 +247,12 @@ if (ol.ENABLE_WEBGL) {
|
||||
this.size_, this.pixelRatio_, opacity, skippedFeatures, featureCallback,
|
||||
oneByOne);
|
||||
replay.getDeleteResourcesFunction(context)();
|
||||
|
||||
if (this.textStyle_) {
|
||||
var flatCoordinates = geometry.getFlatCoordinates();
|
||||
var stride = geometry.getStride();
|
||||
this.drawText_(replayGroup, flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -228,6 +275,11 @@ if (ol.ENABLE_WEBGL) {
|
||||
this.size_, this.pixelRatio_, opacity, skippedFeatures, featureCallback,
|
||||
oneByOne);
|
||||
replay.getDeleteResourcesFunction(context)();
|
||||
|
||||
if (this.textStyle_) {
|
||||
var flatMidpoint = geometry.getFlatMidpoint();
|
||||
this.drawText_(replayGroup, flatMidpoint, 0, 2, 2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -250,6 +302,11 @@ if (ol.ENABLE_WEBGL) {
|
||||
this.size_, this.pixelRatio_, opacity, skippedFeatures, featureCallback,
|
||||
oneByOne);
|
||||
replay.getDeleteResourcesFunction(context)();
|
||||
|
||||
if (this.textStyle_) {
|
||||
var flatMidpoints = geometry.getFlatMidpoints();
|
||||
this.drawText_(replayGroup, flatMidpoints, 0, flatMidpoints.length, 2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -272,6 +329,11 @@ if (ol.ENABLE_WEBGL) {
|
||||
this.size_, this.pixelRatio_, opacity, skippedFeatures, featureCallback,
|
||||
oneByOne);
|
||||
replay.getDeleteResourcesFunction(context)();
|
||||
|
||||
if (this.textStyle_) {
|
||||
var flatInteriorPoint = geometry.getFlatInteriorPoint();
|
||||
this.drawText_(replayGroup, flatInteriorPoint, 0, 2, 2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -294,6 +356,11 @@ if (ol.ENABLE_WEBGL) {
|
||||
this.size_, this.pixelRatio_, opacity, skippedFeatures, featureCallback,
|
||||
oneByOne);
|
||||
replay.getDeleteResourcesFunction(context)();
|
||||
|
||||
if (this.textStyle_) {
|
||||
var flatInteriorPoints = geometry.getFlatInteriorPoints();
|
||||
this.drawText_(replayGroup, flatInteriorPoints, 0, flatInteriorPoints.length, 2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -316,6 +383,10 @@ if (ol.ENABLE_WEBGL) {
|
||||
this.size_, this.pixelRatio_, opacity, skippedFeatures, featureCallback,
|
||||
oneByOne);
|
||||
replay.getDeleteResourcesFunction(context)();
|
||||
|
||||
if (this.textStyle_) {
|
||||
this.drawText_(replayGroup, geometry.getCenter(), 0, 2, 2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -335,4 +406,12 @@ if (ol.ENABLE_WEBGL) {
|
||||
this.strokeStyle_ = strokeStyle;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.setTextStyle = function(textStyle) {
|
||||
this.textStyle_ = textStyle;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -79,7 +79,8 @@ if (ol.ENABLE_WEBGL) {
|
||||
var outerRing = new ol.structs.LinkedList();
|
||||
var rtree = new ol.structs.RBush();
|
||||
// Initialize the outer ring
|
||||
var maxX = this.processFlatCoordinates_(flatCoordinates, stride, outerRing, rtree, true);
|
||||
this.processFlatCoordinates_(flatCoordinates, stride, outerRing, rtree, true);
|
||||
var maxCoords = this.getMaxCoords_(outerRing);
|
||||
|
||||
// Eliminate holes, if there are any
|
||||
if (holeFlatCoordinates.length) {
|
||||
@@ -88,15 +89,18 @@ if (ol.ENABLE_WEBGL) {
|
||||
for (i = 0, ii = holeFlatCoordinates.length; i < ii; ++i) {
|
||||
var holeList = {
|
||||
list: new ol.structs.LinkedList(),
|
||||
maxX: undefined,
|
||||
maxCoords: undefined,
|
||||
rtree: new ol.structs.RBush()
|
||||
};
|
||||
holeLists.push(holeList);
|
||||
holeList.maxX = this.processFlatCoordinates_(holeFlatCoordinates[i],
|
||||
this.processFlatCoordinates_(holeFlatCoordinates[i],
|
||||
stride, holeList.list, holeList.rtree, false);
|
||||
this.classifyPoints_(holeList.list, holeList.rtree, true);
|
||||
holeList.maxCoords = this.getMaxCoords_(holeList.list);
|
||||
}
|
||||
holeLists.sort(function(a, b) {
|
||||
return b.maxX[0] === a.maxX[0] ? a.maxX[1] - b.maxX[1] : b.maxX[0] - a.maxX[0];
|
||||
return b.maxCoords[0] === a.maxCoords[0] ?
|
||||
a.maxCoords[1] - b.maxCoords[1] : b.maxCoords[0] - a.maxCoords[0];
|
||||
});
|
||||
for (i = 0; i < holeLists.length; ++i) {
|
||||
var currList = holeLists[i].list;
|
||||
@@ -104,6 +108,7 @@ if (ol.ENABLE_WEBGL) {
|
||||
var currItem = start;
|
||||
var intersection;
|
||||
do {
|
||||
//TODO: Triangulate holes when they intersect the outer ring.
|
||||
if (this.getIntersections_(currItem, rtree).length) {
|
||||
intersection = true;
|
||||
break;
|
||||
@@ -111,8 +116,7 @@ if (ol.ENABLE_WEBGL) {
|
||||
currItem = currList.nextItem();
|
||||
} while (start !== currItem);
|
||||
if (!intersection) {
|
||||
this.classifyPoints_(currList, holeLists[i].rtree, true);
|
||||
if (this.bridgeHole_(currList, holeLists[i].maxX[0], outerRing, maxX[0], rtree)) {
|
||||
if (this.bridgeHole_(currList, holeLists[i].maxCoords[0], outerRing, maxCoords[0], rtree)) {
|
||||
rtree.concat(holeLists[i].rtree);
|
||||
this.classifyPoints_(outerRing, rtree, false);
|
||||
}
|
||||
@@ -133,13 +137,12 @@ if (ol.ENABLE_WEBGL) {
|
||||
* @param {ol.structs.LinkedList} list Linked list.
|
||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||
* @param {boolean} clockwise Coordinate order should be clockwise.
|
||||
* @return {Array.<number>} X and Y coords of maximum X value.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.processFlatCoordinates_ = function(
|
||||
flatCoordinates, stride, list, rtree, clockwise) {
|
||||
var isClockwise = ol.geom.flat.orient.linearRingIsClockwise(flatCoordinates,
|
||||
0, flatCoordinates.length, stride);
|
||||
var i, ii, maxXX, maxXY;
|
||||
var i, ii;
|
||||
var n = this.vertices.length / 2;
|
||||
/** @type {ol.WebglPolygonVertex} */
|
||||
var start;
|
||||
@@ -152,17 +155,11 @@ if (ol.ENABLE_WEBGL) {
|
||||
if (clockwise === isClockwise) {
|
||||
start = this.createPoint_(flatCoordinates[0], flatCoordinates[1], n++);
|
||||
p0 = start;
|
||||
maxXX = flatCoordinates[0];
|
||||
maxXY = flatCoordinates[1];
|
||||
for (i = stride, ii = flatCoordinates.length; i < ii; i += stride) {
|
||||
p1 = this.createPoint_(flatCoordinates[i], flatCoordinates[i + 1], n++);
|
||||
segments.push(this.insertItem_(p0, p1, list));
|
||||
extents.push([Math.min(p0.x, p1.x), Math.min(p0.y, p1.y), Math.max(p0.x, p1.x),
|
||||
Math.max(p0.y, p1.y)]);
|
||||
if (flatCoordinates[i] > maxXX) {
|
||||
maxXX = flatCoordinates[i];
|
||||
maxXY = flatCoordinates[i + 1];
|
||||
}
|
||||
p0 = p1;
|
||||
}
|
||||
segments.push(this.insertItem_(p1, start, list));
|
||||
@@ -172,17 +169,11 @@ if (ol.ENABLE_WEBGL) {
|
||||
var end = flatCoordinates.length - stride;
|
||||
start = this.createPoint_(flatCoordinates[end], flatCoordinates[end + 1], n++);
|
||||
p0 = start;
|
||||
maxXX = flatCoordinates[end];
|
||||
maxXY = flatCoordinates[end + 1];
|
||||
for (i = end - stride, ii = 0; i >= ii; i -= stride) {
|
||||
p1 = this.createPoint_(flatCoordinates[i], flatCoordinates[i + 1], n++);
|
||||
segments.push(this.insertItem_(p0, p1, list));
|
||||
extents.push([Math.min(p0.x, p1.x), Math.min(p0.y, p1.y), Math.max(p0.x, p1.x),
|
||||
Math.max(p0.y, p1.y)]);
|
||||
if (flatCoordinates[i] > maxXX) {
|
||||
maxXX = flatCoordinates[i];
|
||||
maxXY = flatCoordinates[i + 1];
|
||||
}
|
||||
p0 = p1;
|
||||
}
|
||||
segments.push(this.insertItem_(p1, start, list));
|
||||
@@ -190,8 +181,28 @@ if (ol.ENABLE_WEBGL) {
|
||||
Math.max(p0.y, p1.y)]);
|
||||
}
|
||||
rtree.load(extents, segments);
|
||||
};
|
||||
|
||||
return [maxXX, maxXY];
|
||||
|
||||
/**
|
||||
* Returns the rightmost coordinates of a polygon on the X axis.
|
||||
* @private
|
||||
* @param {ol.structs.LinkedList} list Polygons ring.
|
||||
* @return {Array.<number>} Max X coordinates.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.getMaxCoords_ = function(list) {
|
||||
var start = list.firstItem();
|
||||
var seg = start;
|
||||
var maxCoords = [seg.p0.x, seg.p0.y];
|
||||
|
||||
do {
|
||||
seg = list.nextItem();
|
||||
if (seg.p0.x > maxCoords[0]) {
|
||||
maxCoords = [seg.p0.x, seg.p0.y];
|
||||
}
|
||||
} while (seg !== start);
|
||||
|
||||
return maxCoords;
|
||||
};
|
||||
|
||||
|
||||
@@ -325,7 +336,7 @@ if (ol.ENABLE_WEBGL) {
|
||||
if (!this.classifyPoints_(list, rtree, ccw)) {
|
||||
// Due to the behavior of OL's PIP algorithm, the ear clipping cannot
|
||||
// introduce touching segments. However, the original data may have some.
|
||||
if (!this.resolveLocalSelfIntersections_(list, rtree, true)) {
|
||||
if (!this.resolveSelfIntersections_(list, rtree, true)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -335,7 +346,7 @@ if (ol.ENABLE_WEBGL) {
|
||||
// We ran out of ears, try to reclassify.
|
||||
if (!this.classifyPoints_(list, rtree, ccw)) {
|
||||
// We have a bad polygon, try to resolve local self-intersections.
|
||||
if (!this.resolveLocalSelfIntersections_(list, rtree)) {
|
||||
if (!this.resolveSelfIntersections_(list, rtree)) {
|
||||
simple = this.isSimple_(list, rtree);
|
||||
if (!simple) {
|
||||
// We have a really bad polygon, try more time consuming methods.
|
||||
@@ -382,10 +393,15 @@ if (ol.ENABLE_WEBGL) {
|
||||
p2 = s2.p1;
|
||||
if (p1.reflex === false) {
|
||||
// We might have a valid ear
|
||||
var diagonalIsInside = ccw ? this.diagonalIsInside_(s3.p1, p2, p1, p0,
|
||||
s0.p0) : this.diagonalIsInside_(s0.p0, p0, p1, p2, s3.p1);
|
||||
var variableCriterion;
|
||||
if (simple) {
|
||||
variableCriterion = this.getPointsInTriangle_(p0, p1, p2, rtree, true).length === 0;
|
||||
} else {
|
||||
variableCriterion = ccw ? this.diagonalIsInside_(s3.p1, p2, p1, p0,
|
||||
s0.p0) : this.diagonalIsInside_(s0.p0, p0, p1, p2, s3.p1);
|
||||
}
|
||||
if ((simple || this.getIntersections_({p0: p0, p1: p2}, rtree).length === 0) &&
|
||||
diagonalIsInside && this.getPointsInTriangle_(p0, p1, p2, rtree, true).length === 0) {
|
||||
variableCriterion) {
|
||||
//The diagonal is completely inside the polygon
|
||||
if (simple || p0.reflex === false || p2.reflex === false ||
|
||||
ol.geom.flat.orient.linearRingIsClockwise([s0.p0.x, s0.p0.y, p0.x,
|
||||
@@ -420,7 +436,7 @@ if (ol.ENABLE_WEBGL) {
|
||||
* @param {boolean=} opt_touch Resolve touching segments.
|
||||
* @return {boolean} There were resolved intersections.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.resolveLocalSelfIntersections_ = function(
|
||||
ol.render.webgl.PolygonReplay.prototype.resolveSelfIntersections_ = function(
|
||||
list, rtree, opt_touch) {
|
||||
var start = list.firstItem();
|
||||
list.nextItem();
|
||||
|
||||
@@ -129,8 +129,8 @@ if (ol.ENABLE_WEBGL) {
|
||||
var lines = this.text_.split('\n');
|
||||
var textSize = this.getTextSize_(lines);
|
||||
var i, ii, j, jj, currX, currY, charArr, charInfo;
|
||||
var anchorX = Math.round(textSize[0] * this.textAlign_ + this.offsetX_);
|
||||
var anchorY = Math.round(textSize[1] * this.textBaseline_ + this.offsetY_);
|
||||
var anchorX = Math.round(textSize[0] * this.textAlign_ - this.offsetX_);
|
||||
var anchorY = Math.round(textSize[1] * this.textBaseline_ - this.offsetY_);
|
||||
var lineWidth = (this.state_.lineWidth / 2) * this.state_.scale;
|
||||
|
||||
for (i = 0, ii = lines.length; i < ii; ++i) {
|
||||
|
||||
@@ -238,7 +238,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = functi
|
||||
var sourceTileGrid = source.getTileGrid();
|
||||
var bufferedExtent, found, tileSpaceCoordinate;
|
||||
var i, ii, origin, replayGroup;
|
||||
var tile, tileCoord, tileExtent, tilePixelRatio, tileResolution;
|
||||
var tile, tileCoord, tileExtent, tilePixelRatio, tileRenderResolution;
|
||||
for (i = 0, ii = renderedTiles.length; i < ii; ++i) {
|
||||
tile = renderedTiles[i];
|
||||
tileCoord = tile.tileCoord;
|
||||
@@ -254,12 +254,14 @@ ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = functi
|
||||
var sourceTileExtent = sourceTileGrid.getTileCoordExtent(sourceTileCoord, this.tmpExtent);
|
||||
origin = ol.extent.getTopLeft(sourceTileExtent);
|
||||
tilePixelRatio = this.getTilePixelRatio_(source, sourceTile);
|
||||
tileResolution = sourceTileGrid.getResolution(sourceTileCoord[0]) / tilePixelRatio;
|
||||
var sourceTileResolution = sourceTileGrid.getResolution(sourceTileCoord[0]);
|
||||
tileRenderResolution = sourceTileResolution / tilePixelRatio;
|
||||
tileSpaceCoordinate = [
|
||||
(coordinate[0] - origin[0]) / tileResolution,
|
||||
(origin[1] - coordinate[1]) / tileResolution
|
||||
(coordinate[0] - origin[0]) / tileRenderResolution,
|
||||
(origin[1] - coordinate[1]) / tileRenderResolution
|
||||
];
|
||||
resolution = tilePixelRatio;
|
||||
var upscaling = tileGrid.getResolution(tileCoord[0]) / sourceTileResolution;
|
||||
resolution = tilePixelRatio * upscaling;
|
||||
} else {
|
||||
tileSpaceCoordinate = coordinate;
|
||||
}
|
||||
|
||||
@@ -302,7 +302,14 @@ ol.View.prototype.animate = function(var_args) {
|
||||
}
|
||||
|
||||
animation.callback = callback;
|
||||
start += animation.duration;
|
||||
|
||||
// check if animation is a no-op
|
||||
if (ol.View.isNoopAnimation(animation)) {
|
||||
animation.complete = true;
|
||||
// we still push it onto the series for callback handling
|
||||
} else {
|
||||
start += animation.duration;
|
||||
}
|
||||
series.push(animation);
|
||||
}
|
||||
this.animations_.push(series);
|
||||
@@ -1158,3 +1165,24 @@ ol.View.createRotationConstraint_ = function(options) {
|
||||
return ol.RotationConstraint.disable;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Determine if an animation involves no view change.
|
||||
* @param {ol.ViewAnimation} animation The animation.
|
||||
* @return {boolean} The animation involves no view change.
|
||||
*/
|
||||
ol.View.isNoopAnimation = function(animation) {
|
||||
if (animation.sourceCenter && animation.targetCenter) {
|
||||
if (!ol.coordinate.equals(animation.sourceCenter, animation.targetCenter)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (animation.sourceResolution !== animation.targetResolution) {
|
||||
return false;
|
||||
}
|
||||
if (animation.sourceRotation !== animation.targetRotation) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -154,8 +154,8 @@ describe('ol.render.webgl.TextReplay', function() {
|
||||
expect(replay.originY).to.be(charInfo.offsetY);
|
||||
expect(replay.imageHeight).to.be(charInfo.image.height);
|
||||
expect(replay.imageWidth).to.be(charInfo.image.width);
|
||||
expect(replay.anchorX).to.be(-widthX + 10);
|
||||
expect(replay.anchorY).to.be(10);
|
||||
expect(replay.anchorX).to.be(-widthX - 10);
|
||||
expect(replay.anchorY).to.be(-10);
|
||||
});
|
||||
|
||||
it('does not draw if text is empty', function() {
|
||||
|
||||
@@ -298,6 +298,42 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
|
||||
expect(spy.callCount).to.be(1);
|
||||
expect(spy.getCall(0).args[1]).to.equal(layer);
|
||||
});
|
||||
});
|
||||
|
||||
it('does not give false positives when overzoomed', function(done) {
|
||||
var target = document.createElement('div');
|
||||
target.style.width = '100px';
|
||||
target.style.height = '100px';
|
||||
document.body.appendChild(target);
|
||||
var extent = [1824704.739223726, 6141868.096770482, 1827150.7241288517, 6144314.081675608];
|
||||
var source = new ol.source.VectorTile({
|
||||
format: new ol.format.MVT(),
|
||||
url: 'spec/ol/data/14-8938-5680.vector.pbf',
|
||||
minZoom: 14,
|
||||
maxZoom: 14
|
||||
});
|
||||
var map = new ol.Map({
|
||||
target: target,
|
||||
layers: [
|
||||
new ol.layer.VectorTile({
|
||||
extent: extent,
|
||||
source: source
|
||||
})
|
||||
],
|
||||
view: new ol.View({
|
||||
center: ol.extent.getCenter(extent),
|
||||
zoom: 19
|
||||
})
|
||||
});
|
||||
source.on('tileloadend', function() {
|
||||
setTimeout(function() {
|
||||
var features = map.getFeaturesAtPixel([96, 96]);
|
||||
document.body.removeChild(target);
|
||||
map.dispose();
|
||||
expect(features).to.be(null);
|
||||
done();
|
||||
}, 200);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -457,6 +457,20 @@ describe('ol.View', function() {
|
||||
}, 10);
|
||||
});
|
||||
|
||||
it('immediately completes for no-op animations', function() {
|
||||
var view = new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 5
|
||||
});
|
||||
|
||||
view.animate({
|
||||
zoom: 5,
|
||||
center: [0, 0],
|
||||
duration: 25
|
||||
});
|
||||
expect(view.getAnimating()).to.eql(false);
|
||||
});
|
||||
|
||||
it('prefers zoom over resolution', function(done) {
|
||||
var view = new ol.View({
|
||||
center: [0, 0],
|
||||
@@ -556,6 +570,21 @@ describe('ol.View', function() {
|
||||
view.setCenter([1, 2]); // interrupt the animation
|
||||
});
|
||||
|
||||
it('calls a callback even if animation is a no-op', function(done) {
|
||||
var view = new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 0
|
||||
});
|
||||
|
||||
view.animate({
|
||||
zoom: 0,
|
||||
duration: 25
|
||||
}, function(complete) {
|
||||
expect(complete).to.be(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('can run multiple animations in series', function(done) {
|
||||
var view = new ol.View({
|
||||
center: [0, 0],
|
||||
@@ -613,7 +642,7 @@ describe('ol.View', function() {
|
||||
expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(2);
|
||||
|
||||
view.animate({
|
||||
rotate: Math.PI,
|
||||
rotation: Math.PI,
|
||||
duration: 25
|
||||
}, decrement);
|
||||
expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(3);
|
||||
@@ -640,7 +669,7 @@ describe('ol.View', function() {
|
||||
expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(2);
|
||||
|
||||
view.animate({
|
||||
rotate: Math.PI,
|
||||
rotation: Math.PI,
|
||||
duration: 25
|
||||
});
|
||||
expect(view.getHints()[ol.ViewHint.ANIMATING]).to.be(3);
|
||||
@@ -1282,3 +1311,74 @@ describe('ol.View', function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ol.View.isNoopAnimation()', function() {
|
||||
|
||||
var cases = [{
|
||||
animation: {
|
||||
sourceCenter: [0, 0], targetCenter: [0, 0],
|
||||
sourceResolution: 1, targetResolution: 1,
|
||||
sourceRotation: 0, targetRotation: 0
|
||||
},
|
||||
noop: true
|
||||
}, {
|
||||
animation: {
|
||||
sourceCenter: [0, 0], targetCenter: [0, 1],
|
||||
sourceResolution: 1, targetResolution: 1,
|
||||
sourceRotation: 0, targetRotation: 0
|
||||
},
|
||||
noop: false
|
||||
}, {
|
||||
animation: {
|
||||
sourceCenter: [0, 0], targetCenter: [0, 0],
|
||||
sourceResolution: 1, targetResolution: 0,
|
||||
sourceRotation: 0, targetRotation: 0
|
||||
},
|
||||
noop: false
|
||||
}, {
|
||||
animation: {
|
||||
sourceCenter: [0, 0], targetCenter: [0, 0],
|
||||
sourceResolution: 1, targetResolution: 1,
|
||||
sourceRotation: 0, targetRotation: 1
|
||||
},
|
||||
noop: false
|
||||
}, {
|
||||
animation: {
|
||||
sourceCenter: [0, 0], targetCenter: [0, 0]
|
||||
},
|
||||
noop: true
|
||||
}, {
|
||||
animation: {
|
||||
sourceCenter: [1, 0], targetCenter: [0, 0]
|
||||
},
|
||||
noop: false
|
||||
}, {
|
||||
animation: {
|
||||
sourceResolution: 1, targetResolution: 1
|
||||
},
|
||||
noop: true
|
||||
}, {
|
||||
animation: {
|
||||
sourceResolution: 0, targetResolution: 1
|
||||
},
|
||||
noop: false
|
||||
}, {
|
||||
animation: {
|
||||
sourceRotation: 10, targetRotation: 10
|
||||
},
|
||||
noop: true
|
||||
}, {
|
||||
animation: {
|
||||
sourceRotation: 0, targetRotation: 10
|
||||
},
|
||||
noop: false
|
||||
}];
|
||||
|
||||
cases.forEach(function(c, i) {
|
||||
it('works for case ' + i, function() {
|
||||
var noop = ol.View.isNoopAnimation(c.animation);
|
||||
expect(noop).to.equal(c.noop);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user