slippy-tile
Advanced tools
Comparing version 1.3.3 to 1.4.0
# Changelog | ||
## 1.4.0 - 2016-12-04 | ||
- Added Circle CI tests | ||
- Replace test cases with Jest | ||
- Refactor providers to Typescript (removed .yml & .json) | ||
## 1.3.2 - 2016-10-27 | ||
@@ -4,0 +10,0 @@ |
35
index.js
"use strict"; | ||
const mercator = require("global-mercator"); | ||
exports.providers = require('./providers'); | ||
const digitalglobe = require("./providers/digitalglobe"); | ||
exports.digitalglobe = digitalglobe; | ||
const esri = require("./providers/esri"); | ||
exports.esri = esri; | ||
const bing = require("./providers/bing"); | ||
exports.bing = bing; | ||
const osm = require("./providers/osm"); | ||
exports.osm = osm; | ||
const strava = require("./providers/strava"); | ||
exports.strava = strava; | ||
/** | ||
@@ -16,6 +25,2 @@ * Substitutes the given tile information [x,y,zoom] to the URL tile scheme. | ||
const [x, y, zoom] = tile; | ||
const providerURL = provider(url); | ||
if (providerURL) { | ||
url = providerURL; | ||
} | ||
url = url.replace(/{(zoom|z)}/, String(zoom)); | ||
@@ -80,22 +85,2 @@ url = url.replace(/{x}/, String(x)); | ||
/** | ||
* Provider Lookup | ||
* | ||
* @param {string} provider Provider unique key | ||
* @returns {string} url Tile URL scheme | ||
* @example | ||
* provider('bing-imagery') | ||
* //='http://ecn.t{switch:0,1,2,3}.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=5250' | ||
* provider('osm') | ||
* //='https://{s}.tile.openstreetmap.org/{zoom}/{x}/{y}.png' | ||
*/ | ||
function provider(provider) { | ||
if (provider) { | ||
const key = provider.toLowerCase().trim(); | ||
if (exports.providers[key]) { | ||
return exports.providers[key].url; | ||
} | ||
} | ||
} | ||
exports.provider = provider; | ||
/** | ||
* Sample an item from a given list | ||
@@ -102,0 +87,0 @@ * |
57
index.ts
import * as mercator from 'global-mercator' | ||
import * as digitalglobe from './providers/digitalglobe' | ||
import * as esri from './providers/esri' | ||
import * as bing from './providers/bing' | ||
import * as osm from './providers/osm' | ||
import * as strava from './providers/strava' | ||
interface Provider { | ||
name: string | ||
export { | ||
bing, | ||
digitalglobe, | ||
esri, | ||
osm, | ||
strava, | ||
} | ||
/** | ||
* Provider | ||
*/ | ||
export interface Provider { | ||
attribution: string | ||
categories: Array<string> | ||
url: string | ||
description: string | ||
attribution: string | ||
name: string | ||
format: string | ||
url: string | ||
} | ||
interface Providers { | ||
[index: string]: Provider | ||
} | ||
interface Options { | ||
url?: string | ||
provider?: string | ||
} | ||
export const providers: Providers = require('./providers') | ||
/** | ||
@@ -40,4 +45,2 @@ * Tile [x, y, zoom] | ||
const [x, y, zoom] = tile | ||
const providerURL = provider(url) | ||
if (providerURL) { url = providerURL } | ||
url = url.replace(/{(zoom|z)}/, String(zoom)) | ||
@@ -97,22 +100,2 @@ url = url.replace(/{x}/, String(x)) | ||
/** | ||
* Provider Lookup | ||
* | ||
* @param {string} provider Provider unique key | ||
* @returns {string} url Tile URL scheme | ||
* @example | ||
* provider('bing-imagery') | ||
* //='http://ecn.t{switch:0,1,2,3}.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=5250' | ||
* provider('osm') | ||
* //='https://{s}.tile.openstreetmap.org/{zoom}/{x}/{y}.png' | ||
*/ | ||
export function provider (provider: string) { | ||
if (provider) { | ||
const key = provider.toLowerCase().trim() | ||
if (providers[key]) { | ||
return providers[key].url | ||
} | ||
} | ||
} | ||
/** | ||
* Sample an item from a given list | ||
@@ -119,0 +102,0 @@ * |
{ | ||
"name": "slippy-tile", | ||
"version": "1.3.3", | ||
"version": "1.4.0", | ||
"description": "Helps convert Slippy Map url tile schemas", | ||
@@ -8,5 +8,4 @@ "main": "index.js", | ||
"scripts": { | ||
"pretest": "js-yaml providers.yml > providers.json", | ||
"test": "npm run lint && nyc ava", | ||
"docs": "tsc && cat HEADER.md > README.md && documentation build index.js -c documentation.yml -f md >> README.md && cat CHANGELOG.md >> README.md", | ||
"test": "npm run lint && jest --coverage", | ||
"docs": "tsc && cat HEADER.md > README.md && documentation build index.js -c documentation.yml -f md --shallow >> README.md && cat CHANGELOG.md >> README.md", | ||
"lint": "tsc && tslint index.ts test.ts && documentation lint index.js" | ||
@@ -28,11 +27,7 @@ }, | ||
"devDependencies": { | ||
"@types/js-yaml": "^3.5.28", | ||
"@types/node": "^6.0.45", | ||
"ava": "^0.16.0", | ||
"coveralls": "^2.11.14", | ||
"documentation": "^4.0.0-beta11", | ||
"js-yaml": "^3.6.1", | ||
"nyc": "^8.3.2", | ||
"tslint": "^3.15.1", | ||
"typescript": "^2.0.3" | ||
"@types/jest": "16.0.1", | ||
"documentation": "4.0.0-beta10", | ||
"jest-cli": "17.0.3", | ||
"tslint": "3.15.1", | ||
"typescript": "2.0.10" | ||
}, | ||
@@ -51,13 +46,6 @@ "keywords": [ | ||
], | ||
"ava": { | ||
"files": [ | ||
"test.js" | ||
], | ||
"concurrency": 5, | ||
"failFast": true, | ||
"tap": true | ||
}, | ||
"testEnvironment": "node", | ||
"dependencies": { | ||
"global-mercator": "^1.3.2" | ||
"global-mercator": "1.4.0" | ||
} | ||
} |
@@ -0,2 +1,5 @@ | ||
# [Slippy Tile](https://www.npmjs.com/package/slippy-tile) | ||
[![Build Status](https://travis-ci.org/DenisCarriere/slippy-tile.svg?branch=master)](https://travis-ci.org/DenisCarriere/slippy-tile) | ||
[![Circle CI](https://circleci.com/gh/DenisCarriere/slippy-tile.svg?style=svg)](https://circleci.com/gh/DenisCarriere/slippy-tile) | ||
[![Coverage Status](https://coveralls.io/repos/github/DenisCarriere/slippy-tile/badge.svg?branch=master)](https://coveralls.io/github/DenisCarriere/slippy-tile?branch=master) | ||
@@ -6,4 +9,2 @@ [![npm version](https://badge.fury.io/js/slippy-tile.svg)](https://badge.fury.io/js/slippy-tile) | ||
# Slippy Tile | ||
Slippy Tile helps parse a Tile scheme URL from a given Tile [x, y, zoom]. | ||
@@ -64,5 +65,5 @@ | ||
- `{-y}`: Tile Row for TMS scheme | ||
- `{zoom}` or `{TileMatrix}`: Zoom Level | ||
- `{zoom}` or `{z}` or `{TileMatrix}`: Zoom Level | ||
- `{bbox}`: GeoJSON Bounding Box | ||
- `{quadkey}`: Microsoft's Quadkey | ||
- `{quadkey}` or `{q}`: Microsoft's Quadkey | ||
- `{switch:1,2,3}`: Selects a random sample | ||
@@ -72,4 +73,2 @@ - `{height}` default = 256 | ||
- `{proj}`: default = EPSG:3857 | ||
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
# parse | ||
@@ -110,21 +109,2 @@ | ||
# provider | ||
Provider Lookup | ||
**Parameters** | ||
- `provider` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Provider unique key | ||
**Examples** | ||
```javascript | ||
provider('bing-imagery') | ||
//='http://ecn.t{switch:0,1,2,3}.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=5250' | ||
provider('osm') | ||
//='https://{s}.tile.openstreetmap.org/{zoom}/{x}/{y}.png' | ||
``` | ||
Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** url Tile URL scheme | ||
# sample | ||
@@ -148,2 +128,8 @@ | ||
## 1.4.0 - 2016-12-04 | ||
- Added Circle CI tests | ||
- Replace test cases with Jest | ||
- Refactor providers to Typescript (removed .yml & .json) | ||
## 1.3.2 - 2016-10-27 | ||
@@ -150,0 +136,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
37784
5
28
670
158
1
+ Addedglobal-mercator@1.4.0(transitive)
- Removedglobal-mercator@1.9.2(transitive)
Updatedglobal-mercator@1.4.0