@wikimedia/tilelive-promise

2.1.0 • Public • Published

Build Status

tilelive-promise

Adds an extended Promise-based interface to the existing tilelive components, or exposes new components to older tilelive systems.

This module supplies either a modern or a legacy wrapper for the tilelive (TileSource) object.

For sources that implement getTile(), getGrid() and getInfo(), creates a new getAsync() generic function.

For sources that implement getAsync(), supplies the callback-based getTile(), getGrid() and getInfo().

If both getTile() and getAsync() are present, the instance is returned unmodified.

Promise<object> getAsync(options)

The new function allows to treat get*() as promises, permits additional parameter passing with each request (e.g. scaling, format, language), and allow non-tile data to be retrieved through the same system.

Both tile and grid requests via GetAsync() may also use an index parameter instead of (x,y) coordinates. Index is a single 56bit quadtile integer, allowing up to zoom 26.

getAsync() returns a Promise that resolves to an object. The content of the object depends on the type.

Legacy vs New interface

get*() tilelive API getAsync() API
getTile(z, x, y,
  callback<err, tile, headers>)
Promise{data, headers} getAsync({z, x, y})
or
Promise{data, headers} getAsync(
  {type:'tile', z, x, y})
getGrid(z, x, y,
  callback<err, grid, headers>)
Promise{data, headers} getAsync(
  {type:'grid', z, x, y})
getInfo(callback<err, info>) Promise{data} getAsync({type:'info'})

Package Sidebar

Install

npm i @wikimedia/tilelive-promise

Weekly Downloads

1

Version

2.1.0

License

MIT

Unpacked Size

7.79 kB

Total Files

4

Last publish

Collaborators

  • adamwight
  • wmde-fisch
  • thiemowmde
  • jgiannelos-wmf