slippy-tile
Advanced tools
Comparing version 1.1.1 to 1.2.0
# Changelog | ||
## 1.2.1 - 2016-10-20 | ||
- Added DigitalGlobe as provider | ||
- Converted `source.json` to `providers.yml` | ||
## 1.1.0 - 2016-10-14 | ||
@@ -4,0 +9,0 @@ |
@@ -30,3 +30,3 @@ [![Build Status](https://travis-ci.org/DenisCarriere/slippy-tile.svg?branch=master)](https://travis-ci.org/DenisCarriere/slippy-tile) | ||
|-------------------------------|---------------------| | ||
| OSM (Default) | osm, osm-standard | ||
| OSM (Default) | osm | ||
| OSM Cycle Map | osm-cycle | ||
@@ -37,6 +37,6 @@ | OSM Humanitarian | osm-hot | ||
| OSM Lyrk | osm-lyrk | ||
| Bing Imagery | bing, imagery, bing-imagery | ||
| Bing Imagery | bing-imagery | ||
| Strava Cycling & Running | strava | ||
| National Geographic World Map | natgeo | ||
| ESRI Imagery | esri, esri-imagery | ||
| ESRI Imagery | esri-imagery | ||
| ESRI Ocean Basemap | esri-ocean | ||
@@ -46,3 +46,6 @@ | ESRI USA Topo Maps | esri-usa-topo | ||
| ESRI World Topographic Map | esri-topo | ||
| DigitalGlobe Imagery | digitalgloble-imagery | ||
| DigitalGlobe Hybrid | digitalgloble-hybrid | ||
## Scheme | ||
@@ -49,0 +52,0 @@ |
23
index.js
@@ -12,4 +12,3 @@ "use strict"; | ||
const rp = require('request-promise'); | ||
const path = require('path'); | ||
const sources = require(path.join(__dirname, 'utils', 'sources.json')); | ||
const providers_1 = require('./utils/providers'); | ||
/** | ||
@@ -27,3 +26,3 @@ * Substitutes the given tile information [x,y,zoom] to the URL tile scheme. | ||
const [x, y, zoom] = tile; | ||
let url = sourceLookup(scheme); | ||
let url = providerLookup(scheme); | ||
url = url.replace(/{(zoom|z)}/, String(zoom)); | ||
@@ -86,5 +85,5 @@ url = url.replace(/{x}/, String(x)); | ||
/** | ||
* Source Lookup | ||
* Provider Lookup | ||
* | ||
* @param {string} source Source unique key | ||
* @param {string} provider Provider unique key | ||
* @returns {string} scheme Tile scheme URL | ||
@@ -95,12 +94,12 @@ * @example | ||
*/ | ||
function sourceLookup(source) { | ||
if (source) { | ||
const key = source.toLowerCase().trim(); | ||
if (sources[key] !== undefined) { | ||
return sources[key].scheme; | ||
function providerLookup(provider) { | ||
if (provider) { | ||
const key = provider.toLowerCase().trim(); | ||
if (providers_1.providers[key] !== undefined) { | ||
return providers_1.providers[key].scheme; | ||
} | ||
} | ||
return source; | ||
return provider; | ||
} | ||
exports.sourceLookup = sourceLookup; | ||
exports.providerLookup = providerLookup; | ||
/** | ||
@@ -107,0 +106,0 @@ * Sample an item from a given list |
30
index.ts
import * as mercator from 'global-mercator' | ||
import * as rp from 'request-promise' | ||
import * as path from 'path' | ||
import { providers } from './utils/providers' | ||
export interface Source { | ||
name: string | ||
scheme: string | ||
description: string | ||
attribution: string | ||
format: string | ||
} | ||
interface Sources { [key: string]: Source } | ||
const sources: Sources = require(path.join(__dirname, 'utils', 'sources.json')) | ||
/** | ||
@@ -32,3 +22,3 @@ * Tile [x, y, zoom] | ||
const [x, y, zoom] = tile | ||
let url = sourceLookup(scheme) | ||
let url = providerLookup(scheme) | ||
url = url.replace(/{(zoom|z)}/, String(zoom)) | ||
@@ -83,5 +73,5 @@ url = url.replace(/{x}/, String(x)) | ||
/** | ||
* Source Lookup | ||
* Provider Lookup | ||
* | ||
* @param {string} source Source unique key | ||
* @param {string} provider Provider unique key | ||
* @returns {string} scheme Tile scheme URL | ||
@@ -92,10 +82,10 @@ * @example | ||
*/ | ||
export function sourceLookup(source: string) { | ||
if (source) { | ||
const key = source.toLowerCase().trim() | ||
if (sources[key] !== undefined) { | ||
return sources[key].scheme | ||
export function providerLookup(provider: string) { | ||
if (provider) { | ||
const key = provider.toLowerCase().trim() | ||
if (providers[key] !== undefined) { | ||
return providers[key].scheme | ||
} | ||
} | ||
return source | ||
return provider | ||
} | ||
@@ -102,0 +92,0 @@ |
{ | ||
"name": "slippy-tile", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Helps convert Slippy Map url tile schemas", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"test": "tsc && npm run lint && nyc ava", | ||
"docs": "tsc && cat HEADER.md > README.md && documentation build index.js -c documentation.yml -f md >> README.md", | ||
"docs": "tsc && cat HEADER.md > README.md && documentation build index.js -c documentation.yml -f md >> README.md && cat CHANGELOG.md >> README.md", | ||
"lint": "tsc && tslint index.ts test.ts && documentation lint index.js" | ||
@@ -28,2 +28,3 @@ }, | ||
"devDependencies": { | ||
"@types/js-yaml": "^3.5.28", | ||
"ava": "^0.16.0", | ||
@@ -59,6 +60,7 @@ "coveralls": "^2.11.14", | ||
"@types/bluebird": "^3.0.35", | ||
"@types/request": "^0.0.31", | ||
"@types/request-promise": "^3.0.32", | ||
"@types/request": "^0.0.31", | ||
"bluebird": "^3.4.6", | ||
"global-mercator": "^1.3.2", | ||
"js-yaml": "^3.6.1", | ||
"request": "^2.75.0", | ||
@@ -65,0 +67,0 @@ "request-promise": "^4.1.1" |
@@ -30,3 +30,3 @@ [![Build Status](https://travis-ci.org/DenisCarriere/slippy-tile.svg?branch=master)](https://travis-ci.org/DenisCarriere/slippy-tile) | ||
|-------------------------------|---------------------| | ||
| OSM (Default) | osm, osm-standard | ||
| OSM (Default) | osm | ||
| OSM Cycle Map | osm-cycle | ||
@@ -37,6 +37,6 @@ | OSM Humanitarian | osm-hot | ||
| OSM Lyrk | osm-lyrk | ||
| Bing Imagery | bing, imagery, bing-imagery | ||
| Bing Imagery | bing-imagery | ||
| Strava Cycling & Running | strava | ||
| National Geographic World Map | natgeo | ||
| ESRI Imagery | esri, esri-imagery | ||
| ESRI Imagery | esri-imagery | ||
| ESRI Ocean Basemap | esri-ocean | ||
@@ -46,3 +46,6 @@ | ESRI USA Topo Maps | esri-usa-topo | ||
| ESRI World Topographic Map | esri-topo | ||
| DigitalGlobe Imagery | digitalgloble-imagery | ||
| DigitalGlobe Hybrid | digitalgloble-hybrid | ||
## Scheme | ||
@@ -124,9 +127,9 @@ | ||
# sourceLookup | ||
# providerLookup | ||
Source Lookup | ||
Provider Lookup | ||
**Parameters** | ||
- `source` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Source unique key | ||
- `provider` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Provider unique key | ||
@@ -158,1 +161,18 @@ **Examples** | ||
Returns **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))** Single item from the list | ||
# Changelog | ||
## 1.2.1 - 2016-10-20 | ||
- Added DigitalGlobe as provider | ||
- Converted `source.json` to `providers.yml` | ||
## 1.1.0 - 2016-10-14 | ||
- Changed default function to `url` | ||
- Added `download` feature | ||
- Fallbacks, request-promise dependency for downloading Tile data Buffer | ||
- Update docs | ||
## 1.0.0 - 2016-10-13 | ||
First Stable release of `slippy-tile`. |
Sorry, the diff of this file is not supported yet
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
199246
25
174
8
8
321
+ Addedjs-yaml@^3.6.1
+ Addedargparse@1.0.10(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedsprintf-js@1.0.3(transitive)