public MapBoxVectorTileSource(string url, string ext = "pbf") { var request = new TmsRequest(new Uri(url), ext); Provider = new WebTileProvider(request, fetchTile: FetchTile); Schema = new GlobalSphericalMercator(); }
private void button1_Click(object sender, EventArgs e) { extent.Add(double.Parse(textBox3.Text)); extent.Add(double.Parse(textBox4.Text)); extent.Add(double.Parse(textBox5.Text)); extent.Add(double.Parse(textBox2.Text)); var tile = comboBox1.SelectedItem; if (tile == null) { MessageBox.Show("请选择至少一种地图"); return; } EnumBruTileLayer enumBruTileLayer = (EnumBruTileLayer)Enum.Parse(typeof(EnumBruTileLayer), tile.ToString()); IConfig config = ConfigHelper.GetConfig(enumBruTileLayer); string cacheDir = CacheSettings.GetCacheFolder(); tileSource = config.CreateTileSource(); schema = tileSource.Schema; tileProvider = (WebTileProvider)tileSource.Provider; fileCache = CacheDirectory.GetFileCache(cacheDir, config, enumBruTileLayer); _tiles = GetTile(); if (_tiles.ToList().Count > 0) { DownloadTiles(); } }
public void ProcessRequest(HttpContext context) { RuntimeManager.BindLicense(ProductCode.EngineOrDesktop); extent = context.Request.QueryString["Extent"].Split(new[] { ',' }).Select(Convert.ToDouble).ToList(); level = double.Parse(context.Request.QueryString["level"]); _config = ConfigHelper.GetConfig(EnumBruTileLayer.OSM); _tileSource = _config.CreateTileSource(); _tileProvider = (WebTileProvider)_tileSource.Provider; _cacheDir = CacheSettings.GetCacheFolder(); _fileCache = CacheDirectory.GetFileCache(_cacheDir, _config, EnumBruTileLayer.OSM); Draw(); //using (Bitmap map = new Bitmap(@"D:\我的文件\天津师大切片解决方案\DownloadTiles\DownloadTiles\bin\Debug\p.png")) using (Bitmap map = mosaicImage()) { using (MemoryStream mem = new MemoryStream()) { map.Save(mem, ImageFormat.Png); mem.Seek(0, SeekOrigin.Begin); context.Response.ContentType = "image/png"; mem.CopyTo(context.Response.OutputStream, 4096); context.Response.Flush(); } } }
public QuantizedMeshTileSource(string url, string ext = "terrain") { var request = new TmsRequest(new Uri(url), ext); Provider = new WebTileProvider(request, fetchTile: FetchTile); Schema = new GlobalSphericalMercator(); }
public GeodanWorldWmsTileSource() { var schema = new SphericalMercatorWorldSchema { Srs = "EPSG:900913" }; Provider = new WebTileProvider(CreateWmsRequest(schema)); Schema = schema; }
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); }
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); }
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 GeodanWorldTmsTileSource() { const string url = "http://geoserver.nl/tiles/tilecache.aspx/1.0.0/world_GM/"; var parameters = new Dictionary <string, string>(); parameters.Add("seriveparam", "world_GM"); parameters.Add("uid", "4c6b3b161be3a2eb513b66b09a70f18d"); var request = new TmsRequest(new Uri(url), "png", parameters); Provider = new WebTileProvider(request); Schema = new SphericalMercatorWorldSchema(); }
public GeodanWorldWmsTileSource() { var schema = new SphericalMercatorInvertedWorldSchema(); schema.Srs = "EPSG:900913"; const string url = "http://geoserver.nl/world/mapserv.cgi?map=world/world.map&VERSION=1.1.1"; var request = new WmscRequest(new Uri(url), schema, new List <string>(new [] { "world" }), new List <string>(), new Dictionary <string, string>()); Provider = new WebTileProvider(request); Schema = new SphericalMercatorInvertedWorldSchema(); }
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 WebTileProvider(baiduRequest); var tileSource = new TileSource(tileProvider, tileSchema); return(tileSource); }
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); }
public static TileSource CreateTileSource(Stream tileMapResource, string overrideUrl) { var reader = new StreamReader(tileMapResource); var serializer = new XmlSerializer(typeof(TileMap)); var tileMap = (TileMap)serializer.Deserialize(reader); var tileSchema = CreateSchema(tileMap); var tileUrls = new List <Uri>(); foreach (TileMapTileSetsTileSet ts in tileMap.TileSets.TileSet) { tileUrls.Add(new Uri(ts.href)); } var tileProvider = new WebTileProvider(CreateRequest(tileUrls, tileSchema.Format, overrideUrl)); return(new TileSource(tileProvider, tileSchema)); }
public static TileSource CreateTileSource(Stream tileMapResource, string overrideUrl = null, Dictionary<string, string> customParameters = null, IPersistentCache<byte[]> persistentCache = null, Func<Uri, HttpWebRequest> webRequestFactory = 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 WebTileProvider(CreateRequest(tileUrls, tileSchema.Format, overrideUrl, customParameters), persistentCache, webRequestFactory); return new TileSource(tileProvider, tileSchema); }
public static WmsTileSource Create(WmsServerInfo serverInfo) { var href = serverInfo.OnlineResource; var layers = new List <string> { serverInfo.Layer }; var schema = //new GlobalMercator("image/png"); new UnProjected(); var request = new WmscRequest(new Uri(href), schema, layers, new List <string>(), // styles new Dictionary <string, string>(), // custom parameters serverInfo.Version); var provider = new WebTileProvider(request); return(new WmsTileSource(provider, schema)); }
public void DoMainTask(DateTime time, string _extent, string basePath, string tileDir, string csv) { this.basePath = basePath; this.csv = csv; extent = _extent.Split(new[] { ',' }).Select(Convert.ToDouble).ToList(); _config = ConfigHelper.GetConfig(EnumBruTileLayer.OSM); _tileSource = _config.CreateTileSource(); _tileProvider = (WebTileProvider)_tileSource.Provider; _cacheDir = CacheSettings.GetCacheFolder(tileDir); while (true) { try { DeleteDirectory(_cacheDir); break; } catch (Exception ex) { LogManager.LogPath = AppDomain.CurrentDomain.BaseDirectory + "\\log\\"; LogManager.WriteLog("error", ex.Message); } } _fileCache = CacheDirectory.GetFileCache(_cacheDir, _config, EnumBruTileLayer.OSM); Draw(); var map = mosaicImage(); DirectoryInfo directory = new DirectoryInfo(basePath + time.ToString("yyyy") + "\\" + time.ToString("yyyyMMdd") + "\\" + time.ToString("yyyyMMddHHmm")); if (!directory.Exists) { directory.Create(); } map.Save(directory.FullName + "\\traffic.png"); CreateTrafficCsv(directory); }
public static TileSource CreateTileSource(Stream tileMapResource, string overrideUrl = null, Dictionary <string, string> customParameters = null, IPersistentCache <byte[]> persistentCache = null, Func <Uri, HttpWebRequest> webRequestFactory = 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 WebTileProvider(CreateRequest(tileUrls, tileSchema.Format, overrideUrl, customParameters), persistentCache, webRequestFactory); return(new TileSource(tileProvider, tileSchema)); }
public void Draw(IStepProgressor stepProgressor, IActiveView activeView, FileCache fileCache, ITrackCancel trackCancel, ISpatialReference layerSpatialReference, ref string currentLevel, ITileSource tileSource, IDisplay display) { _tileSource = tileSource; _trackCancel = trackCancel; _layerSpatialReference = layerSpatialReference; _currentLevel = currentLevel; _fileCache = fileCache; _tileProvider = (WebTileProvider)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) { _tiles = GetTiles(activeView); currentLevel = _currentLevel; 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 (IsBeAdded(tile)) // continue; // _showTiles.Add(tile);*/ // /* if (tile != null) // { // var name = _fileCache.GetFileName(tile.Index); // if (!File.Exists(name)) continue; // DrawRaster(name); // }*/ //} //stepProgressor.Hide(); } else { Logger.Debug("No tiles to retrieve or draw"); } Logger.Debug("End drawing tiles: " + _tiles.ToList().Count); } }