Exemple #1
0
        public void World()
#endif
        {
            var map = new Map <VectorTile>(_fs);

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

            var mapObserver = new Utils.VectorMapObserver();

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

#if UNITY_5_6_OR_NEWER
            IEnumerator enumerator = _fs.WaitForAllRequests();
            while (enumerator.MoveNext())
            {
                yield return(null);
            }
#else
            _fs.WaitForAllRequests();
#endif

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

            map.Unsubscribe(mapObserver);
        }
Exemple #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);
        }
 void Start()
 {
     map                = new Map <RasterTile>(MapboxAccess.Instance);
     map.Zoom           = 2;
     map.Vector2dBounds = Vector2dBounds.World();
     map.MapId          = "mapbox://styles/mapbox/streets-v10";
     map.Subscribe(this);
     map.Update();
 }
        public void World()
        {
            var bounds = Vector2dBounds.World();

            Assert.AreEqual(bounds.South, -90);
            Assert.AreEqual(bounds.West, -180);
            Assert.AreEqual(bounds.North, 90);
            Assert.AreEqual(bounds.East, 180);
        }
Exemple #5
0
    void Start()
    {
        var map = new Map <RasterTile>(MapboxAccess.Instance);

        map.Zoom           = 2;
        map.Vector2dBounds = Vector2dBounds.World();
        map.MapId          = "mapbox://styles/miker256/cj5w36k7r72ev2sr1c1mpnyii";
        map.Subscribe(this);
        map.Update();
    }
 public void World()
 {
     // Zoom > 8 will generate so many tiles that we
     // might run out of memory.
     for (int zoom = 0; zoom < 8; ++zoom)
     {
         var tiles = TileCover.Get(Vector2dBounds.World(), zoom);
         Assert.AreEqual(Math.Pow(4, zoom), tiles.Count);
     }
 }
Exemple #7
0
    public void initializeRasterMap(Vector2 latLong, int zFactor)
    {
        var map = new Map <RasterTile>(MapboxAccess.Instance);

        map.Zoom           = zFactor;
        map.Vector2dBounds = Vector2dBounds.World();
        map.Center         = new Mapbox.Utils.Vector2d((double)latLong.x, (double)latLong.y);

        map.Subscribe(this);
        map.Update();
    }
Exemple #8
0
        public void SetVector2dBoundsZoom()
        {
            var map1 = new Map <RasterTile>(this.fs);
            var map2 = new Map <RasterTile>(this.fs);

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

            map2.SetVector2dBoundsZoom(Vector2dBounds.World(), 3);

            Assert.AreEqual(map1.Tiles.Count, map2.Tiles.Count);
        }
Exemple #9
0
    void Start()
    {
        var map = new Map <RasterTile>(MapboxAccess.Instance);

        map.Zoom           = 16;
        map.Vector2dBounds = Vector2dBounds.World();
        //map.Center = new Mapbox.Utils.Vector2d((double)latLong.x, (double)latLong.y);
        //map.MapId = "mapbox://styles/mapbox/outdoors-v4";
        map.MapId = "mapbox://styles/mapbox/streets-v10";
        map.Subscribe(this);
        map.Update();
    }
Exemple #10
0
        public void ToVector2d()
        {
            var set = TileCover.Get(Vector2dBounds.World(), 5);

            foreach (var tile in set)
            {
                var reverse = TileCover.CoordinateToTileId(tile.ToVector2d(), 5);

                Assert.AreEqual(tile.Z, reverse.Z);
                Assert.AreEqual(tile.X, reverse.X);
                Assert.AreEqual(tile.Y, reverse.Y);
            }
        }
Exemple #11
0
        public void TileMax()
        {
            var map = new Map <RasterTile>(this.fs);

            map.SetVector2dBoundsZoom(Vector2dBounds.World(), 2);
            map.Update();
            Assert.Less(map.Tiles.Count, Map <RasterTile> .TileMax);           // 16

            // Should stay the same, ignore requests.
            map.SetVector2dBoundsZoom(Vector2dBounds.World(), 5);
            map.Update();
            Assert.AreEqual(16, map.Tiles.Count);
        }
        private void Update()
        {
            if (_map.AbsoluteZoom > 5)
            {
                throw new System.Exception("Too many tiles! Use a lower zoom level!");
            }

            var tileCover = TileCover.Get(Vector2dBounds.World(), _map.AbsoluteZoom);

            foreach (var tile in tileCover)
            {
                AddTile(new UnwrappedTileId(tile.Z, tile.X, tile.Y));
            }
        }
Exemple #13
0
        public override void OnInitialized()
        {
            // HACK: don't allow too many tiles to be requested.
            if (_map.Zoom > 5)
            {
                throw new System.Exception("Too many tiles! Use a lower zoom level!");
            }

            var tileCover = TileCover.Get(Vector2dBounds.World(), _map.Zoom);

            foreach (var tile in tileCover)
            {
                AddTile(new UnwrappedTileId(tile.Z, tile.X, tile.Y));
            }
        }
Exemple #14
0
        public override void UpdateTileExtent()
        {
            // HACK: don't allow too many tiles to be requested.
            if (_map.AbsoluteZoom > 5)
            {
                throw new System.Exception("Too many tiles! Use a lower zoom level!");
            }

            var tileCover = TileCover.Get(Vector2dBounds.World(), _map.AbsoluteZoom);

            foreach (var tile in tileCover)
            {
                _currentExtent.activeTiles.Add(new UnwrappedTileId(tile.Z, tile.X, tile.Y));
            }
            OnExtentChanged();
        }
Exemple #15
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);
        }
Exemple #16
0
        internal override void OnInitialized()
        {
            // HACK: don't allow too many tiles to be requested.
            if (_map.Zoom > 5 || fullZoom > 8)
            {
                throw new System.Exception("Too many tiles! Use a lower zoom level!");
            }

            if (showHighResArea)
            {
                string cacheFilename = ((int)(highResN * highResE * highResS * highResW * fullZoom)).ToString() + ".cache";

                if (File.Exists(cacheFilename))
                {
                    using (BinaryReader reader = new BinaryReader(File.Open(cacheFilename, FileMode.Open)))
                    {
                        int count = reader.ReadInt32();
                        for (int i = 0; i < count; ++i)
                        {
                            int z = reader.ReadInt32();
                            int x = reader.ReadInt32();
                            int y = reader.ReadInt32();

                            AddTile(new UnwrappedTileId(z, x, y));
                        }
                    }

                    return;
                }

                var sw = new Vector2d(highResS, highResW);
                var ne = new Vector2d(highResN, highResE);
                var b  = new Vector2dBounds(sw, ne);

                for (int i = _map.Zoom; i < fullZoom; ++i)
                {
                    overlappingTileCoverCache.Add(TileCover.Get(b, i));
                }

                AddTiles(Vector2dBounds.World(), _map.Zoom);

                using (BinaryWriter writer = new BinaryWriter(File.Open(cacheFilename, FileMode.Create)))
                {
                    writer.Write(finalTiles.Count);
                    foreach (var t in finalTiles)
                    {
                        writer.Write(t.Z);
                        writer.Write(t.X);
                        writer.Write(t.Y);

                        AddTile(t);
                    }
                }
            }
            else
            {
                foreach (var tile in TileCover.Get(Vector2dBounds.World(), _map.Zoom))
                {
                    AddTile(new UnwrappedTileId(tile.Z, tile.X, tile.Y));
                }
            }
        }