示例#1
0
        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.Vector.Tile.VectorTileLayer layer = tile.GetLayer("water");
                Assert.NotNull(layer, "Tile contains 'water' layer. Layers: {0}", string.Join(",", tile.LayerNames().ToArray()));
                Assert.Greater(layer.VectorTileFeatures.Count, 0, "Water layer has features");
                // todo: Uncomment the lines below
                //Mapbox.Vector.Tile.VectorTileFeature feature = layer.GetFeature(0);
                //Assert.Greater(feature.Geometry<long>().Count, 0, "Feature has geometry");
                //Assert.Greater(tile.GeoJson.Length, 1000);
            }

            map.Unsubscribe(mapObserver);
        }
示例#2
0
        public void SeveralTiles()
        {
            var map = new Map <VectorTile>(_fs);

            var mapObserver = new Utils.VectorMapObserver();

            map.Subscribe(mapObserver);

            map.Vector2dBounds = Vector2dBounds.World();
            map.Zoom           = 3;   // 64 tiles.
            map.Update();

            _fs.WaitForAllRequests();

            Assert.AreEqual(64, mapObserver.Tiles.Count);

            foreach (var tile in mapObserver.Tiles)
            {
                if (!tile.HasError)
                {
                    Assert.Greater(tile.GeoJson.Length, 41);
                }
                else
                {
                    Assert.GreaterOrEqual(tile.Exceptions.Count, 1, "not set enough exceptions set on 'Tile'");
                }
            }

            map.Unsubscribe(mapObserver);
        }
示例#3
0
        public void World()
        {
            var map = new Map <VectorTile>(this.fs);

            map.Vector2dBounds = Vector2dBounds.World();
            map.Zoom           = 3;

            var mapObserver = new Utils.VectorMapObserver();

            map.Subscribe(mapObserver);
            map.Update();

            this.fs.WaitForAllRequests();

            Assert.AreEqual(64, mapObserver.Tiles.Count);

            map.Unsubscribe(mapObserver);
        }