コード例 #1
0
        public void TestHttpTileProvider()
        {
            var srcS = new HttpTileProvider(new BasicRequest("http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png", new [] { "a", "b" }), userAgent: "HUHU");
            var srcD = SandD(srcS);

            Assert.IsNotNull(srcD);
        }
コード例 #2
0
        public MapBoxVectorTileSource(string url, string ext = "pbf")
        {
            var request = new TmsRequest(new Uri(url), ext);

            Provider = new HttpTileProvider(request, fetchTile: FetchTile);
            Schema   = new GlobalSphericalMercator();
        }
コード例 #3
0
        public static ITileSource CreateTileSource(string urlString, string layerName, string CRS)
        {
            var schema = new GlobalSphericalMercator("png", YAxis.OSM, 0, 21, null);
            var layers = new List <string>();

            layers.Add(layerName);
            var styles = new List <string>();

            if (!urlString.ToLower().Contains("&version="))
            {
                urlString = urlString + "&version=1.3.0";
            }
            if (!urlString.ToLower().Contains("&crs="))
            {
                urlString = urlString + "&CRS=" + CRS;
            }
            if (!urlString.ToLower().Contains("&format="))
            {
                urlString = urlString + "&format=png";
            }
            if (!urlString.ToLower().Contains("&transparent="))
            {
                urlString = urlString + "&transparent=true";
            }
            var request  = new WmscRequest(new Uri(urlString), schema, layers, new string[0].ToList());
            var provider = new HttpTileProvider(request);

            return(new TileSource(provider, schema));
        }
コード例 #4
0
ファイル: TileLayerConfig.cs プロジェクト: jjgas/ArcBruTile
        public ITileSource CreateTileSource()
        {
            var tileSchema       = new GlobalSphericalMercator();
            var tileLayerRequest = new BasicRequest(_url, Domains);
            var tileProvider     = new HttpTileProvider(tileLayerRequest);
            var tileSource       = new TileSource(tileProvider, tileSchema);

            return(tileSource);
        }
コード例 #5
0
        public GeodanWorldWmsTileSource()
        {
            var schema = new GlobalSphericalMercator(YAxis.TMS)
            {
                Srs = "EPSG:900913"
            };

            Provider = new HttpTileProvider(CreateWmsRequest(schema));
            Schema   = schema;
        }
コード例 #6
0
ファイル: TiledWmsSample.cs プロジェクト: xivk/Mapsui
        public GeodanWorldWmsTileSource()
        {
            var schema = new WkstNederlandSchema
            {
                Srs    = "EPSG:28992",
                Format = "image/png"
            };

            Provider = new HttpTileProvider(CreateWmsRequest(schema));
            Schema   = schema;
        }
コード例 #7
0
        internal static T ReflectRequest <T>(HttpTileProvider provider) where T : IRequest
        {
            var fi = typeof(HttpTileProvider).GetField("_request", BindingFlags.Instance | BindingFlags.NonPublic);

            if (fi == null)
            {
                throw new ArgumentException("Provider does not have a private field '_request'", "provider");
            }

            return((T)fi.GetValue(provider));
        }
コード例 #8
0
        public ITileSource CreateTileSource()
        {
            var tileSchema  = new DaumTileSchema();
            var daumRequest = new DaumRequest(Url, new List <string> {
                "0", "1", "2", "3"
            });
            var tileProvider = new HttpTileProvider(daumRequest);
            var tileSource   = new TileSource(tileProvider, tileSchema);

            return(tileSource);
        }
コード例 #9
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 HttpTileProvider(naverRequest);
            var tileSource   = new TileSource(tileProvider, tileSchema);

            return(tileSource);
        }
コード例 #10
0
        public static ITileSource Create()
        {
            const string url = "http://geodata.nationaalgeoregister.nl/omgevingswarmte/wms?SERVICE=WMS&VERSION=1.1.1";
            // You need to know the schema. This can be a problem. Usally it is GlobalSphericalMercator
            var schema = new WkstNederlandSchema {
                Format = "image/png"
            };
            var request  = new WmscRequest(new Uri(url), schema, new[] { "koudegeslotenwkobuurt" }.ToList(), new string[0].ToList());
            var provider = new HttpTileProvider(request);

            return(new TileSource(provider, schema));
        }
コード例 #11
0
ファイル: BaiduConfig.cs プロジェクト: jjgas/ArcBruTile
        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);
        }
コード例 #12
0
        public static ITileSource Create()
        {
            const string url = "http://geodata.nationaalgeoregister.nl/ahn25m/wms?service=wms";
            // You need to know the schema. This can be a problem. Usally it is GlobalSphericalMercator
            var schema = new WkstNederlandSchema {
                Format = "image/png"
            };
            var request  = new WmscRequest(new Uri(url), schema, new[] { "ahn25m" }.ToList(), new string[0].ToList());
            var provider = new HttpTileProvider(request);

            return(new TileSource(provider, schema));
        }
コード例 #13
0
        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));
        }
コード例 #14
0
            public HttpTileProviderRef(SerializationInfo info, StreamingContext context)
            {
                var type    = (Type)info.GetValue("_requestType", typeof(Type));
                var request = (IRequest)info.GetValue("_request", type);

                type = (Type)info.GetValue("_fetchTileType", typeof(Type));
                var fetchTile = (Func <Uri, byte[]>)info.GetValue("_fetchTile", type);

                type = (Type)info.GetValue("_persistentCacheType", typeof(Type));
                var persistentCache = (IPersistentCache <byte[]>)info.GetValue("_persistentCache", type);

                _httpTileProvider = new HttpTileProvider(request, persistentCache, fetchTile);
            }
コード例 #15
0
        public Task <BackgroundLayerSet> GetKWaterMapLayers()
        {
            var baseUrl = "http://kommap.kwater.or.kr/arcgis/rest/services/public/BaseMap_2018/MapServer";
            //var capabilitiesUrl = "http://kommap.kwater.or.kr/arcgis/rest/services/public/BaseMap_2018/MapServer/WMTS/1.0.0/WMTSCapabilities.xml";
            //var svrSource       = await GetTileSourcesFromCapabilities(new Uri(capabilitiesUrl));
            //var svrSchema       = svrSource.FirstOrDefault().Schema;

            var schema = new TileSchema();

            schema.OriginX = -5423200;
            schema.OriginY = 6294600;
            schema.Format  = "image/jpgpng";
            schema.YAxis   = YAxis.OSM;
            schema.Srs     = "EPSG:5181";
            schema.Extent  = new Extent(-956717.4541277827, -341633.6944546023, 1690051.884713592, 1587544.6432406649);
            //foreach (var r in svrSchema.Resolutions)
            //    schema.Resolutions[r.Key] = r.Value;
            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) });

            set.Add("없음");
            set.Add("일반", "일반");
            return(Task.FromResult(set));
        }
コード例 #16
0
        /// <summary>
        /// Method called prior to any tile access
        /// </summary>
        public void Initialize()
        {
            if (_initialized)
            {
                return;
            }
            _initialized = true;

            var schema  = RestoreSchema();
            var request = new WmscRequest(new Uri(_url), schema, _layers, _styles, _customParameters, _version);

            ITileProvider provider = new HttpTileProvider(request);

            TileSource   = (WmscTileSource)Activator.CreateInstance(typeof(WmscTileSource), BindingFlags.NonPublic, schema, provider);
            TileCache    = CreateTileCache();
            _tileFetcher = new TileFetcher(provider,
                                           BruTileLayerPlugin.Settings.MemoryCacheMinimum,
                                           BruTileLayerPlugin.Settings.MemoryCacheMaximum,
                                           TileCache);
        }
コード例 #17
0
ファイル: TileMapParser.cs プロジェクト: zjwgis721/BruTile
        public static TileSource CreateTileSource(Stream tileMapResource, string overrideUrl   = null,
                                                  Dictionary <string, string> customParameters = null, IPersistentCache <byte[]> persistentCache = null,
                                                  Func <Uri, byte[]> fetchTile = null)
        {
            var reader     = new StreamReader(tileMapResource);
            var serializer = new XmlSerializer(typeof(TileMap));
            var tileMap    = (TileMap)serializer.Deserialize(reader);
            var tileSchema = CreateSchema(tileMap);

            var tileUrls = new Dictionary <string, Uri>();

            foreach (TileMapTileSetsTileSet ts in tileMap.TileSets.TileSet)
            {
                tileUrls[ts.order] = new Uri(ts.href);
            }
            var tileProvider = new HttpTileProvider(CreateRequest(tileUrls, tileSchema.Format, overrideUrl, customParameters),
                                                    persistentCache, fetchTile);

            return(new TileSource(tileProvider, tileSchema));
        }
コード例 #18
0
ファイル: BruTileTester.cs プロジェクト: tabinfl/Inception
    private bool GetMap(string url, string version, string layer, int minLevel, int maxLevel, string imageType, out ITileSource tileSource)
    {
        if (string.IsNullOrEmpty(imageType))
        {
            tileSource = null;
            return(false);
        }

        var schema = new GlobalSphericalMercator(imageType, YAxis.OSM, minLevel, maxLevel);

        schema.Validate();
        var request = new WmscRequest(new Uri(url), schema,
                                      layers: new[] { layer }.ToList(),
                                      styles: new[] { "" }.ToList(),
                                      version: version);
        var provider = new HttpTileProvider(request);

        tileSource = new TileSource(provider, schema);
        return(tileSource != null);
    }
コード例 #19
0
ファイル: BruTileClient.cs プロジェクト: tabinfl/Inception
        private bool GetMap(string url, string version, string layer, GeographicBounds bounds, string imageType, out ITileSource tileSource)
        {
            if (string.IsNullOrEmpty(imageType))
            {
                tileSource = null;
                return(false);
            }

            Extent extent = new Extent(bounds.MinimumCoordinates.Longitude, bounds.MinimumCoordinates.Latitude, bounds.MaximumCoordinates.Longitude, bounds.MaximumCoordinates.Latitude);
            var    schema = new GlobalSphericalMercator(imageType, YAxis.OSM, null, null, extent);

            schema.Validate();
            var request = new WmscRequest(new Uri(url), schema,
                                          layers: new[] { layer }.ToList(),
                                          styles: new[] { "" }.ToList(),
                                          version: version);
            var provider = new HttpTileProvider(request);

            tileSource = new TileSource(provider, schema);
            return(tileSource != null);
        }
コード例 #20
0
        public void Draw(IStepProgressor stepProgressor,
                         IActiveView activeView,
                         FileCache fileCache,
                         ITrackCancel trackCancel,
                         ISpatialReference layerSpatialReference,
                         ref string currentLevel, ITileSource tileSource, IDisplay display, string auth = null)
        {
            _auth                  = auth;
            _tileSource            = tileSource;
            _trackCancel           = trackCancel;
            _layerSpatialReference = layerSpatialReference;
            _currentLevel          = currentLevel;
            _fileCache             = fileCache;
            _tileProvider          = (HttpTileProvider)tileSource.Provider;
            var spatialReferences = new SpatialReferences();

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

            //var fetcher = new FileFetcher<Image>(osmTileSource, fileCache);

            _display = display;

            if (!activeView.Extent.IsEmpty)
            {
                var ti = TileCalculator.GetTiles(activeView, tileSource);
                _tiles        = ti.Tiles;
                _currentLevel = ti.Level;
                Logger.Debug("Number of tiles to draw: " + _tiles.Count);

                if (_tiles.ToList().Count > 0)
                {
                    stepProgressor.MinRange = 0;
                    stepProgressor.MaxRange = _tiles.ToList().Count;
                    stepProgressor.Show();

                    var downloadFinished = new ManualResetEvent(false);

                    // this is a hack, otherwise we get error message...
                    // "WaitAll for multiple handles on a STA thread is not supported. (mscorlib)"
                    // so lets start a thread first...
                    var t = new Thread(DownloadTiles);
                    t.Start(downloadFinished);

                    // wait till finished
                    downloadFinished.WaitOne();

                    // 3. Now draw all tiles...

                    if (layerSpatialReference != null && _dataSpatialReference != null)
                    {
                        _needReproject = (layerSpatialReference.FactoryCode != _dataSpatialReference.FactoryCode);
                    }
                    Logger.Debug("Need reproject tile: " + _needReproject.ToString());

                    foreach (var tile in _tiles)
                    {
                        stepProgressor.Step();

                        if (tile != null)
                        {
                            var name = _fileCache.GetFileName(tile.Index);

                            if (!File.Exists(name))
                            {
                                continue;
                            }
                            DrawRasterNew(name, tile);
                        }
                    }

                    stepProgressor.Hide();
                }
                else
                {
                    Logger.Debug("No tiles to retrieve or draw");
                }

                Logger.Debug("End drawing tiles: " + _tiles.ToList().Count);
            }
        }