kartotherian/tilelive-promise

Name: tilelive-promise

Owner: kartotherian

Description: Augment tilelive source with promise functions

Created: 2017-03-31 04:48:08.0

Updated: 2017-11-01 10:53:02.0

Pushed: 2017-12-04 17:58:58.0

Homepage: null

Size: 14

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.