Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

slippy-tile

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slippy-tile - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

7

CHANGELOG.md
# Changelog
## 2.2.0 - 2017-09-08
- Dropped throw errors on uncomplete parsed URL
- Add extra optional params
- Remove extra devDependencies
- Support for NodeJS 4
## 2.1.0 - 2017-04-24

@@ -5,0 +12,0 @@

9

index.d.ts
type Tile = [number, number, number];
declare function slippyTile(tile: Tile, url: string): string;
interface Options {
layer?: string
format?: string
version?: string
[key: string]: string
}
declare function slippyTile(tile: Tile, url: string, options?: Options): string;
declare namespace slippyTile { }
export = slippyTile

48

index.js

@@ -1,8 +0,15 @@

var mercator = require('global-mercator')
var googleToBBox = mercator.googleToBBox
var googleToTile = mercator.googleToTile
var googleToQuadkey = mercator.googleToQuadkey
var bboxToMeters = mercator.bboxToMeters
const mercator = require('global-mercator')
const googleToBBox = mercator.googleToBBox
const googleToTile = mercator.googleToTile
const googleToQuadkey = mercator.googleToQuadkey
const bboxToMeters = mercator.bboxToMeters
/**
* @typedef {Object} Options
* @property {string} layer
* @property {string} version
* @property {string} [format='image/png']
*/
/**
* Substitutes the given tile information [x, y, z] to the URL tile scheme.

@@ -13,2 +20,3 @@ *

* @param {string} url URL Tile scheme or provider unique key
* @param {Options} options Additional options
* @returns {string} parsed URL

@@ -19,6 +27,8 @@ * @example

*/
module.exports = function (tile, url) {
var x = tile[0]
var y = tile[1]
var zoom = tile[2]
module.exports = function (tile, url, options) {
options = options || {}
const format = options.format || 'image/png'
const x = tile[0]
const y = tile[1]
const zoom = tile[2]
url = wms(tile, url)

@@ -30,5 +40,14 @@ url = wmts(url)

url = url.replace(/{(y|row)}/gi, String(y))
url = url.replace(/{format}/gi, format)
// Replace all additional options
Object.keys(options).forEach(key => {
const pattern = RegExp('{' + key + '}', 'ig')
if (url.match(pattern)) {
if (options[key] === undefined) throw new Error('options.' + key + ' is required')
url = url.replace(pattern, options[key])
}
})
if (url.match(/{-y}/)) url = url.replace(/{-y}/gi, String(googleToTile(tile)[1]))
if (url.match(/{(quadkey|q)}/)) url = url.replace(/{(quadkey|q)}/gi, googleToQuadkey(tile))
if (url.match(/{.*}/)) throw new Error('Could not completly parse URL' + url)
return url

@@ -98,11 +117,8 @@ }

// Default simple switch
if (url.match(/{s}/gi)) {
return url.replace(/{s}/gi, String(sample(['a', 'b', 'c'])))
}
if (url.match(/{s}/gi)) return url.replace(/{s}/gi, String(sample(['a', 'b', 'c'])))
// Custom switch
var pattern = /{switch:([a-z,\d]*)}/i
var found = url.match(pattern)
if (found) {
return url.replace(pattern, String(sample(found[1].split(','))))
}
if (found) return url.replace(pattern, String(sample(found[1].split(','))))
return url

@@ -109,0 +125,0 @@ }

{
"name": "slippy-tile",
"version": "2.1.0",
"version": "2.2.0",
"description": "Helps convert Slippy Map url tile schemas",

@@ -13,13 +13,6 @@ "main": "index.js",

"scripts": {
"prepublish": "npm run test && npm run build && npm run docs",
"pretest": "npm run lint",
"test": "node test.js",
"bench": "node bench.js",
"lint": "standard index.js",
"build": "npm run rollup && npm run uglify",
"docs": "documentation readme index.js --shallow --section=API --markdown-toc",
"rollup": "rollup -c rollup.config.js",
"uglify": "uglifyjs docs/slippy-tile.js -c -m > docs/slippy-tile.min.js"
"test": "tap test.js --coverage"
},
"author": "Denis Carriere <carriere.denis@gmail.com>",
"author": "Denis Carriere <@DenisCarriere>",
"license": "MIT",

@@ -29,5 +22,3 @@ "keywords": [

"geo",
"geojs",
"geospatial",
"geography",
"map",

@@ -40,19 +31,9 @@ "url",

"devDependencies": {
"benchmark": "^2.1.3",
"coveralls": "^2.11.15",
"documentation": "^4.0.0-beta.18",
"jest-cli": "^18.0.0",
"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",
"tape": "^4.6.3",
"uglifyjs": "^2.4.10"
"tap": "^10.7.2",
"tape": "^4.6.3"
},
"dependencies": {
"global-mercator": "^2.6.0"
"global-mercator": "^2.8.4"
}
}

@@ -51,2 +51,3 @@ # Slippy Tile

- `{proj}`: default = EPSG:3857
- `{format}`: default = image/png

@@ -63,3 +64,3 @@ ## API

- `url` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** URL Tile scheme or provider unique key
- `options` **Object** Additional params
**Examples**

@@ -66,0 +67,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc