cesium-native icon indicating copy to clipboard operation
cesium-native copied to clipboard

Rasterize GeoJSON data for a RasterOverlay

Open azrogers opened this issue 8 months ago • 1 comments

Another step on the long road to CesiumGS/cesium-unreal#628 - a raster overlay for VectorDocument objects. This allows vector data loaded from GeoJSON (or, in theory, any other format once support is added) to be rasterized and overlaid onto a tileset. While not the most optimal choice in terms of visual quality, this does have the benefit of being a relatively quick-and-easy to add support for rendering vector data.

While I originally tried to write my own triangle rasterizer, I quickly realized that it would be a better decision to find something else that does the job better than I could. Skia is the obvious choice - widely used, actively developed, well tested - but the fact that even the smallest binary with as many optional features turned off is still 14MB spooked me. For now, I've gone with Blend2D. This is a very fast vector rasterization library (possibly even faster than Skia), but has the disadvantage of fewer features. For one, it only really supports ARGB32 as a pixel format, which is inconvenient for this raster overlay (we have to manually swizzle it into RGBA32), but just plain wasteful for the RasterizedPolygonsOverlay. ~Also, pretty important for full support for vector data - it doesn't support polygons with holes in them, from what I can tell. Maybe there's an approach I'm missing, but this is necessary to actually render some polygons from a GeoJSON file or from other formats.~ (incorrect - see below)

Also, we should do something about the line width so it looks fairly consistent across LODs - it would make the change between LODs less obvious.

azrogers avatar Apr 24 '25 21:04 azrogers

After asking the blend2d developers, it turns out that polygons with holes are supported - I just needed to get the winding order right!

azrogers avatar Apr 25 '25 15:04 azrogers

Was going to push a fix to the BoundingRegionBuilder antimeridian handling but looks like you already solved it 😅 Your solution is more elegant than mine was going to be anyways!

azrogers avatar Jul 31 '25 14:07 azrogers

Thanks @azrogers, great work on this!

kring avatar Jul 31 '25 22:07 kring