only use one extent if two are passed

This commit is contained in:
mike-000
2020-03-30 14:51:27 +01:00
committed by Andreas Hocevar
parent a35794ae97
commit 48b79cf7d1

View File

@@ -479,11 +479,25 @@ class Graticule extends VectorLayer {
* @return {Array<import("../extent.js").Extent>} Extents.
*/
strategyFunction(extent, resolution) {
if (this.loadedExtent_ && !equals(this.loadedExtent_, extent)) {
// extents may be passed in different worlds, to avoid endless loop we use only one
const realExtent = extent.slice();
if (this.projection_) {
const center = getCenter(extent);
const projectionExtent = this.projection_.getExtent();
const worldWidth = getWidth(projectionExtent);
if (this.getSource().getWrapX() && this.projection_.canWrapX() && !containsExtent(projectionExtent, extent)) {
const worldsAway = Math.floor((center[0] - projectionExtent[0]) / worldWidth);
realExtent[0] -= (worldsAway * worldWidth);
realExtent[2] -= (worldsAway * worldWidth);
}
realExtent[0] = Math.round(realExtent[0] * 1e6) / 1e6;
realExtent[2] = Math.round(realExtent[2] * 1e6) / 1e6;
}
if (this.loadedExtent_ && !equals(this.loadedExtent_, realExtent)) {
// we should not keep track of loaded extents
this.getSource().removeLoadedExtent(this.loadedExtent_);
}
return [extent];
return [realExtent];
}
/**