forked from bertt/mapbox-vector-tile-cs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
60 lines (53 loc) · 1.9 KB
/
Copy pathForm1.cs
File metadata and controls
60 lines (53 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using Mapbox.Vector.Tile;
using VelloSharp.WinForms;
using VelloSharp.WinForms.Integration;
using System.Drawing;
namespace VelloWindowsFormSample
{
public partial class Form1 : Form
{
private VelloRenderControl velloControl;
public Form1()
{
InitializeComponent();
velloControl = new VelloRenderControl
{
Dock = DockStyle.Fill // Laat het de hele Form vullen
};
velloControl.PaintSurface += OnPaintSurface;
Controls.Add(velloControl);
}
private void OnPaintSurface(object sender, VelloPaintSurfaceEventArgs e)
{
// Verkrijg de graphics context
var graphics = e.GetGraphics();
// Wis het canvas met een achtergrondkleur (via clear color op scene)
graphics.Clear(Color.White);
// Maak een pen aan
var pen = new VelloPen(Color.Blue, 5);
// Load cadastral.pbf from the executable's directory
var exeDirectory = AppContext.BaseDirectory;
var vtfile = Path.Combine(exeDirectory, "cadastral.pbf");
using (var stream = File.OpenRead(vtfile))
{
var layerInfos = VectorTileParser.Parse(stream);
var layerInfo = layerInfos[0];
foreach (var feature in layerInfo.VectorTileFeatures)
{
var coords = feature.Geometry[0];
for (var i = 1; i < coords.Count; i++)
{
var c0 = coords[i-1];
var c1 = coords[i];
graphics.DrawLine(pen, new PointF(c0.X, c0.Y), new PointF(c1.X, c1.Y));
}
}
}
// Dispose de pen
pen.Dispose();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}