Promisify tilelive and add extra context
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 540
- Forks
- 106
- PR merge metrics
- No merged PRs in 30d
Description
tilelive is fundamentally a URI-based dependency container service, allowing separation between service implementation/instantiation and service consumption. Moving away from the rigid `getTile(z,x,y)` API would allow more diverse context parameters and non-tile services.
* A single "get" function with a single options object instead of individual parameters to handle implementation-specific functionality.
* Promises instead of callbacks, as Promises have now became widely spread, and the current Node (7) supports language-integrated constructs (async/await)
For example, `getTile(z, x, y, callback(err, data, headers))` would be something like `Promise<{data, headers}> getAsync({zoom: z, index: ind, extra1: ...})`
For compatibility, tilelive should inject a rudimentary `getAsync()` ([See injection lib](https://github.com/kartotherian/tilelive-promise#tilelive-promise)), that only supports the basic {tile|grid|info} modes into the legacy tilelive sources. The auto-injected `getAsync()` would not support any of the magical customizations, such as parameters set on callback function. For that, the source would have to implement its own version of getAsync, e.g. [tilelive-vector PR](https://github.com/mapbox/tilelive-vector/pull/141/files).
Immediate benefits of adding a single `getAsync()` function:
* ability to pass additional parameters through the stack callchain. E.g. `language`, `licence`, ...
* ability to handle non-tile requests like snapshots (custom area of the map with the given width/height)
* ability to integrate related services using the same pipeline. For example, in Wikipedia, Kartotherian can get geojson for a specific area, and that same geojson could be used as an extra layer in the snapshot service. Another example - simple-style markers (pushpins) - request a given marker/color/icon size/scaling, and get back an image via the same chain, but with somewhat different params. The source instantiation will continue using the existing tilelive container, without the need to create a separate pipeline.
* ability to introduce an alternative (additional) way of addressing tiles - a single [quad-based index](https://github.com/kartotherian/quadtile-index) instead of x,y coordinates
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the linked tilelive-promise injection library and the tilelive-vector PR to understand the proposed compatibility layer and source-specific implementation. Done means tilelive can expose promise-based getAsync() calls with an options object, while preserving basic tile, grid, and info behavior for legacy sources.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100