Coder Social home page Coder Social logo

Improve RasterStyle about mapsui HOT 4 OPEN

pauldendulk avatar pauldendulk commented on September 25, 2024
Improve RasterStyle

from mapsui.

Comments (4)

taublast avatar taublast commented on September 25, 2024 1

Hey Paul, just wanted to share that implementation of "The Tile is rasterized with custom effects just once and cached", going to publish app today:

devenv_ecyOsyAATW.mp4

Subclassed the loader: https://github.com/taublast/DrawnUi.Maui/blob/main/src/Addons/DrawnUi.Maui.MapsUi/src/CustomizeDownloadedTiles.cs

from mapsui.

pauldendulk avatar pauldendulk commented on September 25, 2024 1

ah, this is at a really low level. You subclassed the HttpTileSource which is part of BruTile. The Encode() returns a png. You could store it to disk as a regular image png. You could also write it to an MbTiles file and open it in QGIS, no Mapsui needed.

from mapsui.

taublast avatar taublast commented on September 25, 2024

Hi Paul!
What kind of improvement/look would you have in mind? Some presets/properties for ISkiaStyle, or maybe more ways to hook custom code that would affect the rendering result?
A quick guess is that we could plug almost any functionality inside a custom ISkiaStyleRenderer. In the mentioned demo I didn't do it because the goal was to create a map control for drawnUi but if I were to use plain Maui, for example, I would add hardware acceleration support for Maui and then create a custom RasterStyleRenderer to achieve the same result. At the same time if we need fast rendering and we have a static result we want to achieve we could custom-render received tiles upon loading and save the final result to cache.
Ways i was considering when thinking about customizing raw tiles, I used the option B:

  • A. The Tile is rasterized with custom effects just once and cached, to be fast drawn from an existing image later. Would use for production app when you already know your final static modifications. With actual implementation would need to hook inside the loader.
  • B. Customization code is dynamically applied to rendering operation at display/browse time, for heavy stuff better have hardware acceleration. Nice for tryouts and affecting any element that supports IRasterStyle, not only tiles.

from mapsui.

pauldendulk avatar pauldendulk commented on September 25, 2024

Hi Nick!

Sorry for my late reply.

What I had in mind is not too ambitious. In your sample you created a custom renderer which can render the tile in certain styles. My idea was to add those (or some of those) options to the existing RasterStyle so that our users can use it without having to use skia.

I did not intent to add more ways to make Mapsui more pluggable. I hope a custom ISkiaStyleRenderer is enough for all scenarios.

but if I were to use plain Maui, for example, I would add hardware acceleration support for Maui and then create a custom RasterStyleRenderer to achieve the same result.

I don't fully understand this. In Mapsui we use skia and skia has options for GPU support in some of their views and some of their platforms. We don't do anything else but turn it on if available. I don't see how we could make use of Maui hardware acceleration.

  • A. The Tile is rasterized with custom effects just once and cached, to be fast drawn from an existing image later. Would use for production app when you already know your final static modifications. With actual implementation would need to hook inside the loader.
  • B. Customization code is dynamically applied to rendering operation at display/browse time, for heavy stuff better have hardware acceleration. Nice for tryouts and affecting any element that supports IRasterStyle, not only tiles.

I have a similar thing in the case of SVGs. We currently create a SKPicture which contains the colors as well. If we want a custom color we need to create an altered copy of the SKPicture. The upside is that this is fast. The downside is that you could need many colors and the cache will grow. In the case of SVGs this is a big problem because you could have continuous color values leading to a cache item very every feature (and there could be 10.000 features). The alternative is to use SKPaths and SKPaints.

For tiles it is less likely to be different for every tile. So there a SKPicture per tile might not be a problem. The downside will be that you can not easily change this without clearing the cache. So a slider which changes the darkness of a tile will not transition smoother. Still I think an SKImage and SKPaint might be the best option for us.

Then again, this is a complicate problem for which I don't expect a perfect solution. We are currently working on changes to the cache so this is not something to change things to in the current code base.

from mapsui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.