Initial commit
This commit is contained in:
28
node_modules/@mapbox/whoots-js/CHANGELOG.md
generated
vendored
Normal file
28
node_modules/@mapbox/whoots-js/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
_Breaking changes, which may affect downstream projects are marked with a_ :warning:
|
||||
|
||||
## 3.1.0
|
||||
##### 2018-Jul-12
|
||||
* Replace legacy Rollup `jsnext:main` with now standard `module` ([#74])
|
||||
* :warning: Drop support for Node 4
|
||||
|
||||
[#74]: https://github.com/mapbox/whoots-js/issues/74
|
||||
|
||||
## 3.0.0
|
||||
##### 2017-Feb-13
|
||||
* :warning: whoots-js is now a scoped package under the @mapbox namespace
|
||||
|
||||
## 2.1.0
|
||||
##### Jul 15, 2016
|
||||
* Release as ES6 module alongside UMD build, add `jsnext:main` to `package.json`
|
||||
|
||||
## 2.0.0
|
||||
##### Jun 1, 2016
|
||||
* :warning: Refactor for a classless API
|
||||
|
||||
## 1.1.0
|
||||
##### May 23, 2016
|
||||
* Make getTileBbox and getMercCoords public
|
||||
|
||||
## 1.0.0
|
||||
##### May 23, 2016
|
||||
* Initial release
|
||||
15
node_modules/@mapbox/whoots-js/LICENSE.md
generated
vendored
Normal file
15
node_modules/@mapbox/whoots-js/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
ISC License
|
||||
|
||||
Copyright (c) 2017, Mapbox
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose
|
||||
with or without fee is hereby granted, provided that the above copyright notice
|
||||
and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
53
node_modules/@mapbox/whoots-js/README.md
generated
vendored
Normal file
53
node_modules/@mapbox/whoots-js/README.md
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
[](https://badge.fury.io/js/%40mapbox%2Fwhoots-js)
|
||||
[](http://travis-ci.org/mapbox/whoots-js)
|
||||
[](https://coveralls.io/github/mapbox/whoots-js?branch=master)
|
||||
|
||||
|
||||
## whoots-js
|
||||
|
||||
Request tiles from WMS servers that support EPSG:3857.
|
||||
|
||||
This project is a JavaScript port of https://github.com/timwaters/whoots by Tim Waters.
|
||||
|
||||
|
||||
### What is it?
|
||||
|
||||
Given a `z/x/y` tile coordinate like `19/154308/197167`, `whoots-js` can request imagery from an EPSG:3857 supporting WMS server like this:
|
||||
|
||||
```
|
||||
http://geodata.state.nj.us/imagerywms/Natural2015?
|
||||
bbox=-8242663.382160267,4966572.349857613,-8242586.945131982,4966648.786885899
|
||||
&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857
|
||||
&width=256&height=256&layers=Natural2015
|
||||
```
|
||||
|
||||
|
||||
### Usage
|
||||
|
||||
```js
|
||||
var WhooTS = require('@mapbox/whoots-js');
|
||||
|
||||
// Get an image url for a given tile coordinate
|
||||
var baseUrl = 'http://geodata.state.nj.us/imagerywms/Natural2015';
|
||||
var layer = 'Natural2015';
|
||||
var url = WhooTS.getURL(baseUrl, layer, 154308, 197167, 19);
|
||||
```
|
||||
|
||||
|
||||
### Server
|
||||
|
||||
This project includes a sample redirecting wms proxy server in `server.js`.
|
||||
|
||||
`npm run server` will start a local server on port 8080 that redirects tile requests.
|
||||
|
||||
Valid tile requests look like:
|
||||
|
||||
```
|
||||
http://localhost:8080/tms/{z}/{x}/{y}/{layer}/{endpoint}
|
||||
http://localhost:8080/tms/19/154308/197167/Natural2015/http://geodata.state.nj.us/imagerywms/Natural2015
|
||||
```
|
||||
|
||||
|
||||
### Documentation
|
||||
|
||||
Complete API documentation is here: http://mapbox.github.io/whoots-js/
|
||||
88
node_modules/@mapbox/whoots-js/index.js
generated
vendored
Normal file
88
node_modules/@mapbox/whoots-js/index.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(factory((global.WhooTS = {})));
|
||||
}(this, (function (exports) {
|
||||
/**
|
||||
* getURL
|
||||
*
|
||||
* @param {String} baseUrl Base url of the WMS server
|
||||
* @param {String} layer Layer name
|
||||
* @param {Number} x Tile coordinate x
|
||||
* @param {Number} y Tile coordinate y
|
||||
* @param {Number} z Tile zoom
|
||||
* @param {Object} [options]
|
||||
* @param {String} [options.format='image/png']
|
||||
* @param {String} [options.service='WMS']
|
||||
* @param {String} [options.version='1.1.1']
|
||||
* @param {String} [options.request='GetMap']
|
||||
* @param {String} [options.srs='EPSG:3857']
|
||||
* @param {Number} [options.width='256']
|
||||
* @param {Number} [options.height='256']
|
||||
* @returns {String} url
|
||||
* @example
|
||||
* var baseUrl = 'http://geodata.state.nj.us/imagerywms/Natural2015';
|
||||
* var layer = 'Natural2015';
|
||||
* var url = whoots.getURL(baseUrl, layer, 154308, 197167, 19);
|
||||
*/
|
||||
function getURL(baseUrl, layer, x, y, z, options) {
|
||||
options = options || {};
|
||||
|
||||
var url = baseUrl + '?' + [
|
||||
'bbox=' + getTileBBox(x, y, z),
|
||||
'format=' + (options.format || 'image/png'),
|
||||
'service=' + (options.service || 'WMS'),
|
||||
'version=' + (options.version || '1.1.1'),
|
||||
'request=' + (options.request || 'GetMap'),
|
||||
'srs=' + (options.srs || 'EPSG:3857'),
|
||||
'width=' + (options.width || 256),
|
||||
'height=' + (options.height || 256),
|
||||
'layers=' + layer
|
||||
].join('&');
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getTileBBox
|
||||
*
|
||||
* @param {Number} x Tile coordinate x
|
||||
* @param {Number} y Tile coordinate y
|
||||
* @param {Number} z Tile zoom
|
||||
* @returns {String} String of the bounding box
|
||||
*/
|
||||
function getTileBBox(x, y, z) {
|
||||
// for Google/OSM tile scheme we need to alter the y
|
||||
y = (Math.pow(2, z) - y - 1);
|
||||
|
||||
var min = getMercCoords(x * 256, y * 256, z),
|
||||
max = getMercCoords((x + 1) * 256, (y + 1) * 256, z);
|
||||
|
||||
return min[0] + ',' + min[1] + ',' + max[0] + ',' + max[1];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getMercCoords
|
||||
*
|
||||
* @param {Number} x Pixel coordinate x
|
||||
* @param {Number} y Pixel coordinate y
|
||||
* @param {Number} z Tile zoom
|
||||
* @returns {Array} [x, y]
|
||||
*/
|
||||
function getMercCoords(x, y, z) {
|
||||
var resolution = (2 * Math.PI * 6378137 / 256) / Math.pow(2, z),
|
||||
merc_x = (x * resolution - 2 * Math.PI * 6378137 / 2.0),
|
||||
merc_y = (y * resolution - 2 * Math.PI * 6378137 / 2.0);
|
||||
|
||||
return [merc_x, merc_y];
|
||||
}
|
||||
|
||||
exports.getURL = getURL;
|
||||
exports.getTileBBox = getTileBBox;
|
||||
exports.getMercCoords = getMercCoords;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
78
node_modules/@mapbox/whoots-js/index.mjs
generated
vendored
Normal file
78
node_modules/@mapbox/whoots-js/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
export { getURL, getTileBBox, getMercCoords };
|
||||
|
||||
|
||||
/**
|
||||
* getURL
|
||||
*
|
||||
* @param {String} baseUrl Base url of the WMS server
|
||||
* @param {String} layer Layer name
|
||||
* @param {Number} x Tile coordinate x
|
||||
* @param {Number} y Tile coordinate y
|
||||
* @param {Number} z Tile zoom
|
||||
* @param {Object} [options]
|
||||
* @param {String} [options.format='image/png']
|
||||
* @param {String} [options.service='WMS']
|
||||
* @param {String} [options.version='1.1.1']
|
||||
* @param {String} [options.request='GetMap']
|
||||
* @param {String} [options.srs='EPSG:3857']
|
||||
* @param {Number} [options.width='256']
|
||||
* @param {Number} [options.height='256']
|
||||
* @returns {String} url
|
||||
* @example
|
||||
* var baseUrl = 'http://geodata.state.nj.us/imagerywms/Natural2015';
|
||||
* var layer = 'Natural2015';
|
||||
* var url = whoots.getURL(baseUrl, layer, 154308, 197167, 19);
|
||||
*/
|
||||
function getURL(baseUrl, layer, x, y, z, options) {
|
||||
options = options || {};
|
||||
|
||||
var url = baseUrl + '?' + [
|
||||
'bbox=' + getTileBBox(x, y, z),
|
||||
'format=' + (options.format || 'image/png'),
|
||||
'service=' + (options.service || 'WMS'),
|
||||
'version=' + (options.version || '1.1.1'),
|
||||
'request=' + (options.request || 'GetMap'),
|
||||
'srs=' + (options.srs || 'EPSG:3857'),
|
||||
'width=' + (options.width || 256),
|
||||
'height=' + (options.height || 256),
|
||||
'layers=' + layer
|
||||
].join('&');
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getTileBBox
|
||||
*
|
||||
* @param {Number} x Tile coordinate x
|
||||
* @param {Number} y Tile coordinate y
|
||||
* @param {Number} z Tile zoom
|
||||
* @returns {String} String of the bounding box
|
||||
*/
|
||||
function getTileBBox(x, y, z) {
|
||||
// for Google/OSM tile scheme we need to alter the y
|
||||
y = (Math.pow(2, z) - y - 1);
|
||||
|
||||
var min = getMercCoords(x * 256, y * 256, z),
|
||||
max = getMercCoords((x + 1) * 256, (y + 1) * 256, z);
|
||||
|
||||
return min[0] + ',' + min[1] + ',' + max[0] + ',' + max[1];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getMercCoords
|
||||
*
|
||||
* @param {Number} x Pixel coordinate x
|
||||
* @param {Number} y Pixel coordinate y
|
||||
* @param {Number} z Tile zoom
|
||||
* @returns {Array} [x, y]
|
||||
*/
|
||||
function getMercCoords(x, y, z) {
|
||||
var resolution = (2 * Math.PI * 6378137 / 256) / Math.pow(2, z),
|
||||
merc_x = (x * resolution - 2 * Math.PI * 6378137 / 2.0),
|
||||
merc_y = (y * resolution - 2 * Math.PI * 6378137 / 2.0);
|
||||
|
||||
return [merc_x, merc_y];
|
||||
}
|
||||
33
node_modules/@mapbox/whoots-js/package.json
generated
vendored
Normal file
33
node_modules/@mapbox/whoots-js/package.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@mapbox/whoots-js",
|
||||
"description": "Request tiles from WMS servers that support EPSG:3857",
|
||||
"version": "3.1.0",
|
||||
"main": "index.js",
|
||||
"module": "index.mjs",
|
||||
"license": "ISC",
|
||||
"author": "Bryan Housel <bryan@mapbox.com>",
|
||||
"repository": "mapbox/whoots-js",
|
||||
"keywords": [
|
||||
"WMS",
|
||||
"tiles",
|
||||
"EPSG:3857"
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"coveralls": "^3.0.0",
|
||||
"documentation": "4.0.0-beta5",
|
||||
"eslint": "^5.0.0",
|
||||
"rollup": "0.60.0",
|
||||
"tap": "^12.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup -f umd -n WhooTS index.mjs --no-indent --no-strict -o index.js",
|
||||
"docs": "documentation build index.mjs --lint --github --format html --output docs/",
|
||||
"lint": "eslint index.mjs server.js test",
|
||||
"start": "node server.js",
|
||||
"test": "npm run lint && npm run build && tap --cov test/*.js"
|
||||
}
|
||||
}
|
||||
40
node_modules/@mapbox/whoots-js/server.js
generated
vendored
Normal file
40
node_modules/@mapbox/whoots-js/server.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
var WhooTS = require('./');
|
||||
var http = require('http');
|
||||
var url = require('url');
|
||||
|
||||
var PORT = 8080;
|
||||
|
||||
// valid requests look like:
|
||||
// http://localhost:8080/tms/{z}/{x}/{y}/{layer}/{baseUrl}
|
||||
// http://localhost:8080/tms/19/154308/197167/Natural2015/http://geodata.state.nj.us/imagerywms/Natural2015
|
||||
function handleRequest(request, response) {
|
||||
var pathname = url.parse(request.url, true).pathname;
|
||||
var params = pathname.split('/');
|
||||
|
||||
if (params.length > 6 && params[1].toLowerCase() === 'tms') {
|
||||
var z = +params[2],
|
||||
x = +params[3],
|
||||
y = +params[4],
|
||||
layer = params[5],
|
||||
baseUrl = pathname.replace(params.slice(0,6).join('/') + '/', '');
|
||||
|
||||
if (!isNaN(z) && !isNaN(x) && !isNaN(y) && layer && url.parse(baseUrl).protocol) {
|
||||
response.writeHead(302, { 'Location': WhooTS.getURL(baseUrl, layer, x, y, z) });
|
||||
response.end('Redirect');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
response.statusCode = '404';
|
||||
response.end('Not Found');
|
||||
}
|
||||
|
||||
|
||||
var server = http.createServer(handleRequest);
|
||||
server.listen(PORT, function() {
|
||||
/* eslint-disable no-console */
|
||||
console.log('Server listening on: http://localhost:%s', PORT);
|
||||
/* eslint-enable no-console */
|
||||
});
|
||||
Reference in New Issue
Block a user