update code to match stock site changes 2013-10-16

- new munge set
- modified map data tile ID/QK - now based on portal level rather than map zoom
This commit is contained in:
Jon Atkins
2013-10-16 03:11:19 +01:00
parent c3b6461d47
commit 1eea47ca99
3 changed files with 65 additions and 51 deletions

View File

@ -9,26 +9,33 @@
// Convertion functions courtesy of
// http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
window.lngToTile = function(lng, zoom) {
return Math.floor((lng + 180) / 360 * Math.pow(2, (zoom>12)?zoom:(zoom+2)));
window.levelToTilesPerEdge = function(level) {
var LEVEL_TO_TILES_PER_EDGE = [65536, 65536, 16384, 16384, 4096, 1536, 1024, 256, 32];
return LEVEL_TO_TILES_PER_EDGE[level];
}
window.latToTile = function(lat, zoom) {
window.lngToTile = function(lng, level) {
return Math.floor((lng + 180) / 360 * levelToTilesPerEdge(level));
}
window.latToTile = function(lat, level) {
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>12)?zoom:(zoom+2)));
1 / Math.cos(lat * Math.PI / 180)) / Math.PI) / 2 * levelToTilesPerEdge(level));
}
window.tileToLng = function(x, zoom) {
return x / Math.pow(2, (zoom>12)?zoom:(zoom+2)) * 360 - 180;
window.tileToLng = function(x, level) {
return x / levelToTilesPerEdge(level) * 360 - 180;
}
window.tileToLat = function(y, zoom) {
var n = Math.PI - 2 * Math.PI * y / Math.pow(2, (zoom>12)?zoom:(zoom+2));
window.tileToLat = function(y, level) {
var n = Math.PI - 2 * Math.PI * y / levelToTilesPerEdge(level);
return 180 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
}
window.pointToTileId = function(zoom, x, y) {
return zoom + "_" + x + "_" + y;
window.pointToTileId = function(level, x, y) {
return level + "_" + x + "_" + y;
}
// given tile id and bounds, returns the format as required by the