Skip to content

kartotherian/tilelive-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'})