From 371542fb1eafb721fe44fe9fbed3f37f2aeafe5e Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Fri, 2 Apr 2021 19:02:10 +0100 Subject: Caveview enabled - local copy 3MB --- media/jslib/CaveView/lib/BGS.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 media/jslib/CaveView/lib/BGS.js (limited to 'media/jslib/CaveView/lib/BGS.js') diff --git a/media/jslib/CaveView/lib/BGS.js b/media/jslib/CaveView/lib/BGS.js new file mode 100644 index 0000000..f10a0ab --- /dev/null +++ b/media/jslib/CaveView/lib/BGS.js @@ -0,0 +1,35 @@ + +function BGSTileURL ( x, y, z ) { + + var earthRadius = 6378137; // in meters + + var tileCount = Math.pow( 2, z ); + var tileSize = earthRadius * 2 * Math.PI / tileCount; + + var x1, x2, y1, y2; + + x = x - tileCount / 2; + y = tileCount / 2 - y; + + x1 = x * tileSize; + y1 = y * tileSize; + + x2 = x1 + tileSize; + y2 = y1 + tileSize; + + + var url = 'https://map.bgs.ac.uk/arcgis/services/BGS_Detailed_Geology/MapServer/WMSServer?REQUEST=GetMap&VERSION=1.3.0&LAYERS=BGS.50k.Bedrock&STYLES=default&FORMAT=image/png&CRS=EPSG:3857&WIDTH=450&HEIGHT=450'; + var bbox = '&BBOX=' + x1 + ',' + y1 + ',' + x2 + ',' + y2; + + console.log( 'BGS: ', bbox ); + +// var img = document.createElement( 'img' ); + +// img.src = url + bbox; +// img.crossOrigin = ''; + +// document.body.appendChild( img ); + + return url + bbox; + +} \ No newline at end of file -- cgit v1.2.3