[ Launch: HAW - Next Media - Tile Rechnerei ] 5693924 by Salzig
-
-
Save salzig/5693924 to your computer and use it in GitHub Desktop.
HAW - Next Media - Tile Rechnerei
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"HAW - Next Media - Tile Rechnerei","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.clear(); | |
var center_long = 9.9649 | |
var center_lat = 53.5496 | |
var zoom = 21 | |
var bounding_long_0 = 9.935 | |
var bounding_long_1 = 9.99 | |
var bounding_lat_0 = 53.5374 | |
var bounding_lat_1 = 53.57 | |
var bounding_long_0_tile = long2tile(bounding_long_0, zoom) | |
var bounding_long_1_tile = long2tile(bounding_long_1, zoom) | |
var bounding_lat_0_tile = lat2tile(bounding_lat_0, zoom) | |
var bounding_lat_1_tile = lat2tile(bounding_lat_1, zoom) | |
console.log("BoundingBox Long 0 Tile:",bounding_long_0_tile); | |
console.log("BoundingBox Long 1 Tile:",bounding_long_1_tile); | |
console.log("BoundingBox Long 0 Long:", tile2long(bounding_long_0_tile, 21)) | |
console.log("BoundingBox Long 1 Long:", tile2long(bounding_long_1_tile, 21)) | |
console.log("BoundingBox Lat 0 Tile:",bounding_lat_0_tile); | |
console.log("BoundingBox Lat 1 Tile:",bounding_lat_1_tile); | |
console.log("BoundingBox Lat 0 Lat:", tile2lat(bounding_lat_0_tile, 21)) | |
console.log("BoundingBox Lat 1 Lat:", tile2lat(bounding_lat_1_tile, 21)) | |
console.log("Tiles Wide: ", bounding_long_1_tile - bounding_long_0_tile) | |
console.log("Tiles High: ", bounding_lat_0_tile - bounding_lat_1_tile) | |
function long2tile(lon,zoom) { | |
return (Math.floor((lon+180)/360*Math.pow(2,zoom))); | |
} | |
function lat2tile(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 tile2long(x,z) { | |
return (x/Math.pow(2,z)*360-180); | |
} | |
function tile2lat(y,z) { | |
var n=Math.PI-2*Math.PI*y/Math.pow(2,z); | |
return (180/Math.PI*Math.atan(0.5*(Math.exp(n)-Math.exp(-n)))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment