private void RequestTiles(TmsGlobalGeodeticTileSchema schema, TileRange tileRange, List <TileInfo> tiles)
        {
            //immediately draw placeholder tile and fire request for texture and height. Depending on which one returns first, update place holder.
            foreach (var t in tiles)
            {
                //draw placeholder tile
                var tile = DrawPlaceHolder(tileRange, t);

                tileDb.Add(new Vector3(t.Index.Col, t.Index.Row, int.Parse(t.Index.Level)), tile);

                //get tile texture data
                string surfaceUrl = "";

                switch (surface.Service)
                {
                case DataService.WMS:
                    var subtileExtent = TileTransform.TileToWorld(new TileRange(t.Index.Col, t.Index.Row), t.Index.Level.ToString(), schema);
                    surfaceUrl = surface.Url.Replace("{xMin}", subtileExtent.MinX.ToString()).Replace("{yMin}", subtileExtent.MinY.ToString()).Replace("{xMax}", subtileExtent.MaxX.ToString()).Replace("{yMax}", subtileExtent.MaxY.ToString()).Replace(",", ".");
                    break;

                case DataService.TMS:
                    surfaceUrl = surface.Url.Replace("{x}", t.Index.Col.ToString()).Replace("{y}", t.Index.Row.ToString()).Replace("{z}", int.Parse(t.Index.Level).ToString());
                    break;
                }

                downloadQueue.Enqueue(new DownloadRequest(surfaceUrl, DataType.Surface, new Vector3(t.Index.Col, t.Index.Row, int.Parse(t.Index.Level))));


                //get tile height data (
                var terrainUrl = terrain.Url.Replace("{x}", t.Index.Col.ToString()).Replace("{y}", t.Index.Row.ToString()).Replace("{z}", int.Parse(t.Index.Level).ToString());
                downloadQueue.Enqueue(new DownloadRequest(terrainUrl, DataType.Terrain, new Vector3(t.Index.Col, t.Index.Row, int.Parse(t.Index.Level))));
            }
        }
        private void LoadMap()
        {
            ClearCache();

            var schema    = new TmsGlobalGeodeticTileSchema();
            var tileRange = TileTransform.WorldToTile(extent, zoomLevel.ToString(), schema);
            var tiles     = schema.GetTileInfos(extent, zoomLevel.ToString()).ToList();

            RequestTiles(schema, tileRange, tiles);

            //if (useSatellite)
            //{
            //    var schema2 = new BruTile.Predefined.GlobalSphericalMercator(YAxis.TMS);
            //    var tiles2 = schema2.GetTileInfos(extent, zoomLevel.ToString()).ToList();

            //    foreach (var t in tiles2)
            //    {
            //        var url = textureUrl.Replace("{x}", t.Index.Col.ToString()).Replace("{y}", t.Index.Row.ToString()).Replace("{z}", int.Parse(t.Index.Level).ToString()); //WMTS
            //        downloadQueue.Enqueue(new DownloadRequest(url, TileServiceType.WMS, new Vector3(t.Index.Col, t.Index.Row, int.Parse(t.Index.Level))));
            //    }
            //}
        }
Esempio n. 3
0
        public void CreateTiles()
        {
            ClearTiles();
            sw.Start();

            var schema    = new TmsGlobalGeodeticTileSchema();
            var tileRange = TileTransform.WorldToTile(extent, zoomLevel.ToString(), schema);

            var tilesOrigin = schema.GetTileInfos(extent, 13.ToString()).ToList();   //refactor when done experimenting scale
            var tiles       = schema.GetTileInfos(extent, zoomLevel.ToString()).ToList();

            yOffset = (float)Math.Abs(tiles[0].Extent.MinY - tilesOrigin[0].Extent.MinY);
            xOffset = (float)Math.Abs(tiles[0].Extent.MinX - tilesOrigin[0].Extent.MinX);
            UnityEngine.Debug.Log(xOffset);

            var folder = new GameObject("map");

            //immediately draw placeholder tile and fire request for texture and height. Depending on which one returns first, update place holder.
            foreach (var t in tiles)
            {
                //draw placeholder tile
                GameObject tile = DrawPlaceHolder(tileRange, t);
                tile.transform.parent = folder.transform;

                tileDb.Add(new Vector3(t.Index.Col, t.Index.Row, int.Parse(t.Index.Level)), tile);

                //get tile texture data
                Extent subtileExtent = TileTransform.TileToWorld(new TileRange(t.Index.Col, t.Index.Row), t.Index.Level.ToString(), schema);
                var    wmsUrl        = textureUrl.Replace("{xMin}", subtileExtent.MinX.ToString()).Replace("{yMin}", subtileExtent.MinY.ToString()).Replace("{xMax}", subtileExtent.MaxX.ToString()).Replace("{yMax}", subtileExtent.MaxY.ToString()).Replace(",", ".");
                downloadQueue.Enqueue(new downloadRequest(wmsUrl, TileService.WMS, new Vector3(t.Index.Col, t.Index.Row, int.Parse(t.Index.Level))));

                //get tile height data (
                var qmUrl = terrainUrl.Replace("{x}", t.Index.Col.ToString()).Replace("{y}", t.Index.Row.ToString()).Replace("{z}", int.Parse(t.Index.Level).ToString());
                downloadQueue.Enqueue(new downloadRequest(qmUrl, TileService.QM, new Vector3(t.Index.Col, t.Index.Row, int.Parse(t.Index.Level))));
            }
        }