public void ParseSuccess() { var map = new Map <VectorTile>(_fs); var mapObserver = new Utils.VectorMapObserver(); map.Subscribe(mapObserver); // Helsinki city center. map.Center = new Vector2d(60.163200, 24.937700); for (int zoom = 15; zoom > 0; zoom--) { map.Zoom = zoom; map.Update(); _fs.WaitForAllRequests(); } // We must have all the tiles for Helsinki from 0-15. Assert.AreEqual(15, mapObserver.Tiles.Count); foreach (var tile in mapObserver.Tiles) { Assert.Greater(tile.LayerNames().Count, 0, "Tile contains at least one layer"); Mapbox.VectorTile.VectorTileLayer layer = tile.GetLayer("water"); Assert.NotNull(layer, "Tile contains 'water' layer. Layers: {0}", string.Join(",", tile.LayerNames().ToArray())); Assert.Greater(layer.FeatureCount(), 0, "Water layer has features"); Mapbox.VectorTile.VectorTileFeature feature = layer.GetFeature(0); Assert.Greater(feature.Geometry <long>().Count, 0, "Feature has geometry"); Assert.Greater(tile.GeoJson.Length, 1000); } map.Unsubscribe(mapObserver); }
private static async Task <VectorTile> baseTileToVector(object baseTile) { var tile = baseTile as Mapbox.VectorTile.VectorTile; var result = new VectorTile(); foreach (var lyrName in tile.LayerNames()) { Mapbox.VectorTile.VectorTileLayer lyr = tile.GetLayer(lyrName); var vectorLayer = new VectorTileLayer(); vectorLayer.Name = lyrName; for (int i = 0; i < lyr.FeatureCount(); i++) { Mapbox.VectorTile.VectorTileFeature feat = lyr.GetFeature(i); var vectorFeature = new VectorTileFeature(); vectorFeature.Extent = 1; vectorFeature.GeometryType = convertGeometryType(feat.GeometryType); vectorFeature.Attributes = feat.GetProperties(); var vectorGeometry = new List <List <Point> >(); foreach (var points in feat.Geometry <int>()) { var vectorPoints = new List <Point>(); foreach (var coordinate in points) { var dX = (double)coordinate.X / (double)lyr.Extent; var dY = (double)coordinate.Y / (double)lyr.Extent; vectorPoints.Add(new Point(dX, dY)); //var newX = Utils.ConvertRange(dX, extent.Left, extent.Right, 0, vectorFeature.Extent); //var newY = Utils.ConvertRange(dY, extent.Top, extent.Bottom, 0, vectorFeature.Extent); //vectorPoints.Add(new Point(newX, newY)); } vectorGeometry.Add(vectorPoints); } vectorFeature.Geometry = vectorGeometry; vectorLayer.Features.Add(vectorFeature); } result.Layers.Add(vectorLayer); } return(result); }