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 1.9.0 to 1.10.0

dist/slippy-tile.browser.js

5

CHANGELOG.md
# Changelog
## 1.10.0 - 2017-02-18
- Convert module to ES5
- Convert project to Rollup
## 1.9.0 - 2017-02-17

@@ -5,0 +10,0 @@

57

index.js

@@ -1,4 +0,4 @@

const mercator = require('global-mercator')
const providers = require('./providers')
module.exports.providers = providers
import { googleToBBox, googleToTile, googleToQuadkey, bboxToMeters } from 'global-mercator'
import * as providers from './providers'
export { providers }

@@ -12,9 +12,11 @@ /**

* @example
* const tile = [10, 15, 8]
* const url = 'https://{s}.tile.openstreetmap.org/{zoom}/{x}/{y}.png'
* var tile = [10, 15, 8]
* var url = 'https://{s}.tile.openstreetmap.org/{zoom}/{x}/{y}.png'
* parse(tile, url)
* //='https://c.tile.openstreetmap.org/8/10/15.png'
*/
function parse (tile, url) {
const [x, y, zoom] = tile
export function parse (tile, url) {
var x = tile[0]
var y = tile[1]
var zoom = tile[2]
url = wms(tile, url)

@@ -26,8 +28,7 @@ url = wmts(url)

url = url.replace(/{(y|row)}/, String(y))
if (url.match(/{-y}/)) { url = url.replace(/{-y}/, String(mercator.googleToTile(tile)[1])) }
if (url.match(/{(quadkey|q)}/)) { url = url.replace(/{(quadkey|q)}/, mercator.googleToQuadkey(tile)) }
if (url.match(/{.*}/)) { throw new Error(`Could not completly parse URL ${url}`) }
if (url.match(/{-y}/)) { url = url.replace(/{-y}/, String(googleToTile(tile)[1])) }
if (url.match(/{(quadkey|q)}/)) { url = url.replace(/{(quadkey|q)}/, googleToQuadkey(tile)) }
if (url.match(/{.*}/)) { throw new Error('Could not completly parse URL' + url) }
return url
}
module.exports.parse = parse

@@ -41,16 +42,16 @@ /**

* @example
* const tile = [10, 15, 8]
* const url = 'https://<Tile Server>/?layers=imagery&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}'
* var tile = [10, 15, 8]
* var url = 'https://<Tile Server>/?layers=imagery&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}'
* wms(tile, url)
* //='https://<Tile Server>/?layers=imagery&SRS=EPSG:3857&WIDTH=256&HEIGHT=256&BBOX=-165.9375,82.676285,-164.53125,82.853382'
*/
function wms (tile, url) {
export function wms (tile, url) {
url = url.replace(/{height}/gi, '256')
url = url.replace(/{width}/gi, '256')
url = url.replace(/{(proj|srs|crs)}/gi, 'EPSG:3857')
let bbox
if (url.match(/EPSG:3857/i)) {
bbox = mercator.bboxToMeters(mercator.googleToBBox(tile))
var bbox
if (url.match(/EPSG:(3857|900913)/i)) {
bbox = bboxToMeters(googleToBBox(tile))
} else {
bbox = mercator.googleToBBox(tile)
bbox = googleToBBox(tile)
}

@@ -61,3 +62,2 @@

}
module.exports.wms = wms

@@ -73,3 +73,3 @@ /**

*/
function wmts (url) {
export function wmts (url) {
url = url.replace(/{TileCol}/gi, '{x}')

@@ -82,3 +82,2 @@ url = url.replace(/{TileRow}/gi, '{y}')

}
module.exports.wmts = wmts

@@ -94,18 +93,15 @@ /**

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

@@ -122,5 +118,4 @@ /**

*/
function sample (collection) {
export function sample (collection) {
return collection[Math.floor(Math.random() * collection.length)]
}
module.exports.sample = sample
{
"name": "slippy-tile",
"version": "1.9.0",
"version": "1.10.0",
"description": "Helps convert Slippy Map url tile schemas",
"main": "index.js",
"types": "index.d.js",
"main": "dist/slippy-tile.js",
"browser": "dist/slippy-tile.browser.js",
"module": "dist/slippy-tile.es.js",
"jsnext:main": "dist/slippy-tile.es.js",
"files": [
"index.d.ts",
"index.js",
"index.d.ts",
"slippy-tile.js",
"slippy-tile.min.js",
"dist",
"providers"
],
"scripts": {
"prepublish": "npm run test && npm run build",
"test": "npm run lint && jest --coverage",
"prepublish": "npm run test && npm run uglify",
"test": "npm run lint && npm run build && jest --coverage",
"lint": "standard",
"docs": "documentation readme index.js --section=API",
"build": "browserify index.js -s slippy-tile > slippy-tile.js && uglifyjs slippy-tile.js -c -m > slippy-tile.min.js"
"build": "rollup -c rollup.config.js",
"uglify": "uglifyjs dist/slippy-tile.browser.js -c -m -o dist/slippy-tile.browser.min.js"
},

@@ -24,11 +26,13 @@ "author": "Denis Carriere <carriere.denis@gmail.com>",

"dependencies": {
"global-mercator": "^1.6.1"
"global-mercator": "^2.0.3"
},
"devDependencies": {
"browserify": "^13.3.0",
"coveralls": "^2.11.15",
"documentation": "^4.0.0-beta.18",
"jest-cli": "^18.1.0",
"typescript": "^2.1.4",
"uglify-js": "git://github.com/mishoo/UglifyJS2.git#harmony"
"jest-cli": "^18.0.0",
"rollup": "^0.41.4",
"rollup-plugin-node-resolve": "^2.0.0",
"standard": "^8.6.0",
"typescript": "^2.1.5",
"uglify-js": "^2.7.5"
},

@@ -52,4 +56,5 @@ "keywords": [

"standard": {
"env": "jest"
"env": "jest",
"ignore": "dist"
}
}

@@ -1,2 +0,2 @@

module.exports.imagery = {
export const imagery = {
name: 'Bing Imagery',

@@ -3,0 +3,0 @@ categories: [

@@ -1,2 +0,2 @@

module.exports.hybrid = {
export const hybrid = {
attribution: '© DigitalGlobe, © OpenStreetMap, © Mapbox',

@@ -18,3 +18,3 @@ categories: [

module.exports.imagery = {
export const imagery = {
name: 'DigitalGlobe Imagery',

@@ -21,0 +21,0 @@ categories: [

@@ -1,2 +0,2 @@

module.exports.natgeo = {
export const natgeo = {
name: 'ESRI National Geographic World Map',

@@ -16,3 +16,3 @@ categories: [

module.exports.ocean = {
export const ocean = {
name: 'ESRI Ocean Basemap',

@@ -31,3 +31,3 @@ categories: [

module.exports.usatopo = {
export const usatopo = {
name: 'ESRI USA Topo Maps',

@@ -46,3 +46,3 @@ categories: [

module.exports.imagery = {
export const imagery = {
name: 'ESRI World Imagery',

@@ -61,3 +61,3 @@ categories: [

module.exports.street = {
export const street = {
name: 'ESRI World Street Map',

@@ -76,3 +76,3 @@ categories: [

module.exports.topo = {
export const topo = {
name: 'ESRI World Topographic Map',

@@ -79,0 +79,0 @@ categories: [

@@ -1,9 +0,9 @@

const bing = require('./bing')
const esri = require('./esri')
const openstreetmap = require('./openstreetmap')
const strava = require('./strava')
const digitalglobe = require('./digitalglobe')
const mapbox = require('./mapbox')
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'
module.exports = {
export {
digitalglobe,

@@ -10,0 +10,0 @@ mapbox,

@@ -1,2 +0,2 @@

module.exports.outdoors = {
export const outdoors = {
name: 'Mapbox Outdoors',

@@ -17,3 +17,3 @@ categories: [

module.exports.imagery = {
export const imagery = {
name: 'Mapbox Imagery',

@@ -20,0 +20,0 @@ categories: [

@@ -1,2 +0,2 @@

module.exports.standard = {
export const standard = {
name: 'OpenStreetMap Standard',

@@ -15,3 +15,3 @@ categories: [

module.exports.cycle = {
export const cycle = {
name: 'OpenStreetMap Cycle Map',

@@ -30,3 +30,3 @@ categories: [

module.exports.hot = {
export const hot = {
name: 'OpenStreetMap Humanitarian',

@@ -46,3 +46,3 @@ categories: [

module.exports.transport = {
export const transport = {
name: 'OpenStreetMap Transport Map',

@@ -61,3 +61,3 @@ categories: [

module.exports.wikimedia = {
export const wikimedia = {
name: 'OpenStreetMap Wikimedia',

@@ -76,3 +76,3 @@ categories: [

module.exports.lyrk = {
export const lyrk = {
name: 'OpenStreetMap Lyrk',

@@ -79,0 +79,0 @@ categories: [

@@ -1,2 +0,2 @@

module.exports.both = {
export const both = {
name: 'Strava Cycling & Running',

@@ -3,0 +3,0 @@ categories: [

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