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.2.1 to 1.2.2

.nyc_output/1837d5e5773fd5c62919a78dc81f2fd1.json

4

CHANGELOG.md
# Changelog
## 1.2.1 - 2016-10-20
## 1.2.2 - 2016-10-21
- Remove all `request` related dependencies
- Removed `download` method
- Added DigitalGlobe as provider

@@ -6,0 +8,0 @@ - Converted `source.json` to `providers.yml`

@@ -19,6 +19,6 @@ [![Build Status](https://travis-ci.org/DenisCarriere/slippy-tile.svg?branch=master)](https://travis-ci.org/DenisCarriere/slippy-tile)

```javascript
import * as slippyTile from 'slippy-tile'
import slippyTile from 'slippy-tile'
const tile = [10, 15, 8] // x, y, zoom
const url = slippyTile.url(tile, 'osm')
const url = slippyTile(tile, 'osm')
//= https://b.tile.openstreetmap.org/8/10/15.png

@@ -55,3 +55,3 @@ ```

const scheme = 'https://{switch:a,b,c}.tile.openstreetmap.org/{zoom}/{x}/{y}.png'
const url = slippyTile.url([10, 15, 8], scheme)
const url = slippyTile([10, 15, 8], scheme)
//= https://b.tile.openstreetmap.org/8/10/15.png

@@ -58,0 +58,0 @@ ```

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments)).next());
});
};
const mercator = require('global-mercator');
const rp = require('request-promise');
const providers_1 = require('./utils/providers');
const fs = require('fs');
const yml = require('js-yaml');
const path = require('path');
const providers = yml.safeLoad(fs.readFileSync(path.join(__dirname, 'providers.yml'), { encoding: 'utf-8' }));
/**

@@ -20,6 +14,7 @@ * Substitutes the given tile information [x,y,zoom] to the URL tile scheme.

* @example
* const url = slippyTile.url([10, 15, 8], 'osm')
* import slippyTile from 'slippyTile'
* slippyTile([10, 15, 8], 'osm')
* //='https://c.tile.openstreetmap.org/8/10/15.png'
*/
function url(tile, scheme) {
function slippyTile(tile, scheme) {
const [x, y, zoom] = tile;

@@ -45,21 +40,18 @@ let url = providerLookup(scheme);

}
exports.url = url;
exports.slippyTile = slippyTile;
// /**
// * Downloads Tile
// *
// * @param {Tile} tile Tile [x, y, zoom]
// * @param {string} scheme Tile scheme URL or pre-loaded source unique key
// * @returns {Promise<Buffer>} tile buffer
// * @example
// * const url = slippyTile.url([10, 15, 8], 'osm')
// * //='https://c.tile.openstreetmap.org/8/10/15.png'
// */
// export async function download(tile: Tile, scheme: string): Promise<Buffer> {
// return rp.get(url(tile, scheme), { encoding : 'binary' })
// .then(data => new Buffer(data, 'binary'))
// }
/**
* Downloads Tile
*
* @param {Tile} tile Tile [x, y, zoom]
* @param {string} scheme Tile scheme URL or pre-loaded source unique key
* @returns {Promise<Buffer>} tile buffer
* @example
* const url = slippyTile.url([10, 15, 8], 'osm')
* //='https://c.tile.openstreetmap.org/8/10/15.png'
*/
function download(tile, scheme) {
return __awaiter(this, void 0, void 0, function* () {
return rp.get(url(tile, scheme), { encoding: 'binary' })
.then(data => new Buffer(data, 'binary'));
});
}
exports.download = download;
/**
* Replaces {switch:a,b,c} with a random sample.

@@ -70,4 +62,4 @@ *

* @example
* const scheme = 'http://tile-{switch:a,b,c}.openstreetmap.fr/hot/{zoom}/{x}/{y}.png'
* const url = slippyTile.parseSwitch(scheme)
* import { parseSwitch } from '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'

@@ -89,5 +81,6 @@ */

* @param {string} provider Provider unique key
* @returns {string} scheme Tile scheme URL
* @returns {string} url Tile URL scheme
* @example
* const scheme = slippyTile.providerLookup('bing')
* import { provider } from 'slippyTile'
* provider('bing-imagery')
* //='http://ecn.t{switch:0,1,2,3}.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=5250'

@@ -98,4 +91,4 @@ */

const key = provider.toLowerCase().trim();
if (providers_1.providers[key] !== undefined) {
return providers_1.providers[key].scheme;
if (providers[key] !== undefined) {
return providers[key].url;
}

@@ -112,3 +105,4 @@ }

* @example
* const item = sample(['a', 'b', 'c'])
* import { sample } from 'slippyTile'
* sample(['a', 'b', 'c'])
* //='a'

@@ -120,2 +114,4 @@ */

exports.sample = sample;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = slippyTile;
//# sourceMappingURL=index.js.map
import * as mercator from 'global-mercator'
import * as rp from 'request-promise'
import { providers } from './utils/providers'
import * as fs from 'fs'
import * as yml from 'js-yaml'
import * as path from 'path'
export interface Provider {
name: string
categories: Array<string>
url: string
description: string
attribution: string
format: string
}
interface Providers {
[key: string]: Provider
}
const providers: Providers = yml.safeLoad(fs.readFileSync(path.join(__dirname, 'providers.yml'), { encoding: 'utf-8' }))
/**

@@ -17,6 +33,7 @@ * Tile [x, y, zoom]

* @example
* const url = slippyTile.url([10, 15, 8], 'osm')
* import slippyTile from 'slippyTile'
* slippyTile([10, 15, 8], 'osm')
* //='https://c.tile.openstreetmap.org/8/10/15.png'
*/
export function url(tile: Tile, scheme: string) {
export function slippyTile(tile: Tile, scheme: string) {
const [x, y, zoom] = tile

@@ -37,16 +54,16 @@ let url = providerLookup(scheme)

/**
* Downloads Tile
*
* @param {Tile} tile Tile [x, y, zoom]
* @param {string} scheme Tile scheme URL or pre-loaded source unique key
* @returns {Promise<Buffer>} tile buffer
* @example
* const url = slippyTile.url([10, 15, 8], 'osm')
* //='https://c.tile.openstreetmap.org/8/10/15.png'
*/
export async function download(tile: Tile, scheme: string): Promise<Buffer> {
return rp.get(url(tile, scheme), { encoding : 'binary' })
.then(data => new Buffer(data, 'binary'))
}
// /**
// * Downloads Tile
// *
// * @param {Tile} tile Tile [x, y, zoom]
// * @param {string} scheme Tile scheme URL or pre-loaded source unique key
// * @returns {Promise<Buffer>} tile buffer
// * @example
// * const url = slippyTile.url([10, 15, 8], 'osm')
// * //='https://c.tile.openstreetmap.org/8/10/15.png'
// */
// export async function download(tile: Tile, scheme: string): Promise<Buffer> {
// return rp.get(url(tile, scheme), { encoding : 'binary' })
// .then(data => new Buffer(data, 'binary'))
// }

@@ -59,4 +76,4 @@ /**

* @example
* const scheme = 'http://tile-{switch:a,b,c}.openstreetmap.fr/hot/{zoom}/{x}/{y}.png'
* const url = slippyTile.parseSwitch(scheme)
* import { parseSwitch } from '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'

@@ -78,5 +95,6 @@ */

* @param {string} provider Provider unique key
* @returns {string} scheme Tile scheme URL
* @returns {string} url Tile URL scheme
* @example
* const scheme = slippyTile.providerLookup('bing')
* import { provider } from 'slippyTile'
* provider('bing-imagery')
* //='http://ecn.t{switch:0,1,2,3}.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=5250'

@@ -88,3 +106,3 @@ */

if (providers[key] !== undefined) {
return providers[key].scheme
return providers[key].url
}

@@ -101,3 +119,4 @@ }

* @example
* const item = sample(['a', 'b', 'c'])
* import { sample } from 'slippyTile'
* sample(['a', 'b', 'c'])
* //='a'

@@ -108,1 +127,3 @@ */

}
export default slippyTile
{
"name": "slippy-tile",
"version": "1.2.1",
"version": "1.2.2",
"description": "Helps convert Slippy Map url tile schemas",

@@ -8,3 +8,3 @@ "main": "index.js",

"scripts": {
"build": "tsc && js-yaml providers.yml",
"prepublish": "tsc",
"test": "tsc && npm run lint && nyc ava",

@@ -29,5 +29,3 @@ "docs": "tsc && cat HEADER.md > README.md && documentation build index.js -c documentation.yml -f md >> README.md && cat CHANGELOG.md >> README.md",

"@types/js-yaml": "^3.5.28",
"@types/bluebird": "^3.0.35",
"@types/request": "^0.0.31",
"@types/request-promise": "^3.0.32",
"@types/node": "^6.0.45",
"ava": "^0.16.0",

@@ -62,8 +60,5 @@ "coveralls": "^2.11.14",

"dependencies": {
"bluebird": "^3.4.6",
"global-mercator": "^1.3.2",
"js-yaml": "^3.6.1",
"request": "^2.75.0",
"request-promise": "^4.1.1"
"js-yaml": "^3.6.1"
}
}

@@ -19,6 +19,6 @@ [![Build Status](https://travis-ci.org/DenisCarriere/slippy-tile.svg?branch=master)](https://travis-ci.org/DenisCarriere/slippy-tile)

```javascript
import * as slippyTile from 'slippy-tile'
import slippyTile from 'slippy-tile'
const tile = [10, 15, 8] // x, y, zoom
const url = slippyTile.url(tile, 'osm')
const url = slippyTile(tile, 'osm')
//= https://b.tile.openstreetmap.org/8/10/15.png

@@ -55,3 +55,3 @@ ```

const scheme = 'https://{switch:a,b,c}.tile.openstreetmap.org/{zoom}/{x}/{y}.png'
const url = slippyTile.url([10, 15, 8], scheme)
const url = slippyTile([10, 15, 8], scheme)
//= https://b.tile.openstreetmap.org/8/10/15.png

@@ -72,3 +72,3 @@ ```

- `{proj}`: default = EPSG:3857
# url
# slippyTile

@@ -85,3 +85,4 @@ Substitutes the given tile information [x,y,zoom] to the URL tile scheme.

```javascript
const url = slippyTile.url([10, 15, 8], 'osm')
import slippyTile from 'slippyTile'
slippyTile([10, 15, 8], 'osm')
//='https://c.tile.openstreetmap.org/8/10/15.png'

@@ -92,20 +93,2 @@ ```

# download
Downloads Tile
**Parameters**
- `tile` **[Tile](https://en.wikipedia.org/wiki/Tiled_web_map)** Tile [x, y, zoom]
- `scheme` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Tile scheme URL or pre-loaded source unique key
**Examples**
```javascript
const url = slippyTile.url([10, 15, 8], 'osm')
//='https://c.tile.openstreetmap.org/8/10/15.png'
```
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Buffer](https://nodejs.org/api/buffer.html)>** tile buffer
# parseSwitch

@@ -122,4 +105,4 @@

```javascript
const scheme = 'http://tile-{switch:a,b,c}.openstreetmap.fr/hot/{zoom}/{x}/{y}.png'
const url = slippyTile.parseSwitch(scheme)
import { parseSwitch } from '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'

@@ -141,7 +124,8 @@ ```

```javascript
const scheme = slippyTile.providerLookup('bing')
import { provider } from 'slippyTile'
provider('bing-imagery')
//='http://ecn.t{switch:0,1,2,3}.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=5250'
```
Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** scheme Tile scheme URL
Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** url Tile URL scheme

@@ -159,3 +143,4 @@ # sample

```javascript
const item = sample(['a', 'b', 'c'])
import { sample } from 'slippyTile'
sample(['a', 'b', 'c'])
//='a'

@@ -167,4 +152,6 @@ ```

## 1.2.1 - 2016-10-20
## 1.2.2 - 2016-10-21
- Remove all `request` related dependencies
- Removed `download` method
- Added DigitalGlobe as provider

@@ -171,0 +158,0 @@ - Converted `source.json` to `providers.yml`

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments)).next());
});
};
const ava_1 = require('ava');
const slippyTile = require('./index');
const index_1 = require('./index');
ava_1.default('url', t => {
const scheme = 'https://tile.openstreetmap.org/{zoom}/{x}/{y}.png';
const tile = [10, 15, 8];
const url = slippyTile.url(tile, scheme);
const url = index_1.default(tile, scheme);
t.deepEqual(url, 'https://tile.openstreetmap.org/8/10/15.png');

@@ -20,10 +12,5 @@ });

const tile = [10, 15, 8];
const url = slippyTile.url(tile, 'osm');
const url = index_1.default(tile, 'osm');
t.true(!!url);
});
ava_1.default('download', (t) => __awaiter(this, void 0, void 0, function* () {
const tile = [10, 15, 8];
const buffer = yield slippyTile.download(tile, 'osm');
t.true(!!buffer);
}));
//# sourceMappingURL=test.js.map
import test from 'ava'
import * as slippyTile from './index'
import slippyTile from './index'
import { Tile } from './index'

@@ -8,3 +8,3 @@

const tile: Tile = [10, 15, 8]
const url = slippyTile.url(tile, scheme)
const url = slippyTile(tile, scheme)
t.deepEqual(url, 'https://tile.openstreetmap.org/8/10/15.png')

@@ -15,10 +15,4 @@ })

const tile: Tile = [10, 15, 8]
const url = slippyTile.url(tile, 'osm')
const url = slippyTile(tile, 'osm')
t.true(!!url)
})
test('download', async t => {
const tile: Tile = [10, 15, 8]
const buffer = await slippyTile.download(tile, 'osm')
t.true(!!buffer)
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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