public virtual void StartDownload() { // Offline check if (World.Settings.WorkOffline) { return; } Log.Write(Log.Levels.Debug, "GSDR", "Starting download for " + m_url); // Log.Write(Log.Levels.Debug, "GSDR", "to be stored in "+this.m_imageStore.GetLocalPath(QuadTile)); WorldWind.Net.Wms.WmsImageStore wmsImageStore = m_imageStore as WorldWind.Net.Wms.WmsImageStore; System.Net.NetworkCredential downloadCredentials = null; if (wmsImageStore != null) { downloadCredentials = new System.Net.NetworkCredential(wmsImageStore.Username, wmsImageStore.Password); } QuadTile.IsDownloadingImage = true; download = new WebDownload(m_url, downloadCredentials); download.DownloadType = DownloadType.Wms; download.SavedFilePath = m_localFilePath + ".tmp"; download.ProgressCallback += new DownloadProgressHandler(UpdateProgress); download.CompleteCallback += new WorldWind.Net.DownloadCompleteHandler(DownloadComplete); download.BackgroundDownloadFile(); }
void WorldWindow_MouseUp(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) { return; } if (m_Form == null) { return; } if (!m_Form.Visible) { return; } if (m_Form.KeyLayer == null) { return; } QuadTileSet qts = m_Form.KeyLayer; WorldWind.Net.Wms.WmsImageStore wms = (WorldWind.Net.Wms.WmsImageStore)qts.ImageStores[0]; string requestUrl = wms.ServerGetMapUrl; string[] layerNameParts = wms.WMSLayerName.Split('&'); string layerName = layerNameParts[0]; string getMapParts = requestUrl += "?QUERY_LAYERS=" + layerName + "&SERVICE=WMS&VERSION=" + wms.Version + "&REQUEST=GetFeatureInfo&SRS=EPSG:4326&FEATURE_COUNT=10&INFO_FORMAT=text/plain&EXCEPTIONS=text/plain"; // From Servir-Viz... Angle LowerLeftX; Angle LowerLeftY; Angle UpperRightX; Angle UpperRightY; string minx, miny, maxx, maxy; char[] degreeChar = { '°' }; int mouseX = e.X; int mouseY = e.Y; int queryBoxWidth = 2 * queryBoxOffset + 1; int queryBoxHeight = 2 * queryBoxOffset + 1; int queryX = queryBoxOffset + 1; int queryY = queryBoxOffset + 1; drawArgs.WorldCamera.PickingRayIntersectionWithTerrain(mouseX - queryBoxOffset, mouseY + queryBoxOffset, out LowerLeftY, out LowerLeftX, drawArgs.CurrentWorld); drawArgs.WorldCamera.PickingRayIntersectionWithTerrain(mouseX + queryBoxOffset, mouseY - queryBoxOffset, out UpperRightY, out UpperRightX, drawArgs.CurrentWorld); //drawArgs.WorldCamera.PickingRayIntersectionWithTerrain(0, 0 + drawArgs.screenHeight, out LowerLeftY, out LowerLeftX, drawArgs.CurrentWorld); //drawArgs.WorldCamera.PickingRayIntersectionWithTerrain(drawArgs.screenWidth, 0, out UpperRightY, out UpperRightX, drawArgs.CurrentWorld); minx = LowerLeftX.ToString().Contains("NaN") ? "-180.0" : LowerLeftX.ToString().TrimEnd(degreeChar); miny = LowerLeftY.ToString().Contains("NaN") ? "-90.0" : LowerLeftY.ToString().TrimEnd(degreeChar); maxx = UpperRightX.ToString().Contains("NaN") ? "180.0" : UpperRightX.ToString().TrimEnd(degreeChar); maxy = UpperRightY.ToString().Contains("NaN") ? "90.0" : UpperRightY.ToString().TrimEnd(degreeChar); // request has to include a bbox and the requested pixel coords relative to that box... requestUrl += "&layers=" + wms.WMSLayerName; requestUrl += "&WIDTH=" + queryBoxWidth.ToString() + "&HEIGHT=" + queryBoxHeight.ToString(); requestUrl += "&BBOX=" + minx + "," + miny + "," + maxx + "," + maxy; requestUrl += "&X=" + queryX.ToString() + "&Y=" + queryY.ToString(); if (!World.Settings.WorkOffline) { WorldWind.Net.WebDownload dl = new WorldWind.Net.WebDownload(requestUrl); System.IO.FileInfo fi = new System.IO.FileInfo("GetFeatureInfo_response.txt"); dl.DownloadFile(fi.FullName); //dl.SavedFilePath = fi.FullName; //dl.BackgroundDownloadFile(GetFeatureDlComplete); if (World.Settings.UseInternalBrowser) { SplitContainer sc = (SplitContainer)drawArgs.parentControl.Parent.Parent; InternalWebBrowserPanel browser = (InternalWebBrowserPanel)sc.Panel1.Controls[0]; browser.NavigateTo(fi.FullName); } else { System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); psi.FileName = fi.FullName; psi.Verb = "open"; psi.UseShellExecute = true; psi.CreateNoWindow = true; System.Diagnostics.Process.Start(psi); } } }
private static ImageStore getImageStoreFromXPathNodeIterator(string name, XPathNodeIterator imageAccessorIter, RenderableObjectList parentRenderable, Cache cache) { double levelZeroTileSizeDegrees = ParseDouble(getInnerTextFromFirstChild(imageAccessorIter.Current.Select("LevelZeroTileSizeDegrees"))); int numberLevels = Int32.Parse(getInnerTextFromFirstChild(imageAccessorIter.Current.Select("NumberLevels"))); int textureSizePixels = Int32.Parse(getInnerTextFromFirstChild(imageAccessorIter.Current.Select("TextureSizePixels"))); string imageFileExtension = getInnerTextFromFirstChild(imageAccessorIter.Current.Select("ImageFileExtension")); string permanentDirectory = getInnerTextFromFirstChild(imageAccessorIter.Current.Select("PermanentDirectory")); if(permanentDirectory == null || permanentDirectory.Length == 0) permanentDirectory = getInnerTextFromFirstChild(imageAccessorIter.Current.Select("PermanantDirectory")); TimeSpan dataExpiration = getCacheExpiration(imageAccessorIter.Current.Select("DataExpirationTime")); string duplicateTilePath = getInnerTextFromFirstChild(imageAccessorIter.Current.Select("DuplicateTilePath")); string cacheDir = getInnerTextFromFirstChild(imageAccessorIter.Current.Select("CacheDirectory")); if(cacheDir == null || cacheDir.Length == 0) { cacheDir = String.Format("{0}{1}{2}{1}{3}", cache.CacheDirectory, Path.DirectorySeparatorChar, getRenderablePathString(parentRenderable), name); } else { cacheDir = Path.Combine(cache.CacheDirectory, cacheDir); } if(permanentDirectory != null && permanentDirectory.IndexOf(":") < 0) { permanentDirectory = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), permanentDirectory); } if(duplicateTilePath != null && duplicateTilePath.IndexOf(":") < 0) { duplicateTilePath = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), duplicateTilePath); } byte opacity = 255; // case 1 : permanent directory specified. if(permanentDirectory != null) { ImageStore ia = new ImageStore(); ia.DataDirectory = permanentDirectory; ia.LevelZeroTileSizeDegrees = levelZeroTileSizeDegrees; ia.LevelCount = numberLevels; ia.ImageExtension = imageFileExtension; //doesn't work when this is set //ia.CacheDirectory = cacheDir; if(duplicateTilePath != null && duplicateTilePath.Length > 0) { ia.DuplicateTexturePath = duplicateTilePath; } return ia; } // case 2: ImageTileService specified XPathNodeIterator imageTileServiceIter = imageAccessorIter.Current.Select("ImageTileService"); if(imageTileServiceIter.Count > 0) { imageTileServiceIter.MoveNext(); string serverUrl = getInnerTextFromFirstChild(imageTileServiceIter.Current.Select("ServerUrl")); string dataSetName = getInnerTextFromFirstChild(imageTileServiceIter.Current.Select("DataSetName")); string serverLogoFilePath = getInnerTextFromFirstChild(imageTileServiceIter.Current.Select("ServerLogoFilePath")); TimeSpan cacheExpiration = getCacheExpiration(imageTileServiceIter.Current.Select("CacheExpirationTime")); if(serverLogoFilePath != null && serverLogoFilePath.Length > 0 && !Path.IsPathRooted(serverLogoFilePath)) { serverLogoFilePath = Path.Combine( Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), serverLogoFilePath); } string opacityString = getInnerTextFromFirstChild(imageTileServiceIter.Current.Select("Opacity")); if(opacityString != null) opacity = byte.Parse(opacityString); ImageStore ia = new NltImageStore(dataSetName, serverUrl); ia.DataDirectory = null; ia.LevelZeroTileSizeDegrees = levelZeroTileSizeDegrees; ia.LevelCount = numberLevels; ia.ImageExtension = imageFileExtension; ia.CacheDirectory = cacheDir; ia.ServerLogo = serverLogoFilePath; return ia; } // case 3: WMSAccessor specified XPathNodeIterator wmsAccessorIter = imageAccessorIter.Current.Select("WMSAccessor"); if(wmsAccessorIter.Count > 0) { wmsAccessorIter.MoveNext(); WorldWind.Net.Wms.WmsImageStore wmsLayerStore = new WorldWind.Net.Wms.WmsImageStore(); wmsLayerStore.ImageFormat = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("ImageFormat")); wmsLayerStore.ImageExtension = imageFileExtension; wmsLayerStore.CacheDirectory = cacheDir; //wmsLayerAccessor.IsTransparent = ParseBool(getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("UseTransparency"))); wmsLayerStore.ServerGetMapUrl = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("ServerGetMapUrl")); wmsLayerStore.Version = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("Version")); wmsLayerStore.WMSLayerName = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("WMSLayerName")); string username = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("Username")); string password = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("Password")); string wmsStyleName = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("WMSLayerStyle")); string serverLogoPath = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("ServerLogoFilePath")); string opacityString = getInnerTextFromFirstChild(wmsAccessorIter.Current.Select("Opacity")); if(serverLogoPath != null && serverLogoPath.Length > 0 && !Path.IsPathRooted(serverLogoPath)) { serverLogoPath = Path.Combine( Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), serverLogoPath); } if(opacityString != null) opacity = byte.Parse(opacityString); TimeSpan cacheExpiration = getCacheExpiration(imageAccessorIter.Current.Select("CacheExpirationTime")); //if(username != null && username.Length > 0) // wmsLayerStore.Username = username; //if(password != null) // wmsLayerAccessor.Password = password; if(wmsStyleName != null && wmsStyleName.Length > 0) wmsLayerStore.WMSLayerStyle = wmsStyleName; else wmsLayerStore.WMSLayerStyle = ""; wmsLayerStore.LevelCount = numberLevels; wmsLayerStore.LevelZeroTileSizeDegrees = levelZeroTileSizeDegrees; return wmsLayerStore; } Log.Write(Log.Levels.Warning, "CONF", "WARNING: no valid image store found!"); return null; }