function getArchiveTileURL(bounds) { var res = this.map.getResolution(); var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w)); var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h)); var z = this.map.getZoom(); var limit = Math.pow(2, z); if (y < 0 || y >= limit) { return null; } else { x = ((x % limit) + limit) % limit; var url = this.url; var rnd = Math.floor(Math.random()*10); if(rnd > 9 || rnd < 0) rnd = 0; var path = "0" + rnd + "/" + z + ".zip/"+ x + "-" + y + ".png"; if(z > 5 && z < 10) { var i = Math.floor(x / 64); var j = Math.floor(y / 64); path = "0" + rnd + "/" + z + "-" + i + "-" + j + ".zip/"+ x + "-" + y + ".png"; } else if(z >= 10) { var j = Math.floor(y / 1024); var md5 = hex_md5("" + z + "-" + x + "-" + j).substr(0,2); if(md5 == "2b") md5 = "2B"; path = md5.substr(0,2) + "/" + z + "-" + x + "-" + j + ".zip/" + x + "-" + y + ".png"; } if(url instanceof Array) url = this.selectUrl(path, url); return url + path; } } function lonLatToMercator(ll) { var lon = ll.lon * 20037508.34 / 180; var lat = Math.log(Math.tan((90 + ll.lat) * Math.PI / 360)) / (Math.PI / 180); lat = lat * 20037508.34 / 180; return new OpenLayers.LonLat(lon, lat); } function lonToX(lon, zoom) { return (Math.floor((lon + 180) / 360 * Math.pow(2, zoom))); } function latToY(lat, zoom) { return (Math.floor((1 - Math.log(Math.tan(lat * Math.PI / 180) + 1 / Math.cos(lat * Math.PI / 180)) / Math.PI) / 2 * Math.pow(2, zoom))); } function tileToLon(x, zoom) { return (x / Math.pow(2, zoom) * 360 - 180); } function tileToLat(y, zoom) { var n = Math.PI - 2 * Math.PI * y / Math.pow(2, zoom); return (180 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)))); }