Exemplo n.º 1
0
        public void TileFetcherShouldRequestAllTilesJustOnes()
        {
            // Arrange
            var tileProvider    = new CountingTileProvider();
            var tileSchema      = new GlobalSphericalMercator();
            var tileSource      = new TileSource(tileProvider, tileSchema);
            var cache           = new MemoryCache <Feature>();
            var fetchDispatcher = new TileFetchDispatcher(cache, tileSource.Schema, (tileInfo) => TileToFeature(tileSource, tileInfo));
            var tileMachine     = new FetchMachine(fetchDispatcher);
            var level           = 4;
            var expextedTiles   = 256;

            // Act
            // Get all tiles of level 3
            fetchDispatcher.SetViewport(tileSchema.Extent.ToBoundingBox(), tileSchema.Resolutions[level].UnitsPerPixel);
            tileMachine.Start();
            // Assert
            while (fetchDispatcher.Busy)
            {
            }

            Assert.AreEqual(expextedTiles, tileProvider.CountByTile.Keys.Count);
            Assert.AreEqual(expextedTiles, tileProvider.CountByTile.Values.Sum());
            Assert.AreEqual(expextedTiles, tileProvider.TotalCount);
        }
Exemplo n.º 2
0
        public void TileFetcherShouldRequestAllTilesJustOnes()
        {
            // Arrange
            var tileProvider = new CountingTileProvider();
            var tileSchema   = new GlobalSphericalMercator();
            var tileSource   = new TileSource(tileProvider, tileSchema);

            using var cache = new MemoryCache <IFeature?>();
            var fetchDispatcher = new TileFetchDispatcher(cache, tileSource.Schema, async tileInfo => await TileToFeatureAsync(tileSource, tileInfo));
            var tileMachine     = new FetchMachine(fetchDispatcher);
            var level           = 3;
            var expectedTiles   = 64;

            var fetchInfo = new FetchInfo(tileSchema.Extent.ToMRect(), tileSchema.Resolutions[level].UnitsPerPixel);

            // Act
            // Get all tiles of level 3
            fetchDispatcher.SetViewport(fetchInfo);
            tileMachine.Start();
            // Assert
            while (fetchDispatcher.Busy)
            {
                Thread.Sleep(1);
            }

            Assert.AreEqual(expectedTiles, tileProvider.CountByTile.Keys.Count);
            Assert.AreEqual(expectedTiles, tileProvider.CountByTile.Values.Sum());
            Assert.AreEqual(expectedTiles, tileProvider.TotalCount);
        }
Exemplo n.º 3
0
        public void RepeatedRestartsShouldNotCauseInfiniteLoop()
        {
            // Arrange
            var tileProvider     = new CountingTileProvider();
            var tileSchema       = new GlobalSphericalMercator();
            var tileSource       = new TileSource(tileProvider, tileSchema);
            var cache            = new MemoryCache <Feature>();
            var fetchDispatcher  = new TileFetchDispatcher(cache, tileSource.Schema, (tileInfo) => TileToFeature(tileSource, tileInfo));
            var tileMachine      = new FetchMachine(fetchDispatcher);
            var numberOfWorkers  = 8;
            var numberOfRestarts = 3;

            // Act
            for (int i = 0; i < numberOfRestarts; i++)
            {
                fetchDispatcher.SetViewport(tileSchema.Extent.ToBoundingBox(), tileSchema.Resolutions[3].UnitsPerPixel);
                tileMachine.Start();
                while (fetchDispatcher.Busy)
                {
                }
            }

            // Assert
            Assert.Greater(numberOfWorkers * numberOfRestarts, FetchWorker.RestartCounter);
        }
Exemplo n.º 4
0
        public void TileFetcherWithFailingFetchesShouldTryAgain()
        {
            // Arrange
            var tileProvider = new FailingTileProvider();
            var tileSchema   = new GlobalSphericalMercator();
            var tileSource   = new TileSource(tileProvider, tileSchema);

            using var cache = new MemoryCache <IFeature?>();
            var fetchDispatcher = new TileFetchDispatcher(cache, tileSource.Schema, async tileInfo => await TileToFeatureAsync(tileSource, tileInfo));
            var tileMachine     = new FetchMachine(fetchDispatcher);
            var level           = 3;
            var tilesInLevel    = 64;
            var fetchInfo       = new FetchInfo(tileSchema.Extent.ToMRect(), tileSchema.Resolutions[level].UnitsPerPixel);

            // Act
            fetchDispatcher.SetViewport(fetchInfo);
            tileMachine.Start();
            while (fetchDispatcher.Busy)
            {
                Thread.Sleep(1);
            }

            // Act again
            fetchDispatcher.SetViewport(fetchInfo);
            tileMachine.Start();
            while (fetchDispatcher.Busy)
            {
                Thread.Sleep(1);
            }

            // Assert
            Assert.AreEqual(tilesInLevel * 2, tileProvider.TotalCount); // tried all tiles twice
        }
Exemplo n.º 5
0
        public void RepeatedRestartsShouldNotCauseInfiniteLoop()
        {
            // Arrange
            var tileProvider = new CountingTileProvider();
            var tileSchema   = new GlobalSphericalMercator();
            var tileSource   = new TileSource(tileProvider, tileSchema);

            using var cache = new MemoryCache <IFeature?>();
            var fetchDispatcher  = new TileFetchDispatcher(cache, tileSource.Schema, async tileInfo => await TileToFeatureAsync(tileSource, tileInfo));
            var tileMachine      = new FetchMachine(fetchDispatcher);
            var numberOfWorkers  = 8;
            var numberOfRestarts = 3;
            var fetchInfo        = new FetchInfo(tileSchema.Extent.ToMRect(), tileSchema.Resolutions[3].UnitsPerPixel);

            // Act
            for (var i = 0; i < numberOfRestarts; i++)
            {
                fetchDispatcher.SetViewport(fetchInfo);
                tileMachine.Start();
                while (fetchDispatcher.Busy)
                {
                    Thread.Sleep(1);
                }
            }

            // Assert
            Assert.Greater(numberOfWorkers * numberOfRestarts, FetchWorker.RestartCounter);
        }
Exemplo n.º 6
0
        public void InitializeFromTileSource_ValidTileSource_InitializeConfiguration()
        {
            // Setup
            var mocks        = new MockRepository();
            var tileProvider = mocks.Stub <ITileProvider>();
            var tileSchema   = mocks.Stub <ITileSchema>();

            mocks.ReplayAll();

            string rootPath = TestHelper.GetScratchPadPath("InitializeFromTileSource_ValidTileSource_InitializeConfiguration");

            DoAndCleanupAfter(
                () =>
            {
                using (var configuration = new SimplePersistentCacheConfiguration(rootPath))
                {
                    var tileSource = new TileSource(tileProvider, tileSchema);

                    // Call
                    configuration.TestInitializeFromTileSource(tileSource);

                    // Assert
                    Assert.AreSame(tileSource.Schema, configuration.TileSchema);
                    Assert.IsInstanceOf <AsyncTileFetcher>(configuration.TileFetcher);
                    Assert.IsTrue(configuration.Initialized);
                }
            },
                rootPath);

            mocks.VerifyAll();
        }
Exemplo n.º 7
0
        public void TileFetcherShouldBehaveProperlyWithNoisyResponses()
        {
            // Arrange
            var schema      = new GlobalSphericalMercator();
            var tileSource  = new TileSource(new SometimesFailingTileProvider(), schema);
            var memoryCache = new MemoryCache <Feature>(14, 17);
            var tileFetcher = new TileFetcher(tileSource, memoryCache);
            var random      = new Random(31747074);
            var tiles       = new List <Feature>();

            // Act
            for (int i = 0; i < 100; i++)
            {
                var randomLevel   = "5";
                var randomCol     = random.Next(schema.GetMatrixWidth(randomLevel));
                var randomRow     = random.Next(schema.GetMatrixHeight(randomLevel));
                var tileRange     = new TileRange(randomCol - 2, randomRow - 2, 5, 5);
                var unitsPerPixel = schema.Resolutions[randomLevel].UnitsPerPixel;
                var extent        = TileTransform.TileToWorld(tileRange, randomLevel, schema);
                tileFetcher.ViewChanged(TileTransform.TileToWorld(tileRange, randomLevel, schema).ToBoundingBox(), unitsPerPixel);
                var tileInfos = schema.GetTileInfos(extent, randomLevel);
                foreach (var tileInfo in tileInfos)
                {
                    tiles.Add(memoryCache.Find(tileInfo.Index));
                }
            }

            // Assert
            Assert.True(tiles.Count > 0);
            Assert.True(memoryCache.TileCount == 0);
        }
Exemplo n.º 8
0
        void GetWeatherData()
        {
            TileSource tSource = new TileSource();

            int MapWidth  = (int)myMap.ActualWidth;
            int MapHeight = (int)myMap.ActualHeight;

            string north = myMap.BoundingRectangle.North.ToString().Substring(0, 6);
            string east  = myMap.BoundingRectangle.East.ToString().Substring(0, 6);
            string south = myMap.BoundingRectangle.South.ToString().Substring(0, 6);
            string west  = myMap.BoundingRectangle.West.ToString().Substring(0, 6);

            string UriString = "{UriScheme}://nowcoast.noaa.gov/wms/com.esri.wms.Esrimap/obs?service=wms&version=1.1.1&request=GetMap&";
            string format    = "format=png&";

            string BBox = "BBOX=" + west + "," + south + "," + east + "," + north;

            string SRS         = "&SRS=EPSG:4269&";
            string WidthHeight = "width=" + MapWidth.ToString() + "&height=" + MapHeight.ToString() + "&";
            string Transparent = "transparent=true&";
            string Layers      = "Layers=world_countries,RAS_RIDGE_NEXRAD";

            // string Layers = "Layers=world_countries,RAS_GOES,RAS_RIDGE_NEXRAD";

            tSource.UriFormat = UriString + format + BBox + SRS + WidthHeight + Transparent + Layers;

            tileLayer.TileSource = tSource;

            tileLayer.Opacity = 0.7;
        }
Exemplo n.º 9
0
        [Test] // handing in build server but not on client
        public void TileFetcherShouldBehaveProperlyWithTileProviderReturningNull()
        {
            // Arrange
            var schema      = new GlobalSphericalMercator();
            var tileSource  = new TileSource(new NullTileProvider(), schema);
            var memoryCache = new MemoryCache <Feature>();
            var tileFetcher = new TileFetcher(tileSource, memoryCache);

            // Act
            Task.Run(() =>
            {
                Task.Delay(5000);
                if (tileFetcher.Busy)
                {
                    Assert.Fail("The fetcher hangs");
                }
            });
            tileFetcher.ViewChanged(schema.Extent.ToBoundingBox(), schema.Resolutions["2"].UnitsPerPixel);
            while (tileFetcher.Busy)
            {
            }

            // Assert
            Assert.True(memoryCache.TileCount == 0);
        }
Exemplo n.º 10
0
        public BruTileCustomLayer(IApplication application, TileSource tileSource, FileCache fileCache)
        {
            _tileSource        = tileSource;
            _fileCache         = fileCache;
            _simplefilefetcher = new SimpleFileFetcher(tileSource, fileCache);
            var spatialReferences = new SpatialReferences();

            _dataSpatialReference = spatialReferences.GetSpatialReference(_tileSource.Schema.Srs);

            if (SpatialReference.FactoryCode == 0)
            {
                // zet dan de spatial ref...
                m_spatialRef = _dataSpatialReference;
            }
            var mxdoc = (IMxDocument)application.Document;

            _map = mxdoc.FocusMap;
            var envelope = GetDefaultEnvelope();

            // If there is only one layer in the TOC zoom to this layer...
            if (_map.LayerCount == 0)
            {
                ((IActiveView)_map).Extent = envelope;
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Method to extract all image layers from a wmts capabilities document.
        /// </summary>
        /// <param name="capabilties">The capabilities document</param>
        /// <param name="tileSchemas">A set of</param>
        /// <returns></returns>
        private static IEnumerable <ITileSource> GetLayers(Capabilities capabilties, List <ITileSchema> tileSchemas)
        {
            var tileSources = new List <ITileSource>();

            foreach (var layer in capabilties.Contents.Layers)
            {
                var    identifier = layer.Identifier.Value;
                var    title      = layer.Title[0].Value;
                string @abstract  = layer.Abstract != null ? layer.Abstract[0].Value : string.Empty;

                foreach (var tileMatrixLink in layer.TileMatrixSetLink)
                {
                    foreach (var style in layer.Style)
                    {
                        foreach (var format in layer.Format)
                        {
                            if (!format.StartsWith("image/"))
                            {
                                continue;
                            }

                            IRequest wmtsRequest;

                            if (layer.ResourceURL == null)
                            {
                                wmtsRequest = new WmtsRequest(CreateResourceUrlsFromOperations(
                                                                  capabilties.OperationsMetadata.Operation,
                                                                  format,
                                                                  capabilties.ServiceIdentification.ServiceTypeVersion.First(),
                                                                  layer.Identifier.Value,
                                                                  style.Identifier.Value,
                                                                  tileMatrixLink.TileMatrixSet));
                            }
                            else
                            {
                                wmtsRequest = new WmtsRequest(CreateResourceUrlsFromResourceUrlNode(
                                                                  layer.ResourceURL,
                                                                  style.Identifier.Value,
                                                                  tileMatrixLink.TileMatrixSet));
                            }

                            var tileMatrixSet = tileMatrixLink.TileMatrixSet;
                            var tileSchema    = (WmtsTileSchema)tileSchemas.First(s => Equals(s.Name, tileMatrixSet));

                            //var layerName = layer.Identifier.Value;
                            var styleName = style.Identifier.Value;

                            var tileSource = new TileSource(new HttpTileProvider(wmtsRequest),
                                                            tileSchema.CreateSpecific(title, identifier, @abstract, tileMatrixSet, styleName, format))
                            {
                                Name = title
                            };

                            tileSources.Add(tileSource);
                        }
                    }
                }
            }
            return(tileSources);
        }
Exemplo n.º 12
0
        public void TileFetcherWithReturningNull()
        {
            // Arrange
            var tileProvider = new NullTileProvider();
            var tileSchema   = new GlobalSphericalMercator();
            var tileSource   = new TileSource(tileProvider, tileSchema);
            var tileFetcher  = new TileFetcher(tileSource, new MemoryCache <Feature>());

            // Act
            for (int i = 0; i < 300; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    tileFetcher.ViewChanged(tileSchema.Extent.ToBoundingBox(), tileSchema.Resolutions[j.ToString()].UnitsPerPixel);
                    System.Threading.Thread.Sleep(10);
                }
            }

            // Assert
            while (tileFetcher.Busy)
            {
            }

            Assert.Pass("The fetcher did not go into an infinite loop");
        }
Exemplo n.º 13
0
        public void InitializeFromTileSource_ConfigurationDisposed_ThrowObjectDisposedException()
        {
            // Setup
            var mocks        = new MockRepository();
            var tileProvider = mocks.Stub <ITileProvider>();
            var tileSchema   = mocks.Stub <ITileSchema>();

            mocks.ReplayAll();

            string rootPath = TestHelper.GetScratchPadPath("InitializeFromTileSource_ConfigurationDisposed_ThrownObjectDisposedException");

            var configuration = new SimplePersistentCacheConfiguration(rootPath);

            configuration.Dispose();

            var tileSource = new TileSource(tileProvider, tileSchema);

            DoAndCleanupAfter(
                () =>
            {
                // Call
                void Call() => configuration.TestInitializeFromTileSource(tileSource);

                // Assert
                string objectName = Assert.Throws <ObjectDisposedException>(Call).ObjectName;
                Assert.AreEqual("SimplePersistentCacheConfiguration", objectName);
            },
                rootPath);

            mocks.VerifyAll();
        }
Exemplo n.º 14
0
        public void TestInitializeFromTileSource_CreationOfDirectoryNotAllowed_ThrowCannotCreateTileCacheException()
        {
            // Setup
            var mocks        = new MockRepository();
            var tileProvider = mocks.Stub <ITileProvider>();
            var tileSchema   = mocks.Stub <ITileSchema>();

            mocks.ReplayAll();

            var tileSource = new TileSource(tileProvider, tileSchema);

            string rootPath = TestHelper.GetScratchPadPath("TestInitializeFromTileSource_CreationOfDirectoryNotAllowed_ThrowCannotCreateTileCacheException");

            DoAndCleanupAfter(
                () =>
            {
                using (var configuration = new SimplePersistentCacheConfiguration(rootPath))
                    using (new DirectoryPermissionsRevoker(TestHelper.GetScratchPadPath(), FileSystemRights.Write))
                    {
                        // Call
                        void Call() => configuration.TestInitializeFromTileSource(tileSource);

                        // Assert
                        const string expectedMessage = "Een kritieke fout is opgetreden bij het aanmaken van de cache.";
                        string message = Assert.Throws <CannotCreateTileCacheException>(Call).Message;
                        Assert.AreEqual(message, expectedMessage);
                    }
            },
                rootPath);
        }
Exemplo n.º 15
0
        public void TileRequestThatReturnsNullShouldNotBeRequestedAgain()
        {
            // Arrange
            var tileProvider    = new NullTileProvider();
            var tileSchema      = new GlobalSphericalMercator();
            var tileSource      = new TileSource(tileProvider, tileSchema);
            var cache           = new MemoryCache <Feature>();
            var fetchDispatcher = new TileFetchDispatcher(cache, tileSource.Schema, (tileInfo) => TileToFeature(tileSource, tileInfo));
            var tileMachine     = new FetchMachine(fetchDispatcher);
            var level           = 3;
            var tilesInLevel    = 64;

            // Act
            fetchDispatcher.SetViewport(tileSchema.Extent.ToBoundingBox(), tileSchema.Resolutions[level].UnitsPerPixel);
            tileMachine.Start();
            while (fetchDispatcher.Busy)
            {
            }
            // do it again
            fetchDispatcher.SetViewport(tileSchema.Extent.ToBoundingBox(), tileSchema.Resolutions[level].UnitsPerPixel);
            tileMachine.Start();
            while (fetchDispatcher.Busy)
            {
                Thread.Sleep(1);
            }

            // Assert
            Assert.AreEqual(tilesInLevel, tileProvider.TotalCount);
        }
Exemplo n.º 16
0
        public void TileFetcherWithFailingFetchesShouldTryAgain()
        {
            // Arrange
            var tileProvider    = new FailingTileProvider();
            var tileSchema      = new GlobalSphericalMercator();
            var tileSource      = new TileSource(tileProvider, tileSchema);
            var cache           = new MemoryCache <Feature>();
            var fetchDispatcher = new TileFetchDispatcher(cache, tileSource.Schema, (tileInfo) => TileToFeature(tileSource, tileInfo));
            var tileMachine     = new FetchMachine(fetchDispatcher);
            var level           = 3;
            var tilesInLevel    = 64;

            // Act
            fetchDispatcher.SetViewport(tileSchema.Extent.ToBoundingBox(), tileSchema.Resolutions[level].UnitsPerPixel);
            tileMachine.Start();
            while (fetchDispatcher.Busy)
            {
            }
            // do it again
            fetchDispatcher.SetViewport(tileSchema.Extent.ToBoundingBox(), tileSchema.Resolutions[level].UnitsPerPixel);
            tileMachine.Start();
            while (fetchDispatcher.Busy)
            {
            }

            // Assert
            Assert.AreEqual(tilesInLevel * 2, tileProvider.TotalCount); // tried all tiles twice
        }
Exemplo n.º 17
0
        public static byte[] GetTile(string layer, string level, int col, int row)
        {
            var tileServer = (KnownTileServers)Enum.Parse(typeof(KnownTileServers), layer, true);
            var tilesource = TileSource.Create(tileServer);

            return(GetTile(tilesource, level, col, row));
        }
Exemplo n.º 18
0
        public async Task <TileSource> CreateTileSource(TileSource tileSource)
        {
            await Context.TileSources.AddAsync(tileSource);

            await Context.SaveChangesAsync();

            return(tileSource);
        }
Exemplo n.º 19
0
        public ITileSource CreateTileSource()
        {
            var tilesource = new TileSource(
                new WebTileProvider(new BasicRequest(Url)),
                new GlobalSphericalMercator(Format, true, 1, 19, "giscloud"));

            return(tilesource);
        }
Exemplo n.º 20
0
        public async Task <IActionResult> Post([FromBody] CreateTileSourceViewModel viewModel)
        {
            TileSource tileSource = await TileSourceRepository.CreateTileSource(Mapper.Map <TileSource>(viewModel));

            return(CreatedAtAction(nameof(Get), new
            {
                tileSourceId = tileSource.TileSourceId,
            }, Mapper.Map <TileSourceViewModel>(tileSource)));
        }
Exemplo n.º 21
0
        public ITileSource CreateTileSource()
        {
            var tileSchema       = new GlobalSphericalMercator();
            var tileLayerRequest = new BasicRequest(_url, Domains);
            var tileProvider     = new WebTileProvider(tileLayerRequest);
            var tileSource       = new TileSource(tileProvider, tileSchema);

            return(tileSource);
        }
Exemplo n.º 22
0
        public async Task <IActionResult> Get(Guid tileSourceId)
        {
            TileSource tileSource = await TileSourceRepository.GetTileSourceWithId(tileSourceId);

            if (tileSource == null)
            {
                return(NotFound());
            }

            return(Ok(Mapper.Map <TileSourceViewModel>(tileSource)));
        }
Exemplo n.º 23
0
        public ITileSource CreateTileSource()
        {
            var tileSchema  = new DaumTileSchema();
            var daumRequest = new DaumRequest(Url, new List <string> {
                "0", "1", "2", "3"
            });
            var tileProvider = new WebTileProvider(daumRequest);
            var tileSource   = new TileSource(tileProvider, tileSchema);

            return(tileSource);
        }
Exemplo n.º 24
0
        public ITileSource CreateTileSource()
        {
            ITileSource result = null;

            if (_osmMapType == OsmMapType.Default)
            {
                result = new TileSource();
            }

            return(result);
        }
Exemplo n.º 25
0
        public ITileSource CreateTileSource()
        {
            var tileSchema = new BaiduTileSchema();
            var servers    = new List <string> {
                "1", "2", "3", "4", "5", "6", "7", "8", "9"
            };
            var baiduRequest = new BasicRequest(Url, servers);
            var tileProvider = new HttpTileProvider(baiduRequest);
            var tileSource   = new TileSource(tileProvider, tileSchema);

            return(tileSource);
        }
Exemplo n.º 26
0
        public ITileSource CreateTileSource()
        {
            var tileSchema = new NaverTileSchema();
            var servers    = new List <string> {
                "onetile1", "onetile2", "onetile3", "onetile4"
            };
            var naverRequest = new BasicRequest(Url, servers);
            var tileProvider = new WebTileProvider(naverRequest);
            var tileSource   = new TileSource(tileProvider, tileSchema);

            return(tileSource);
        }
Exemplo n.º 27
0
        public ITileSource CreateTileSource()
        {
            var tileSchema = new GlobalSphericalMercator();
            var servers    = new List <string> {
                "01", "02", "03", "04"
            };
            var yandexRequest = new BasicRequest(_url, servers);
            var tileProvider  = new WebTileProvider(yandexRequest);
            var tileSource    = new TileSource(tileProvider, tileSchema);

            return(tileSource);
        }
        public Task <BackgroundLayerSet> GetKWater()
        {
            var baseUrl = "http://kommap.kwater.or.kr/arcgis/rest/services/public/BaseMap_2018/MapServer";
            var schema  = new TileSchema
            {
                OriginX = -5423200,
                OriginY = 6294600,
                Format  = "image/jpgpng",
                YAxis   = YAxis.OSM,
                Srs     = "EPSG:5181",
                Extent  = new Extent(-956717.4541277827, -341633.6944546023, 1690051.884713592, 1587544.6432406649)
            };

            schema.Resolutions["0"]  = new Resolution(id:  "0", unitsPerPixel:   926.0435187537042, scaledenominator: 3500000);
            schema.Resolutions["1"]  = new Resolution(id:  "1", unitsPerPixel:   529.1677250021168, scaledenominator: 2000000);
            schema.Resolutions["2"]  = new Resolution(id:  "2", unitsPerPixel:   264.5838625010584, scaledenominator: 1000000);
            schema.Resolutions["3"]  = new Resolution(id:  "3", unitsPerPixel:   132.2919312505292, scaledenominator:  500000);
            schema.Resolutions["4"]  = new Resolution(id:  "4", unitsPerPixel:    66.1459656252646, scaledenominator:  250000);
            schema.Resolutions["5"]  = new Resolution(id:  "5", unitsPerPixel:    33.0729828126323, scaledenominator:  125000);
            schema.Resolutions["6"]  = new Resolution(id:  "6", unitsPerPixel:    16.933367200067735, scaledenominator:   64000);
            schema.Resolutions["7"]  = new Resolution(id:  "7", unitsPerPixel:     8.466683600033868, scaledenominator:   32000);
            schema.Resolutions["8"]  = new Resolution(id:  "8", unitsPerPixel:     4.233341800016934, scaledenominator:   16000);
            schema.Resolutions["9"]  = new Resolution(id:  "9", unitsPerPixel:     2.116670900008467, scaledenominator:    8000);
            schema.Resolutions["10"] = new Resolution(id: "10", unitsPerPixel:     1.0583354500042335, scaledenominator:    4000);
            schema.Resolutions["11"] = new Resolution(id: "11", unitsPerPixel:     0.5291677250021167, scaledenominator:    2000);
            schema.Resolutions["12"] = new Resolution(id: "12", unitsPerPixel:     0.26458386250105836, scaledenominator:    1000);
            schema.Resolutions["13"] = new Resolution(id: "13", unitsPerPixel:     0.13229193125052918, scaledenominator:     500);
            schema.Resolutions["14"] = new Resolution(id: "14", unitsPerPixel:     0.06614596562526459, scaledenominator:     250);
            schema.Resolutions["15"] = new Resolution(id: "15", unitsPerPixel:     0.033072982812632296, scaledenominator:     125);
            schema.Resolutions["16"] = new Resolution(id: "16", unitsPerPixel:     0.016668783337566676, scaledenominator:      63);
            schema.Resolutions["17"] = new Resolution(id: "17", unitsPerPixel:     0.008466683600033867, scaledenominator:      32);
            schema.Resolutions["18"] = new Resolution(id: "18", unitsPerPixel:     0.004233341800016934, scaledenominator:      16);
            schema.Resolutions["19"] = new Resolution(id: "19", unitsPerPixel:     0.002116670900008467, scaledenominator:       8);
            schema.Resolutions["20"] = new Resolution(id: "20", unitsPerPixel:     0.0010583354500042334, scaledenominator:       4);
            schema.Resolutions["21"] = new Resolution(id: "21", unitsPerPixel:     0.000529167725002116, scaledenominator:       2);

            var request    = new BasicRequest($"{baseUrl}/tile/{"{0}/{2}/{1}"}");
            var provider   = new HttpTileProvider(request, null, null);
            var tileSource = new TileSource(provider, schema);

            //var set        = new BackgroundLayerSet(new [] { new BackgroundLayer(tileSource, "일반", order: 0) });
            var set = new BackgroundLayerSet(new[] { new BackgroundLayer(tileSource, null)
                                                     {
                                                         LegendText = "일반"
                                                     } })
            {
                "없음",
                { "일반", "일반" }
            };

            return(Task.FromResult(set));
        }
Exemplo n.º 29
0
        public MainWindow()
        {
            InitializeComponent();

            foreach (var layer in  Enum.GetValues(typeof(KnownTileServers)).Cast <KnownTileServers>())
            {
                var radioButton = new RadioButton {
                    Content = layer.ToString(), Tag = layer
                };
                radioButton.Click += (sender, args) => MapControl.SetTileSource(TileSource.Create((KnownTileServers)((RadioButton)sender).Tag));
                Layers.Children.Add(radioButton);
            }
        }
Exemplo n.º 30
0
 public void LoadMap(int mapid)
 {
     if (mapid == 0)
     {
         tileSource = new TileSource(new FileTileProvider(new FileCache(appdir + "\\maps\\Erangel", "png")), new TileSchema(mapid));
     }
     else if (mapid == 1)
     {
         tileSource = new TileSource(new FileTileProvider(new FileCache(appdir + "\\maps\\Miramar", "png")), new TileSchema(mapid));
     }
     map.RootLayer = new TileLayer(tileSource);
     InitializeTransform(tileSource.Schema);
 }
Exemplo n.º 31
0
 /// <summary>
 /// Provides derived classes an opportunity to handle changes to the Source property.
 /// </summary>
 protected virtual void OnSourceChanged(TileSource oldValue, TileSource newValue)
 {
     if (oldValue != null && newValue != null)
     {
         var oldpos = this.getCurrentPosition();
         var oldzoom = this.CurrentZoom;
         this.TileLayer.TileSources.Clear();
         this.TileLayer.TileSources.Add(newValue);
         this.navigateToCoordinate(oldpos, oldzoom);
     }
     else
     {
         this.TileLayer.TileSources.Clear();
         this.TileLayer.TileSources.Add(newValue);
     }
 }
Exemplo n.º 32
0
 // Called when TileSource is set
 public static void SetTileSource(DependencyObject obj, TileSource value)
 {
     obj.SetValue(TileSourceProperty, value);
 }
        void GetWeatherData()
        {
            TileSource tSource = new TileSource();

            int MapWidth = (int)myMap.ActualWidth;
            int MapHeight =(int) myMap.ActualHeight;

            string north = myMap.BoundingRectangle.North.ToString().Substring(0,6);
            string east = myMap.BoundingRectangle.East.ToString().Substring(0, 6);
            string south = myMap.BoundingRectangle.South.ToString().Substring(0, 6);
            string west = myMap.BoundingRectangle.West.ToString().Substring(0, 6);

            string UriString = "{UriScheme}://nowcoast.noaa.gov/wms/com.esri.wms.Esrimap/obs?service=wms&version=1.1.1&request=GetMap&";
            string format = "format=png&";

            string BBox = "BBOX=" + west+ "," + south + "," + east + "," + north;

            string SRS = "&SRS=EPSG:4269&";
            string WidthHeight = "width="+MapWidth.ToString()+"&height="+MapHeight.ToString()+"&";
            string Transparent = "transparent=true&";
            string Layers = "Layers=world_countries,RAS_RIDGE_NEXRAD";
               // string Layers = "Layers=world_countries,RAS_GOES,RAS_RIDGE_NEXRAD";

            tSource.UriFormat = UriString + format + BBox + SRS + WidthHeight + Transparent + Layers;

            tileLayer.TileSource = tSource;

            tileLayer.Opacity = 0.7;
        }
Exemplo n.º 34
0
        /// <summary>
        /// Method to extract all image layers from a wmts capabilities document.
        /// </summary>
        /// <param name="capabilties">The capabilities document</param>
        /// <param name="tileSchemas">A set of</param>
        /// <returns></returns>
        private static IEnumerable<ITileSource> GetLayers(Capabilities capabilties, List<ITileSchema> tileSchemas)
        {
            var tileSources = new List<ITileSource>();

            foreach (var layer in capabilties.Contents.Layers)
            {
                var identifier = layer.Identifier.Value;
                var title = layer.Title[0].Value;
                string @abstract = layer.Abstract != null ? layer.Abstract[0].Value : string.Empty;

                foreach (var tileMatrixLink in layer.TileMatrixSetLink)
                {
                    foreach (var style in layer.Style)
                    {
                        foreach (var format in layer.Format)
                        {
                            if (!format.StartsWith("image/")) continue;

                            IRequest wmtsRequest;

                            if (layer.ResourceURL == null)
                            {
                                wmtsRequest = new WmtsRequest(CreateResourceUrlsFromOperations(
                                    capabilties.OperationsMetadata.Operation,
                                    format,
                                    capabilties.ServiceIdentification.ServiceTypeVersion.First(),
                                    layer.Identifier.Value,
                                    style.Identifier.Value,
                                    tileMatrixLink.TileMatrixSet));
                            }
                            else
                            {
                                wmtsRequest = new WmtsRequest(CreateResourceUrlsFromResourceUrlNode(
                                    layer.ResourceURL,
                                    style.Identifier.Value,
                                    tileMatrixLink.TileMatrixSet));
                            }

                            var tileMatrixSet = tileMatrixLink.TileMatrixSet;
                            var tileSchema = (WmtsTileSchema)tileSchemas.First(s => Equals(s.Name, tileMatrixSet));

                            //var layerName = layer.Identifier.Value;
                            var styleName = style.Identifier.Value;

                            var tileSource = new TileSource(new HttpTileProvider(wmtsRequest),
                                tileSchema.CreateSpecific(title, identifier, @abstract, tileMatrixSet, styleName, format))
                                {
                                    Name = title
                                };

                            tileSources.Add(tileSource);
                        }
                    }
                }
            }
            return tileSources;
        }
Exemplo n.º 35
0
        private void AddTileOverlay()
        {
            // Create a new map layer to add the tile overlay to.
            tileLayer = new MapTileLayer();

            // The source of the overlay.
            TileSource tileSource = new TileSource();
            tileSource.UriFormat = "{UriScheme}://ecn.t0.tiles.virtualearth.net/tiles/r{quadkey}.jpeg?g=129&mkt=en-us&shading=hill&stl=H";

            // Add the tile overlay to the map layer
            tileLayer.TileSource = tileSource;

            // Add the map layer to the map
            if (!MapTileOverlay.Children.Contains(tileLayer))
            {
                MapTileOverlay.Children.Add(tileLayer);
            }
            tileLayer.Opacity = tileOpacity;
        }
Exemplo n.º 36
0
 public CustomMapTileLayer()
 {
     baseTileSource = new TileSource();
 }