Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DataUriStyleRenderer.cs
1using Mapsui;
2using Mapsui.Extensions;
3using Mapsui.Layers;
4// Attempt to use Skia renderer interfaces; if unavailable, fall back to stub.
5#if MAPSUI_SKIA
6using Mapsui.Rendering.Skia; // Provides ISkiaStyleRenderer & IRenderCache in Mapsui Skia packages
7#endif
8using Mapsui.Rendering.Skia.SkiaStyles;
9using Mapsui.Styles;
10using SkiaSharp;
11
13{
14#if MAPSUI_SKIA
19 public class DataUriStyleRenderer : ISkiaStyleRenderer
20 {
32 public bool Draw(
33 SKCanvas Canvas,
34 Viewport Viewport,
35 ILayer Layer,
36 IFeature Feature,
37 IStyle Style,
38 IRenderCache RenderCache,
39 long Iteration)
40 {
41 if (Style is not DataUriStyle CustomStyle)
42 return false;
43
44 // Extract a single coordinate (assumes point geometry)
45 double WorldX = 0;
46 double WorldY = 0;
47 bool GotPoint = false;
48
49 Feature.CoordinateVisitor((X, Y, Setter) =>
50 {
51 WorldX = X;
52 WorldY = Y;
53 GotPoint = true;
54 });
55
56 if (!GotPoint)
57 return false;
58
59 MPoint WorldPoint = new MPoint(WorldX, WorldY);
60 MPoint Screen = Viewport.WorldToScreen(WorldPoint);
61
62 string DataUri = Feature["DataUri"]?.ToString() ?? string.Empty;
63
64 // Placeholder: Render a circle. Replace with logic parsing DataUri into an icon.
65 using SKPaint Paint = new SKPaint
66 {
67 Color = SKColors.Blue.WithAlpha((byte)(255 * CustomStyle.Opacity)),
68 IsAntialias = true
69 };
70 Canvas.DrawCircle((float)Screen.X, (float)Screen.Y, 12, Paint);
71
72 return true;
73 }
74 }
75#else
80 {
81 public bool Draw() => false;
82 }
83#endif
84}
Stub renderer compiled when MAPSUI_SKIA is not defined; avoids build break.