maplibre / maplibre-rs

Experimental Maps for Web, Mobile and Desktop
Apache License 2.0
1.32k stars 76 forks source link

Raster Tile Rendering #71

Open maxammann opened 2 years ago

maxammann commented 2 years ago

We want to be able to render raster tiles. This is required for rendering data sets like "Natural Earth". Raster tiles can be of any web-native image format like PNG or WEBP.

🤔 Expected Behavior

Raster tiles need to be scaled and transformed like vector tiles.

😯 Current Behavior

No raster tiles are supported.

💁 Possible Solution

The WebGPU spec offers a way to load bitmaps to textures: https://toji.github.io/webgpu-best-practices/img-textures.html In the browser this requires the createImageBitmap() API which offloads decoding of images to the browser.

🔦 Context

💻 Examples

ybiletskyi commented 2 years ago

Any ideas about implementation of this feature?

maxammann commented 2 years ago

This is currently blocked by wgpu. The copyExternalImageToTexture is not yet available and need to be implemented in wgpu. The devs of wgpu said that this is probably not very hard to do. So if you want to work on this then this would be a valuable contribution :)

ybiletskyi commented 2 years ago

Got it. Thanks for update. I'll try to implement it in wgpu.

quietlychris commented 2 years ago

Just as a note: I have a personal interest in this feature! At the moment, I'm using MapLibre (JavaScript) on my personal site to overlay .webp images of environmental drone imagery I've collected. The site's backend is actually written in Rust, and I'd love the opportunity to re-write this particular application with maplibre-rs as well, which is dependent on raster imagery being available (and symbols). Really excited about this project, so just wanted to mention a use case I'd personally be delighted to have support for at some point. I don't have a ton of capacity for new contributions at the moment, but if you need support for something like testing for either this project or the wgpu feature, just let me know!

ybiletskyi commented 2 years ago

Hey. I just created a PR to wgpu. It probably take a time to merge it. But it's not a blocker any more for start this feature implementation.

maxammann commented 2 years ago

@ybiletskyi, @Quillasp might also be interested in working on this as part of his bachelor thesis. I wondered whether collaboration could make sense. If not it shouldn't be hard to find two distinct areas to work on in maplibre-rs.

ybiletskyi commented 2 years ago

It's not a problem for collaboration. I'll be happy to work with @Quillasp. But need to analyze and estimate amount of work. Maybe this feature not so big for 2 dev collaboration. In that case I might to switch to another feature.

maxammann commented 2 years ago

@Drabble can you check with @Quillasp?

quillasp commented 2 years ago

@Drabble gave me an overview of the project today. But the project is still quite big (for me at least), do you have any idea where I should start looking in the code to see where I could implement the basics of this feature ? (sorry for the noob question)

ybiletskyi commented 2 years ago

Probably you should add new layer with type raster link that represent raster tiles on a map. Than you add logic for loading data (io module I supose) and processing data. After that I think you can start to render data.