protocol changes 2014-02-22 - quadkeys have gone back to using map zoom, rather than portal level, in their names
This commit is contained in:
@ -10,32 +10,34 @@
|
||||
// http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
|
||||
|
||||
|
||||
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.zoomToTilesPerEdge = function(zoom) {
|
||||
// var LEVEL_TO_TILES_PER_EDGE = [65536, 65536, 16384, 16384, 4096, 1536, 1024, 256, 32];
|
||||
// return LEVEL_TO_TILES_PER_EDGE[level];
|
||||
var ZOOM_TO_TILES_PER_EDGE = [32, 32, 32, 32, 256, 256, 256, 1024, 1024, 1536, 4096, 4096, 16384, 16384, 16384];
|
||||
return ZOOM_TO_TILES_PER_EDGE[zoom] || 65536;
|
||||
}
|
||||
|
||||
|
||||
window.lngToTile = function(lng, level) {
|
||||
return Math.floor((lng + 180) / 360 * levelToTilesPerEdge(level));
|
||||
window.lngToTile = function(lng, zoom) {
|
||||
return Math.floor((lng + 180) / 360 * zoomToTilesPerEdge(zoom));
|
||||
}
|
||||
|
||||
window.latToTile = function(lat, level) {
|
||||
window.latToTile = function(lat, zoom) {
|
||||
return Math.floor((1 - Math.log(Math.tan(lat * Math.PI / 180) +
|
||||
1 / Math.cos(lat * Math.PI / 180)) / Math.PI) / 2 * levelToTilesPerEdge(level));
|
||||
1 / Math.cos(lat * Math.PI / 180)) / Math.PI) / 2 * zoomToTilesPerEdge(zoom));
|
||||
}
|
||||
|
||||
window.tileToLng = function(x, level) {
|
||||
return x / levelToTilesPerEdge(level) * 360 - 180;
|
||||
window.tileToLng = function(x, zoom) {
|
||||
return x / zoomToTilesPerEdge(zoom) * 360 - 180;
|
||||
}
|
||||
|
||||
window.tileToLat = function(y, level) {
|
||||
var n = Math.PI - 2 * Math.PI * y / levelToTilesPerEdge(level);
|
||||
window.tileToLat = function(y, zoom) {
|
||||
var n = Math.PI - 2 * Math.PI * y / zoomToTilesPerEdge(zoom);
|
||||
return 180 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
|
||||
}
|
||||
|
||||
window.pointToTileId = function(level, x, y) {
|
||||
return level + "_" + x + "_" + y;
|
||||
window.pointToTileId = function(zoom, x, y) {
|
||||
return zoom + "_" + x + "_" + y;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user