private void InitializeLayer() { var mxdoc = (IMxDocument)_application.Document; _map = mxdoc.FocusMap; _cacheDir = CacheSettings.GetCacheFolder(); _tileTimeOut = ConfigurationHelper.GetTileTimeOut(); var spatialReferences = new SpatialReferences(); _tileSource = _config.CreateTileSource(); _schema = _tileSource.Schema; _dataSpatialReference = spatialReferences.GetSpatialReference(_schema.Srs); _envelope = GetDefaultEnvelope(); if (_map.SpatialReference == null) { // zet dan de spatial ref... _map.SpatialReference = _dataSpatialReference; } // If there is only one layer in the TOC zoom to this layer... if (_map.LayerCount == 0) { //envelope.Expand(-0.1, -0.1, true); _envelope.Project(_map.SpatialReference); ((IActiveView)_map).Extent = _envelope; } _displayFilter = new TransparencyDisplayFilterClass(); }
public override void Uninstall(System.Collections.IDictionary savedState) { base.OnBeforeUninstall(savedState); XmlConfigurator.Configure(new FileInfo(GetType().Assembly.Location + ".config")); Logger.Debug("Uninstall ArcBruTile"); // Try to clean up stuff try { var cacheFolder = CacheSettings.GetCacheFolder(); Logger.Debug("Trying to delete tile folder: " + cacheFolder); Directory.Delete(cacheFolder, true); Logger.Debug("Tile directory is deleted"); // delete services config dir var configFolder = CacheSettings.GetServicesConfigDir(); Directory.Delete(configFolder, true); } catch (Exception ex) { Logger.Debug("Delete folder failed, error: " + ex); } var esriRegAsmFilename = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles), "ArcGIS\\bin\\ESRIRegAsm.exe"); var esriRegAsm = new Process { StartInfo = { FileName = esriRegAsmFilename } }; var cmd = string.Format("\"{0}\" /p:Desktop /u", GetType().Assembly.Location); esriRegAsm.StartInfo.Arguments = cmd; Logger.Debug("Unregister for ArcGIS 10: " + cmd); esriRegAsm.Start(); Logger.Debug("Unregister for ArcGIS 10 finished."); }
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 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); }
private void button1_Click(object sender, EventArgs e) { string _cacheDir = CacheSettings.GetCacheFolder(); Process.Start(_cacheDir); }