AliFlux / VectorTileRenderer

A comprehensive Vector Map Tile Renderer for .Net/C#
MIT License
183 stars 51 forks source link

Active developed #14

Open BergChristian opened 4 years ago

BergChristian commented 4 years ago

Hi Ali

Ran into your project and I think this is a great one and I can't see any other on the Internet doing what you do. I can see that there is some time ago it was actively developed. I am happy to contribute to the project if you are interesting in taking it active. I can see HW rendering is one thing to achieve as well as spending some time on that function to draw street names...

All the best Christian

AliFlux commented 4 years ago

Hi, Thanks for the interest. Contributions are certainly welcome for this project. Let me know which part/feature are you interested in.

BergChristian commented 4 years ago

Hi

I am interested in getting performance up. Either HW accelerated drawing using Direct2D or maybe just see if there is other things to do

charlenni commented 4 years ago

I assume, that drawing isn‘t the bottle neck. I draw all lines and polygons in 5-10 ms with GPU backend of Skia. The problem is reading the data, decoding it and than, one of the biggest part, evaluating the filter of each style layer with each feature of the data.

Another big part is the placing of symbols and text on the tile. For this you need the symbols and text of the surrounding 8 tiles (read data, decode and filter for all 8 tiles). I assume, that this costs the most time at the end.

AliFlux commented 4 years ago

A couple of days ago, I was porting this renderer to Cesium JS library for vector tile rendering on the fly. I did some extensive tests and figured out that the biggest bottleneck is the filter.

The filter system is essentially a function evaluator. One way to speed it up would be to generate a filter code (in C#) for each layer as soon as the style is loaded. Then execute that filter code in run-time for faster performance (see this for runtime execution of C# code).

charlenni commented 4 years ago

I’m not sure, if this approach (runtime execution of C# code) runs on all platforms (.Net, iOS, Android and so on).

I made the filter system with special objects, that all implement an evaluation function (see here). I tried to optimize it. One big point was to go away from Json objects. They are flexible, but slow. Now it is acceptable fast. Perhaps it could be made faster, if some feature sorted out before filtering, because line or fill layers aren’t interested in points.

Perhaps someone has another idea to speed it up.

AliFlux commented 4 years ago

That's some nicely organized code. I'm experimenting with web-based vector rendering, and so far the best way to go about it is to dynamically compile filters.

CBergAccount commented 4 years ago

Hi!

I have tried this https://openmaptiles.com/ It works nicely with your code but it is insanely fast on the web. Any idea how they make it so fast?

charlenni commented 4 years ago

How did you tested OpenMapTiles with this code?

CBergAccount commented 4 years ago

Hi,

You could download a trial from there web page which I used directly with your code and GMAP.Net. Worked straight out of the box.

I just the Winform example you provide.

AliFlux commented 4 years ago

On the web, it uses WebGL and some extreme optimization techniques to render the vector tiles. Can you test your openmaptiles with the tileserver-gl in raster mode? (it uses a similar technique of rendering)

CBergAccount commented 4 years ago

I am sorry, I don't have the time right now to test it and since I am not familiar with Java it would take me a lot of time... If you want to try it, just download the vector tiles, just download it from their webpage.

AliFlux commented 3 years ago

Hi. I was implementing vector tiles for web using javascript and HTML5 canvas. Turns out the biggest performance bottleneck is the filtering operations. I'll be testing it further and posting results

AliFlux commented 3 years ago

I've updated the repo with some performance improvements. Here are a few of these: