Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor source interface to better accommodate non-tiled sources #3186

Open
lucaswoj opened this issue Sep 14, 2016 · 5 comments
Open

Refactor source interface to better accommodate non-tiled sources #3186

lucaswoj opened this issue Sep 14, 2016 · 5 comments

Comments

@lucaswoj
Copy link
Contributor

lucaswoj commented Sep 14, 2016

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 #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 #3010 (comment)

Related to #2982 #281 #3010 #3123

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Oct 7, 2016

I just updated the interface proposals above to address the concerns of #3123 and the needs of #3051 🚀

@mourner
Copy link
Member

mourner commented Oct 12, 2016

@lucaswoj why does getVectorTile accept url but getRasterTile accept coord? I guess both should be either url or coord.

@lucaswoj
Copy link
Contributor Author

@mourner Typo. Fixed above.

@1ec5
Copy link
Contributor

1ec5 commented Nov 10, 2016

This is also being tracked for the iOS and macOS SDKs in mapbox/mapbox-gl-native#6861, happening in mapbox/mapbox-gl-native#6940.

@anandthakker
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants