Give up loading this (definitively, unexpectedly bad) tile and possibly give up on this layer entirely.
546535
function failTile(e) {
        ++tileFailures;

        if (
          tileFailures > 5 &&
          defined(layer) &&
          globeOrMap.isImageryLayerShown({ layer })
        ) {
          // Too many failures, display an error message and hide the layer.
          if (
            catalogItem === catalogItem.terria.baseMap ||
            (catalogItem.terria.baseMap instanceof CompositeCatalogItem &&
              catalogItem.terria.baseMap.items.indexOf(catalogItem) >= 0)
          ) {
            globeOrMap.terria.error.raiseEvent(
              new TerriaError({
                sender: catalogItem,
                title: "Error accessing base map",
                message:
                  "An error occurred while attempting to download tiles for base map:<p><center>" +
                  catalogItem.terria.baseMap.name +
                  "</center></p> This may indicate that there is a " +
                  "problem with your internet connection, that the base map is temporarily unavailable, or that the base map " +
                  "is invalid.  Please select a different base map using the Map button in the top-right corner.  Further technical details may be found below.<br/><br/>" +
                  "<pre>" +
                  formatError(e) +
                  "</pre>"
              })
            );

            globeOrMap.hideImageryLayer({
              layer: layer
            });
            catalogItem.terria.baseMap = undefined;

            // Don't use this base map again on startup.
            catalogItem.terria.setLocalProperty("basemap", undefined);
          } else {
            globeOrMap.terria.error.raiseEvent(
              new TerriaError({
                sender: catalogItem,
                title: "Error accessing catalogue item",
                message:
                  "An error occurred while attempting to download tiles for catalogue item:<p><center>" +
                  catalogItem.name +
                  "</center></p> This may indicate that there is a " +
                  "problem with your internet connection, that the catalogue item is temporarily unavailable, or that the catalogue item " +
                  "is invalid.  The catalogue item has been hidden from the map.  You may re-show it in the Now Viewing panel to try again.  Further technical details may be found below.<br/><br/>" +
                  "<pre>" +
                  formatError(e) +
                  "</pre>"
              })
            );

            if (globeOrMap === catalogItem.terria.currentViewer) {
              catalogItem.isShown = false;
            } else {
              globeOrMap.hideImageryLayer({
                layer: layer
              });
            }
          }
        }

        tellMapToSilentlyGiveUp();
      }
784571
function(layer) {
    var me          = this.toJSON()
      , other       = layer.toJSON()
      // Select params generated when layer is added to the map
      , map_params  = ['id', 'order'];

    // Delete from the layers copy
    _.each(map_params, function(param){
      delete me[param];
      delete other[param];
      if (me.options)     delete me.options[param];
      if (other.options)  delete other.options[param];
    });

    var myType  = me.type? me.type : me.options.type
      , itsType = other.type? other.type : other.options.type;

    if(myType && (myType === itsType)) {

      if(myType === 'Tiled') {
        var myTemplate  = me.urlTemplate? me.urlTemplate : me.options.urlTemplate;
        var itsTemplate = other.urlTemplate? other.urlTemplate : other.options.urlTemplate;
        var myName = me.name? me.name : me.options.name;
        var itsName = other.name? other.name : other.options.name;

        return myTemplate === itsTemplate && myName === itsName;
      } else if(myType === 'WMS') {
        var myTemplate  = me.urlTemplate? me.urlTemplate : me.options.urlTemplate;
        var itsTemplate = other.urlTemplate? other.urlTemplate : other.options.urlTemplate;
        var myLayer  = me.layers? me.layers : me.options.layers;
        var itsLayer = other.layers? other.layers : other.options.layers;
        return myTemplate === itsTemplate && myLayer === itsLayer;
      }
      else if (myType === 'torque') {
        return cdb.geo.TorqueLayer.prototype.isEqual.call(this, layer);
      }
      else if (myType === 'named_map') {
        return cdb.geo.CartoDBNamedMapLayer.prototype.isEqual.call(this, layer);
      } else { // same type but not tiled
        var myBaseType = me.base_type? me.base_type : me.options.base_type;
        var itsBaseType = other.base_type? other.base_type : other.options.base_type;
        if(myBaseType) {
          if(_.isEqual(me,other)) {
            return true;
          } else {
            return false;
          }
        } else { // not gmaps
          return true;
        }
      }
    }
    return false; // different type
  }
75095
function () {
        if (this.hatchInterval) clearInterval(this.hatchInterval); // stop hatching animation
        if (this.cvsDiv) {
            this.clear();
        }
        OpenLayers.Tile.prototype.destroy.call(this);
    }
1325363
function(tile) {
        tile.unload();
        tile.events.un({
            "loadstart": tile.onLoadStart,
            "loadend": tile.onLoadEnd,
            "unload": tile.onLoadEnd,
            "loaderror": tile.onLoadError,
            scope: this
        });
    }
369450
function(tile) {
    var x = tile.x;
    var y = tile.y;
    var xUp = x + 1 < xUpperBound;
    var xDown = x >= 0;
    var yUp = y + 1 < yUpperBound;
    var yDown = y >= 0;

    var adjacents = [];
    if (xUp) {
      adjacents.push({x: x + 1, y: y});
      if (yUp) {
        adjacents.push({x: x + 1, y: y + 1});
      }
      if (yDown) {
        adjacents.push({x: x + 1, y: y - 1});
      }
    }
    if (xDown) {
      adjacents.push({x: x - 1, y: y});
      if (yUp) {
        adjacents.push({x: x - 1, y: y + 1});
      }
      if (yDown) {
        adjacents.push({x: x - 1, y: y - 1});
      }
    }
    if (yUp) {
      adjacents.push({x: x, y: y + 1});
    }
    if (yDown) {
      adjacents.push({x: x, y: y - 1});
    }
    return adjacents;
  }
1303737
function(evt) {
        evt.layer.events.on({
            tileloadstart: this.makeSameOrigin,
            tileloaded: this.onTileLoaded,
            scope: this
        });        
    }
1301129
function drawTileLayer(renderer, layer, rect) {
         // get top-left and bottom-right tile position
         var start = this.pixelToTileCoords(rect.pos.x, rect.pos.y, me.pool.pull("me.Vector2d")).floorSelf();
         var end = this.pixelToTileCoords(rect.pos.x + rect.width + this.tilewidth, rect.pos.y + rect.height + this.tileheight, me.pool.pull("me.Vector2d")).ceilSelf(); //ensure we are in the valid tile range

         start.x = start.x < 0 ? 0 : start.x;
         start.y = start.y < 0 ? 0 : start.y;
         end.x = end.x > this.cols ? this.cols : end.x;
         end.y = end.y > this.rows ? this.rows : end.y; // main drawing loop

         for (var y = start.y; y < end.y; y++) {
           for (var x = start.x; x < end.x; x++) {
             var tmxTile = layer.layerData[x][y];

             if (tmxTile) {
               this.drawTile(renderer, x, y, tmxTile);
             }
           }
         }

         me.pool.push(start);
         me.pool.push(end);
       }
394803
function(layer, b) {
    // shift arguments to maintain caompatibility
    if(b == undefined) {
      b = layer;
      layer = 0;
    }
    var layerInteraction;
    this.interactionEnabled[layer] = b;
    if(!b) {
      layerInteraction = this.interaction[layer];
      if(layerInteraction) {
        layerInteraction.remove();
        this.interaction[layer] = null;
      }
    } else {
      // if urls is null it means that setInteraction will be called
      // when the layergroup token was recieved, then the real interaction
      // layer will be created
      if(this.urls) {
        // generate the tilejson from the urls. wax needs it
        var layer_index = this.getLayerIndexByNumber(+layer);
        var tilejson = this._tileJSONfromTiles(layer_index, this.urls);

        // remove previous
        layerInteraction = this.interaction[layer];
        if(layerInteraction) {
          layerInteraction.remove();
        }
        var self = this;

        // add the new one
        this.interaction[layer] = this.interactionClass()
          .map(this.options.map)
          .tilejson(tilejson)
          .on('on', function(o) {
            if (self._interactionDisabled) return;
            o.layer = +layer;
            self._manageOnEvents(self.options.map, o);
          })
          .on('off', function(o) {
            if (self._interactionDisabled) return;
            o = o || {}
            o.layer = +layer;
            self._manageOffEvents(self.options.map, o);
          });
      }
    }
    return this;
  }
490111
function (layer) {
            var bounds = layer instanceof me.TMXLayer ? me.pool.pull("me.Rect", 0, 0, 0, 0) : this.bounds;

            // origin is always 0 for finite maps
            bounds.pos.set(0, 0);
            // The map size is the same regardless of which indexes are shifted.
            if (this.staggerX) {
                bounds.resize(
                    this.cols * this.columnwidth + this.sideoffsetx,
                    this.rows * (this.tileheight + this.sidelengthy)
                );
                if (bounds.width > 1) {
                    bounds.height += this.rowheight;
                }
            } else {
                bounds.resize(
                    this.cols * (this.tilewidth + this.sidelengthx),
                    this.rows * this.rowheight + this.sideoffsety
                );
                if (bounds.height > 1) {
                    bounds.width += this.columnwidth;
                }
            }
            return bounds;
        }
1148969
function() {
        for (var key in this.layerCache) {
            delete this.layerCache[key];
        }
        for (var key in this.wfsCache) {
            delete this.wfsCache[key];
        }
        OpenLayers.Control.prototype.destroy.apply(this, arguments);
    }
151738
def unload():
        """"""
        global __tile_maps
        global active_map
        if TileMapManager.active_map != None:
            world = Ragnarok.get_world()

            for obj in TileMapManager.active_map.objects:
                world.remove_obj(obj)
            world.remove_obj(TileMapManager.active_map)
687973
def tilelayer_preview(tilelayer):
    
    output = '<img src="{src}" alt="{alt}" title="{title}" />'
    url = tilelayer.url_template.format(s="a", z=9, x=265, y=181)
    output = output.format(src=url, alt=tilelayer.name, title=tilelayer.name)
    return output
1223127
def tilecache(self, event, *args, **kwargs):
        """"""
        request, response = event.args[:2]
        self.log(request.path, lvl=verbose)
        try:
            filename, url = self._split_cache_url(request.path, 'tilecache')
        except UrlError:
            return

        # self.log('CACHE QUERY:', filename, url)

        # Do we have the tile already?
        if os.path.isfile(filename):
            self.log("Tile exists in cache", lvl=verbose)
            # Don't set cookies for static content
            response.cookie.clear()
            try:
                yield serve_file(request, response, filename)
            finally:
                event.stop()
        else:
            # We will have to get it first.
            self.log("Tile not cached yet. Tile data: ", filename, url,
                     lvl=verbose)
            if url in self._tiles:
                self.log("Getting a tile for the second time?!", lvl=error)
            else:
                self._tiles += url
            try:
                tile, log = yield self.call(task(get_tile, url), "tcworkers")
                if log:
                    self.log("Thread error: ", log, lvl=error)
            except Exception as e:
                self.log("[MTS]", e, type(e))
                tile = None

            tile_path = os.path.dirname(filename)

            if tile:
                try:
                    os.makedirs(tile_path)
                except OSError as e:
                    if e.errno != errno.EEXIST:
                        self.log(
                            "Couldn't create path: %s (%s)" % (e, type(e)), lvl=error)

                self.log("Caching tile.", lvl=verbose)
                try:
                    with open(filename, "wb") as tile_file:
                        try:
                            tile_file.write(bytes(tile))
                        except Exception as e:
                            self.log("Writing error: %s" % str([type(e), e]), lvl=error)

                except Exception as e:
                    self.log("Open error on %s - %s" % (filename, str([type(e), e])), lvl=error)
                    return
                finally:
                    event.stop()

                try:
                    self.log("Delivering tile.", lvl=verbose)
                    yield serve_file(request, response, filename)
                except Exception as e:
                    self.log("Couldn't deliver tile: ", e, lvl=error)
                    event.stop()
                self.log("Tile stored and delivered.", lvl=verbose)
            else:
                self.log("Got no tile, serving default tile: %s" % url)
                if self.default_tile:
                    try:
                        yield serve_file(request, response, self.default_tile)
                    except Exception as e:
                        self.log('Cannot deliver default tile:', e, type(e),
                                 exc=True, lvl=error)
                    finally:
                        event.stop()
                else:
                    yield
614447
@Override
    public void destroyAll() {
        for (Layer layer : this.layerManager.getLayers()) {
            this.layerManager.getLayers().remove(layer);
            layer.onDestroy();
            if (layer instanceof TileLayer) {
                ((TileLayer<?>) layer).getTileCache().destroy();
            }
            if (layer instanceof TileRendererLayer) {
                LabelStore labelStore = ((TileRendererLayer) layer).getLabelStore();
                if (labelStore != null) {
                    labelStore.clear();
                }
            }
        }
        destroy();
    }
1089258
def stop(self):
        """"""

        for tile in self._tiles.values():
            tile.signal_stop()

        for tile in self._tiles.values():
            tile.wait_stopped()

        super(TileBasedVirtualDevice, self).stop()
584129
def reload(self):
		
		oldlayers = self.layers
		self.layers = []
		for cp, filename, fp in oldlayers:
			cp = cp # pylint
			if fp is None:
				self.read(filename)
			else:
				self.readfp(fp, filename)
107504
function() {
        if (this.tile) {
            this.removeTileMonitoringHooks(this.tile);
            this.tile.destroy();
            this.tile = null;
        }
        OpenLayers.Layer.prototype.destroy.apply(this, arguments);
    }