Use binaryInsert instead of sort

This commit is contained in:
ahocevar
2013-06-21 17:05:19 +02:00
parent aa62764d90
commit 89c23b5560

View File

@@ -320,14 +320,16 @@ ol.renderer.canvas.VectorLayer.prototype.renderFrame =
var oldResolutions = goog.isNull(this.tileGrid_) ? [] : var oldResolutions = goog.isNull(this.tileGrid_) ? [] :
this.tileGrid_.getResolutions(); this.tileGrid_.getResolutions();
if (!goog.array.contains(oldResolutions, newResolution)) { if (!goog.array.contains(oldResolutions, newResolution)) {
var newResolutions = oldResolutions.concat([]);
goog.array.binaryInsert(newResolutions, newResolution,
function(a, b) { return b - a; });
tileGrid = new ol.tilegrid.TileGrid({ tileGrid = new ol.tilegrid.TileGrid({
origin: [0, 0], origin: [0, 0],
projection: view2DState.projection, projection: view2DState.projection,
resolutions: [newResolution].concat(oldResolutions) resolutions: newResolutions,
.sort(function(a, b) { return b - a; }),
tileSize: [512, 512] tileSize: [512, 512]
}); });
this.updateTileCache_(oldResolutions, tileGrid.getResolutions()); this.updateTileCache_(oldResolutions, newResolutions);
this.tileGrid_ = tileGrid; this.tileGrid_ = tileGrid;
} }
} }