slippy-tile
Advanced tools
Comparing version 1.10.2 to 1.11.0
# Changelog | ||
## 1.11.0 - 2017-03-08 | ||
- Convert module back to CommonJS | ||
- Dropped Mapbox, DigitalGlobe & Strava (due to API keys being required) | ||
## 1.10.0 - 2017-02-18 | ||
@@ -5,0 +10,0 @@ |
@@ -0,0 +0,0 @@ export interface Provider { |
46
index.js
@@ -1,4 +0,7 @@ | ||
import { googleToBBox, googleToTile, googleToQuadkey, bboxToMeters } from 'global-mercator' | ||
import * as providers from './providers' | ||
export { providers } | ||
const providers = require('./providers') | ||
const mercator = require('global-mercator') | ||
const googleToBBox = mercator.googleToBBox | ||
const googleToTile = mercator.googleToTile | ||
const googleToQuadkey = mercator.googleToQuadkey | ||
const bboxToMeters = mercator.bboxToMeters | ||
@@ -12,8 +15,6 @@ /** | ||
* @example | ||
* var tile = [10, 15, 8] | ||
* var url = 'https://{s}.tile.openstreetmap.org/{zoom}/{x}/{y}.png' | ||
* parse(tile, url) | ||
* slippyTile.parse([10, 15, 8], 'https://{s}.tile.openstreetmap.org/{zoom}/{x}/{y}.png') | ||
* //='https://c.tile.openstreetmap.org/8/10/15.png' | ||
*/ | ||
export function parse (tile, url) { | ||
function parse (tile, url) { | ||
var x = tile[0] | ||
@@ -37,2 +38,3 @@ var y = tile[1] | ||
* | ||
* @private | ||
* @param {Tile} tile Tile [x, y, z] | ||
@@ -42,8 +44,6 @@ * @param {string} url WMTS URL scheme | ||
* @example | ||
* var tile = [10, 15, 8] | ||
* var url = 'https://<Tile Server>/?layers=imagery&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}' | ||
* wms(tile, url) | ||
* slippyTile.wms([10, 15, 8], 'https://<Tile Server>/?layers=imagery&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}') | ||
* //='https://<Tile Server>/?layers=imagery&SRS=EPSG:3857&WIDTH=256&HEIGHT=256&BBOX=-165.9375,82.676285,-164.53125,82.853382' | ||
*/ | ||
export function wms (tile, url) { | ||
function wms (tile, url) { | ||
url = url.replace(/{height}/gi, '256') | ||
@@ -66,9 +66,10 @@ url = url.replace(/{width}/gi, '256') | ||
* | ||
* @private | ||
* @param {string} url WMTS URL scheme | ||
* @returns {string} | ||
* @example | ||
* wmts('https://<Tile Server>/WMTS/tile/1.0.0/Imagery/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpg') | ||
* slippyTile.wmts('https://<Tile Server>/WMTS/tile/1.0.0/Imagery/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpg') | ||
* //='https://<Tile Server>/WMTS/tile/1.0.0/Imagery/default/GoogleMapsCompatible/{z}/{y}/{x}.jpg' | ||
*/ | ||
export function wmts (url) { | ||
function wmts (url) { | ||
url = url.replace(/{TileCol}/gi, '{x}') | ||
@@ -85,9 +86,10 @@ url = url.replace(/{TileRow}/gi, '{y}') | ||
* | ||
* @private | ||
* @param {string} url - URL Scheme | ||
* @returns {string} Parsed URL with switch replaced | ||
* @example | ||
* parseSwitch('http://tile-{switch:a,b,c}.openstreetmap.fr/hot/{zoom}/{x}/{y}.png') | ||
* slippyTile.parseSwitch('http://tile-{switch:a,b,c}.openstreetmap.fr/hot/{zoom}/{x}/{y}.png') | ||
* //='http://tile-b.openstreetmap.fr/hot/{zoom}/{x}/{y}.png' | ||
*/ | ||
export function parseSwitch (url) { | ||
function parseSwitch (url) { | ||
// Default simple switch | ||
@@ -109,11 +111,15 @@ if (url.match(/{s}/)) { | ||
* | ||
* @private | ||
* @name sample | ||
* @param {any[]} collection List of items | ||
* @returns {any} Single item from the list | ||
* @param {Array} array List of items | ||
* @returns {*} Single item from the list | ||
* @example | ||
* sample(['a', 'b', 'c']) | ||
* slippyTile.sample(['a', 'b', 'c']) | ||
* //='b' | ||
*/ | ||
export function sample (collection) { | ||
return collection[Math.floor(Math.random() * collection.length)] | ||
function sample (array) { | ||
if (array === null || array === undefined || array.length === 0) { return undefined } | ||
return array[Math.floor(Math.random() * array.length)] | ||
} | ||
module.exports = {parse, providers, wms, wmts, parseSwitch, sample} |
{ | ||
"name": "slippy-tile", | ||
"version": "1.10.2", | ||
"version": "1.11.0", | ||
"description": "Helps convert Slippy Map url tile schemas", | ||
"main": "dist/slippy-tile.js", | ||
"browser": "dist/slippy-tile.browser.js", | ||
"module": "dist/slippy-tile.es.js", | ||
"jsnext:main": "dist/slippy-tile.es.js", | ||
"main": "index.js", | ||
"files": [ | ||
"index.d.ts", | ||
"index.js", | ||
"dist", | ||
"docs", | ||
"providers" | ||
], | ||
"scripts": { | ||
"prepublish": "npm run test && npm run uglify", | ||
"test": "npm run lint && npm run build && jest --coverage", | ||
"prepublish": "npm run test && npm run rollup", | ||
"test": "npm run lint && jest --coverage", | ||
"lint": "standard", | ||
"benchmark": "node bench.js", | ||
"docs": "documentation readme index.js --section=API", | ||
"build": "rollup -c rollup.config.js", | ||
"uglify": "uglifyjs dist/slippy-tile.browser.js -c -m -o dist/slippy-tile.browser.min.js" | ||
"rollup": "rollup -c docs/rollup.config.js" | ||
}, | ||
@@ -29,2 +26,3 @@ "author": "Denis Carriere <carriere.denis@gmail.com>", | ||
"devDependencies": { | ||
"benchmark": "^2.1.3", | ||
"coveralls": "^2.11.15", | ||
@@ -34,6 +32,9 @@ "documentation": "^4.0.0-beta.18", | ||
"rollup": "^0.41.4", | ||
"rollup-plugin-commonjs": "^7.1.0", | ||
"rollup-plugin-json": "^2.1.0", | ||
"rollup-plugin-node-builtins": "^2.1.0", | ||
"rollup-plugin-node-globals": "^1.1.0", | ||
"rollup-plugin-node-resolve": "^2.0.0", | ||
"standard": "^8.6.0", | ||
"typescript": "^2.1.5", | ||
"uglify-js": "^2.7.5" | ||
"typescript": "^2.1.5" | ||
}, | ||
@@ -58,4 +59,4 @@ "keywords": [ | ||
"env": "jest", | ||
"ignore": "dist" | ||
"ignore": "docs" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
export const imagery = { | ||
module.exports.imagery = { | ||
name: 'Bing Imagery', | ||
@@ -3,0 +3,0 @@ categories: [ |
@@ -1,2 +0,2 @@ | ||
export var natgeo = { | ||
module.exports.natgeo = { | ||
name: 'ESRI National Geographic World Map', | ||
@@ -16,3 +16,3 @@ categories: [ | ||
export var ocean = { | ||
module.exports.ocean = { | ||
name: 'ESRI Ocean Basemap', | ||
@@ -31,3 +31,3 @@ categories: [ | ||
export var usatopo = { | ||
module.exports.usatopo = { | ||
name: 'ESRI USA Topo Maps', | ||
@@ -46,3 +46,3 @@ categories: [ | ||
export var imagery = { | ||
module.exports.imagery = { | ||
name: 'ESRI World Imagery', | ||
@@ -61,3 +61,3 @@ categories: [ | ||
export var street = { | ||
module.exports.street = { | ||
name: 'ESRI World Street Map', | ||
@@ -76,3 +76,3 @@ categories: [ | ||
export var topo = { | ||
module.exports.topo = { | ||
name: 'ESRI World Topographic Map', | ||
@@ -79,0 +79,0 @@ categories: [ |
@@ -1,15 +0,5 @@ | ||
import * as bing from './bing' | ||
import * as esri from './esri' | ||
import * as openstreetmap from './openstreetmap' | ||
import * as strava from './strava' | ||
import * as digitalglobe from './digitalglobe' | ||
import * as mapbox from './mapbox' | ||
export { | ||
digitalglobe, | ||
mapbox, | ||
esri, | ||
bing, | ||
openstreetmap, | ||
strava | ||
module.exports = { | ||
esri: require('./esri'), | ||
bing: require('./bing'), | ||
openstreetmap: require('./openstreetmap') | ||
} |
@@ -1,2 +0,2 @@ | ||
export var standard = { | ||
module.exports.standard = { | ||
name: 'OpenStreetMap Standard', | ||
@@ -15,3 +15,3 @@ categories: [ | ||
export var cycle = { | ||
module.exports.cycle = { | ||
name: 'OpenStreetMap Cycle Map', | ||
@@ -30,3 +30,3 @@ categories: [ | ||
export var hot = { | ||
module.exports.hot = { | ||
name: 'OpenStreetMap Humanitarian', | ||
@@ -46,3 +46,3 @@ categories: [ | ||
export var transport = { | ||
module.exports.transport = { | ||
name: 'OpenStreetMap Transport Map', | ||
@@ -61,3 +61,3 @@ categories: [ | ||
export var wikimedia = { | ||
module.exports.wikimedia = { | ||
name: 'OpenStreetMap Wikimedia', | ||
@@ -76,3 +76,3 @@ categories: [ | ||
export var lyrk = { | ||
module.exports.lyrk = { | ||
name: 'OpenStreetMap Lyrk', | ||
@@ -79,0 +79,0 @@ categories: [ |
@@ -20,6 +20,6 @@ # Slippy Tile | ||
**web browser ([ES6](https://kangax.github.io/compat-table/es6))** | ||
**web browser ([ES5](https://kangax.github.io/compat-table/es5))** | ||
```html | ||
<script src="https://unpkg.com/slippy-tile/slippy-tile.min.js"></script> | ||
<script src="https://unpkg.com/slippy-tile/dist/slippy-tile.browser.js"></script> | ||
``` | ||
@@ -30,15 +30,8 @@ | ||
```javascript | ||
const slippyTile = require('slippy-tile') | ||
const tile = [10, 15, 8] // x, y, zoom | ||
const url = slippyTile(tile, 'osm') | ||
var tile = [10, 15, 8] // [x, y, zoom] | ||
var scheme = 'https://{switch:a,b,c}.tile.openstreetmap.org/{zoom}/{x}/{y}.png' | ||
var url = slippyTile.parse(tile, scheme) | ||
//= https://b.tile.openstreetmap.org/8/10/15.png | ||
``` | ||
## Supports | ||
- [Webpack](https://webpack.js.org/) | ||
- [Browserify](http://browserify.org/) | ||
- [ES6 (ES2015)](https://babeljs.io/learn-es2015/) | ||
## Providers | ||
@@ -104,5 +97,3 @@ | ||
```javascript | ||
const tile = [10, 15, 8] | ||
const url = 'https://{s}.tile.openstreetmap.org/{zoom}/{x}/{y}.png' | ||
parse(tile, url) | ||
slippyTile.parse([10, 15, 8], 'https://{s}.tile.openstreetmap.org/{zoom}/{x}/{y}.png') | ||
//='https://c.tile.openstreetmap.org/8/10/15.png' | ||
@@ -125,5 +116,3 @@ ``` | ||
```javascript | ||
const tile = [10, 15, 8] | ||
const url = 'https://<Tile Server>/?layers=imagery&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}' | ||
wms(tile, url) | ||
slippyTile.wms([10, 15, 8], 'https://<Tile Server>/?layers=imagery&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}') | ||
//='https://<Tile Server>/?layers=imagery&SRS=EPSG:3857&WIDTH=256&HEIGHT=256&BBOX=-165.9375,82.676285,-164.53125,82.853382' | ||
@@ -145,3 +134,3 @@ ``` | ||
```javascript | ||
wmts('https://<Tile Server>/WMTS/tile/1.0.0/Imagery/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpg') | ||
slippyTile.wmts('https://<Tile Server>/WMTS/tile/1.0.0/Imagery/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpg') | ||
//='https://<Tile Server>/WMTS/tile/1.0.0/Imagery/default/GoogleMapsCompatible/{z}/{y}/{x}.jpg' | ||
@@ -163,3 +152,3 @@ ``` | ||
```javascript | ||
parseSwitch('http://tile-{switch:a,b,c}.openstreetmap.fr/hot/{zoom}/{x}/{y}.png') | ||
slippyTile.parseSwitch('http://tile-{switch:a,b,c}.openstreetmap.fr/hot/{zoom}/{x}/{y}.png') | ||
//='http://tile-b.openstreetmap.fr/hot/{zoom}/{x}/{y}.png' | ||
@@ -176,3 +165,3 @@ ``` | ||
- `collection` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<any>** List of items | ||
- `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** List of items | ||
@@ -182,6 +171,6 @@ **Examples** | ||
```javascript | ||
sample(['a', 'b', 'c']) | ||
slippyTile.sample(['a', 'b', 'c']) | ||
//='b' | ||
``` | ||
Returns **any** Single item from the list | ||
Returns **Any** Single item from the list |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49938
12
13
1262
169
1