mapbox / mapbox/mapbox-gl-js

Refactor source interface to better accommodate non-tiled sources

Open
#3,186 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

refactoring :building_construction:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

We currently shoehorn all source types into the VectorTileSource interface by abusing Tile objects. For example, ImageSource populates a single Tile with a number of ad-hoc properties. This architecture breaks and causes bugs like https://github.com/mapbox/mapbox-gl-js/issues/3010.

There are several different types of sources in GL JS and each should have its own interface:

interface VectorTileSource {
    getVectorTileCoordURL(coord: TileCoord) => string;
    getVectorTile(url: string, callback: (error: Error, tile: VectorTile) => void) => void;
}

interface RasterTileSource {
    getRasterTileCoordURL(coord: TileCoord) => string;
    getRasterTile(url: string, callback: (error: Error, tile: ImageData) => void);
}

interface ImageSource {
    getImage(callback: (error: Error, image: ImageData) => void);
}

interface VideoSource {
    getVideo(callback: (error: Error, video: () => ImageData) => void);
}

Wiring up these interfaces to StyleLayers, SourceCache, etc will require some elbow grease and will be worth it. 💪 Note the elimination of Tile objects per #145.

Inspired by https://github.com/mapbox/mapbox-gl-js/issues/3010#issuecomment-244201644

Related to #2982 #281 #3010 #3123

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with js/source/image_source.js at the linked lines, then trace how StyleLayers and SourceCache consume source and Tile objects. Review the related issues, especially #3010 and #145, before mapping the existing source types. Done means distinct source interfaces are wired through the affected components without using Tile objects for non-tiled sources.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend, web-dev
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.