From e4393cc4dc131f92c8785c91dea90be755513b02 Mon Sep 17 00:00:00 2001
From: Sean Nichols <seannichols94@gmail.com>
Date: Tue, 6 Jun 2017 15:30:09 -0400
Subject: [PATCH] Use TileSource.getClosestLevel to set TileCache release
 cutoff

---
 src/tiledimage.js | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/tiledimage.js b/src/tiledimage.js
index d705240b..f7080aa7 100644
--- a/src/tiledimage.js
+++ b/src/tiledimage.js
@@ -1468,8 +1468,7 @@ function onTileLoad( tiledImage, tile, time, image, errorMsg, tileRequest ) {
     }
 
     var finish = function() {
-        var cutoff = Math.ceil( Math.log(
-            tiledImage.source.getTileWidth(tile.level) ) / Math.log( 2 ) );
+        var cutoff = tiledImage.source.getClosestLevel();
         setTileLoaded(tiledImage, tile, image, cutoff, tileRequest);
     };