;
        url = this.url;
        url = url.replace('{x}', '{X}');
        url = url.replace('{y}', '{Y}');
        url = url.replace('{z}', '{Z}');
        url = url.replace('{q}', '{Q}');
        url = url.replace('{xmin}', '{XMIN}');
        url = url.replace('{ymin}', '{YMIN}');
        url = url.replace('{xmax}', '{XMAX}');
        url = url.replace('{ymax}', '{YMAX}');
        return this.url = url;
    };
    TileSource.prototype.update = function () {
        var key, ref, results, tile;
        logging_1.logger.debug("TileSource: tile cache count: " + (Object.keys(this.tiles).length));
        ref = this.tiles;
        results = [];
        for (key in ref) {
            tile = ref[key];
            tile.current = false;
            results.push(tile.retain = false);
        }
        return results;
    };
    TileSource.prototype.tile_xyz_to_key = function (x, y, z) {
        var key;
        key = x + ":" + y + ":" + z;
        return key;
    };
    TileSource.prototype.key_to_tile_xyz = function (key) {
        var c;
        return (function () {
            var i, len, ref, results;
            ref = key.split(':');
            results = [];
            for (i = 0, len = ref.length; i < len; i++) {
                c = ref[i];
                results.push(parseInt(c));
            }
            return results;
        })();
    };
    TileSource.prototype.sort_tiles_from_center = function (tiles, tile_extent) {
        var center_x, center_y, txmax, txmin, tymax, tymin;
        txmin = tile_extent[0], tymin = tile_extent[1], txmax = tile_extent[2], tymax = tile_extent[3];
        center_x = (txmax - txmin) / 2 + txmin;
        center_y = (tymax - tymin) / 2 + tymin;
        tiles.sort(function (a, b) {
            var a_distance, b_distance;
            a_distance = Math.sqrt(Math.pow(center_x - a[0], 2) + Math.pow(center_y - a[1], 2));
            b_distance = Math.sqrt(Math.pow(center_x - b[0], 2) + Math.pow(center_y - b[1], 2));
            return a_distance - b_distance;
        });
        ret