private GeographicBoundingBox GetNewBox(GeographicBoundingBox input, double dScale) { GeographicBoundingBox result = new GeographicBoundingBox( input.CenterLatitude + (input.North - input.CenterLatitude) * dScale, input.CenterLatitude + (input.South - input.CenterLatitude) * dScale, input.CenterLongitude + (input.West - input.CenterLongitude) * dScale, input.CenterLongitude + (input.East - input.CenterLongitude) * dScale ); //result.North = Math.Min(m_oGroundOverlay.LatLonBox.North, Math.Min(90.0, result.North)); //result.South = Math.Max(m_oGroundOverlay.LatLonBox.South, Math.Max(-90.0, result.South)); if (!WraparoundLayer) { //result.East = Math.Min(m_oGroundOverlay.LatLonBox.East, Math.Min(180.0, result.East)); //result.West = Math.Max(m_oGroundOverlay.LatLonBox.West, Math.Max(-180.0, result.West)); } else { if (result.Longitude > 360.0) { result.East = 180.0; result.West = -180.0; } } return(result); }
internal ArcIMSQuadLayerBuilder(ArcIMSServerUri oServerUri, String strServiceName, String szLayerTitle, String szLayerID, GeographicBoundingBox oEnvelope, ArcIMSFeatureCoordSys oProjection, WorldWindow oWorldWindow, IBuilder oParent, double dMinScale, double dMaxScale, CultureInfo oInfo) : base(szLayerTitle, oWorldWindow, oParent) { m_oServerUri = oServerUri; m_oCultureInfo = oInfo; m_oUnprojectedEnvelope = oEnvelope; m_oProjection = oProjection; m_szLayerID = szLayerID; m_szServiceName = strServiceName; m_dMinScale = dMinScale; if (m_dMinScale < DefaultMinScale) { m_dMinScale = DefaultMinScale; } m_dMaxScale = dMaxScale; if (m_dMaxScale > DefaultMaxScale) { m_dMaxScale = DefaultMaxScale; } if (m_dMaxScale < m_dMinScale) { // --- Weird scale values, ignore them and hope for the best --- m_dMaxScale = DefaultMaxScale; m_dMinScale = DefaultMinScale; } CalculateLevels(); }
/// <summary> /// 获取几何绘制外边框 /// </summary> protected void GetGeographicBoundingBox() { if (m_Polygons == null || m_Polygons.Length < 1) { return; } double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; double minZ = double.MaxValue; double maxZ = double.MinValue; m_GeoBBox = new GeographicBoundingBox(maxY, minY, minX, maxX, minZ, maxZ); for (int i = 0; i < m_Polygons.Length; i++) { Polygon plg = m_Polygons[i]; GeographicBoundingBox plgGBB = plg.GetGeographicBoundingBox(); m_GeoBBox.ExtentGeoBBox(plgGBB); } }
public ArcIMSReprojectDownload(ArcIMSServerUri serverUri, int index, GeographicBoundingBox sourceBounds, ArcIMSFeatureCoordSys sourceCoordSys, String serviceName) : base(serverUri, index) { this.sourceBounds = sourceBounds; this.sourceCoordSys = sourceCoordSys; this.serviceName = serviceName; }
private void LoadTileServerSet(dappleview.tileserversetType entry) { if (entry.Hastilelayers()) { for (int i = 0; i < entry.tilelayers.tilelayerCount; i++) { dappleview.tilelayerType oLayer = entry.tilelayers.GettilelayerAt(i); dappleview.boundingboxType oBoundsData = oLayer.boundingbox; GeographicBoundingBox oBounds = new GeographicBoundingBox( oBoundsData.maxlat.Value, oBoundsData.minlat.Value, oBoundsData.minlon.Value, oBoundsData.maxlon.Value); ImageTileLayerModelNode oNode = new ImageTileLayerModelNode( this, oLayer.name.Value, new Uri(oLayer.url.Value), oLayer.imageextension.Value, oLayer.levelzerotilesize.Value, oLayer.dataset.Value, oLayer.levels.Value, oBounds, oLayer.Hasdistanceabovesurface() ? oLayer.distanceabovesurface.Value : Convert.ToInt32(dappleview.tilelayerType.GetdistanceabovesurfaceDefault(), CultureInfo.InvariantCulture), oLayer.Hastilepixelsize() ? oLayer.tilepixelsize.Value : Convert.ToInt32(dappleview.tilelayerType.GettilepixelsizeDefault(), CultureInfo.InvariantCulture) ); this.AddImageTileLayer(entry.name.Value, oNode); } } }
protected virtual ImageTileInfo GetImageTileInfo(GeographicBoundingBox geoBox, int level) { int row = SMath.GetRowFromLatitude((geoBox.South + geoBox.North) / 2, geoBox.North - geoBox.South); int col = SMath.GetColFromLongitude((geoBox.West + geoBox.East) / 2, geoBox.North - geoBox.South); return(GetImageTileInfo(level, row, col)); }
internal static RenderableObject CreateKMLLayer(KMLFile oSource, World oWorld, out GeographicBoundingBox oBounds) { oBounds = GeographicBoundingBox.NullBox(); RenderableObject result = Construct(Path.GetDirectoryName(oSource.Filename), oSource.Document, oWorld, oBounds, null, null); if (!oBounds.IsValid) oBounds = new GeographicBoundingBox(90.0, -90.0, -180.0, 180.0); return result; }
public override void Initialize(WorldWind.DrawArgs drawArgs) { lock (this) { m_oLastAoI = drawArgs.CurrentRoI; m_oLastAoIChangeTime = DateTime.Now; if (m_oGroundOverlay.Icon.ViewRefreshMode == KMLViewRefreshMode.onStop) { GeographicBoundingBox oRenderBox = GetNewBox(drawArgs.CurrentRoI, m_oGroundOverlay.Icon.ViewBoundScale); m_oLayer = new ImageLayer( m_oGroundOverlay.Name, drawArgs.CurrentWorld, m_oGroundOverlay.Altitude, m_strImageFilename, oRenderBox.South, oRenderBox.North, oRenderBox.West, oRenderBox.East, (byte)(m_oGroundOverlay.Color.A * ((double)m_opacity / (double)(byte.MaxValue))), drawArgs.CurrentWorld.TerrainAccessor); if (m_oGroundOverlay.Icon.IsLocalFile) { m_oLayer.ImagePath = Path.Combine(m_strKMLDirectory, m_oGroundOverlay.Icon.HRef); } else { m_oLayer.ImageUrl = m_oGroundOverlay.Icon.GetUri(oRenderBox.West, oRenderBox.South, oRenderBox.East, oRenderBox.North); } m_oLayerAoI = drawArgs.CurrentRoI.Clone() as GeographicBoundingBox; } else { m_oLayer = new ImageLayer( m_oGroundOverlay.Name, drawArgs.CurrentWorld, m_oGroundOverlay.Altitude, m_strImageFilename, m_oGroundOverlay.LatLonBox.South, m_oGroundOverlay.LatLonBox.North, m_oGroundOverlay.LatLonBox.West, m_oGroundOverlay.LatLonBox.East, (byte)(m_oGroundOverlay.Color.A * ((double)m_opacity / (double)(byte.MaxValue))), drawArgs.CurrentWorld.TerrainAccessor); if (m_oGroundOverlay.Icon.IsLocalFile) { m_oLayer.ImagePath = Path.Combine(m_strKMLDirectory, m_oGroundOverlay.Icon.HRef); } else { m_oLayer.ImageUrl = m_oGroundOverlay.GetUri(); } } m_oLayer.Initialize(drawArgs); } }
internal override LayerBuilder getBuilder(DappleModel oModel) { GeographicBoundingBox oLayerBounds = new GeographicBoundingBox(); bool blTerrainMapped; int iHeight, iLevels, iSize; double dLvl0Tilesie; if (!Double.TryParse(getAttribute("west"), NumberStyles.Any, CultureInfo.InvariantCulture, out oLayerBounds.West)) { return(null); } if (!Double.TryParse(getAttribute("south"), NumberStyles.Any, CultureInfo.InvariantCulture, out oLayerBounds.South)) { return(null); } if (!Double.TryParse(getAttribute("east"), NumberStyles.Any, CultureInfo.InvariantCulture, out oLayerBounds.East)) { return(null); } if (!Double.TryParse(getAttribute("north"), NumberStyles.Any, CultureInfo.InvariantCulture, out oLayerBounds.North)) { return(null); } if (!Int32.TryParse(getAttribute("height"), NumberStyles.Any, CultureInfo.InvariantCulture, out iHeight)) { return(null); } if (!Int32.TryParse(getAttribute("levels"), NumberStyles.Any, CultureInfo.InvariantCulture, out iLevels)) { return(null); } if (!Int32.TryParse(getAttribute("size"), NumberStyles.Any, CultureInfo.InvariantCulture, out iSize)) { return(null); } if (!Boolean.TryParse(getAttribute("terrainmapped"), out blTerrainMapped)) { return(null); } if (!Double.TryParse(getAttribute("lvl0tilesize"), NumberStyles.Any, CultureInfo.InvariantCulture, out dLvl0Tilesie)) { return(null); } return(new NltQuadLayerBuilder( getAttribute("name"), iHeight, blTerrainMapped, oLayerBounds, dLvl0Tilesie, iLevels, iSize, m_oServer.ToBaseUri(), getAttribute("datasetname"), getAttribute("imgfileext"), 255, MainForm.WorldWindowSingleton, null)); }
public override void Update(WorldWind.DrawArgs drawArgs) { lock (this) { if (m_oLayer != null) { if (m_oGroundOverlay.Icon.ViewRefreshMode == KMLViewRefreshMode.onStop) { double dTimeStopped; if (drawArgs.CurrentRoI.Equals(m_oLastAoI)) { dTimeStopped = (DateTime.Now - m_oLastAoIChangeTime).Seconds; } else { dTimeStopped = 0.0; m_oLastAoI = drawArgs.CurrentRoI; m_oLastAoIChangeTime = DateTime.Now; } if (dTimeStopped > m_oGroundOverlay.Icon.ViewRefreshTime && !m_oLayerAoI.Equivalent(drawArgs.CurrentRoI, 1e-6)) { try { File.Delete(m_strImageFilename); } catch (IOException) { return; } GeographicBoundingBox oRenderBox = GetNewBox(drawArgs.CurrentRoI, m_oGroundOverlay.Icon.ViewBoundScale); m_oLayer = new ImageLayer( m_oGroundOverlay.Name, drawArgs.CurrentWorld, m_oGroundOverlay.Altitude, m_strImageFilename, oRenderBox.South, oRenderBox.North, oRenderBox.West, oRenderBox.East, (byte)(m_oGroundOverlay.Color.A * ((double)m_opacity / (double)(byte.MaxValue))), drawArgs.CurrentWorld.TerrainAccessor); if (m_oGroundOverlay.Icon.IsLocalFile) { m_oLayer.ImagePath = Path.Combine(m_strKMLDirectory, m_oGroundOverlay.Icon.HRef); } else { m_oLayer.ImageUrl = m_oGroundOverlay.Icon.GetUri(oRenderBox.West, oRenderBox.South, oRenderBox.East, oRenderBox.North); } m_oLayer.Initialize(drawArgs); m_oLayerAoI = drawArgs.CurrentRoI.Clone() as GeographicBoundingBox; } } m_oLayer.Update(drawArgs); } } }
internal DappleSearchWebDownload(GeographicBoundingBox oBoundingBox, String szKeywords, int iPage, long lSearchIndex, int resultsPerPage) : base(MainForm.Settings.DappleSearchURL, true) { m_oBoundingBox = oBoundingBox; m_szKeywords = szKeywords; m_iPage = iPage; m_lSearchIndex = lSearchIndex; m_iNumResults = resultsPerPage; }
public void ExtentGeoBBox(GeographicBoundingBox boundingBox) { North = (North < boundingBox.North) ? boundingBox.North : North; South = (South > boundingBox.South) ? boundingBox.South : South; East = (East < boundingBox.East) ? boundingBox.East : East; West = (West > boundingBox.West) ? boundingBox.West : West; MaximumAltitude = (MaximumAltitude < boundingBox.MaximumAltitude) ? boundingBox.MaximumAltitude : MaximumAltitude; MinimumAltitude = (MinimumAltitude > boundingBox.MinimumAltitude) ? boundingBox.MinimumAltitude : MinimumAltitude; }
private void butNext_Click(object sender, EventArgs e) { if (ValidateChildren(ValidationConstraints.Enabled) && Validate()) { // if there are screens to go to.... if (butNext.Text.StartsWith("&N")) { tabCtl.TabPages.Clear(); tabCtl.TabPages.Add(m_tabPages[m_intCurrentTab]); } // otherwise else { // Make result available and close if (m_intCurrentTab == 3) { m_oServer = null; m_oTileServer = null; m_WmsURL = txtWmsServeURL.Text; } else if (m_intCurrentTab == 2) { //DAP m_oTileServer = null; m_WmsURL = ""; } else if (m_intCurrentTab == 1) { m_oServer = null; m_WmsURL = ""; string cacheDir = System.IO.Path.Combine(m_worldWind.WorldWindSettings.CachePath, txtName.Text); ImageTileService imageTileService = new ImageTileService(txtDatabaseName.Text, txtServerURL.Text, txtServerURL.Text); GeographicBoundingBox geoBox = new GeographicBoundingBox( Math.Round(Convert.ToDouble(numN.Value), 0), Math.Round(Convert.ToDouble(numS.Value), 0), Math.Round(Convert.ToDouble(numW.Value), 0), Math.Round(Convert.ToDouble(numE.Value), 0)); m_oTileServer = new LayerGeneration.QuadLayerBuilder( txtName.Text, Convert.ToInt32(numHeight.Value), chkTileServerUseTerrainMap.Checked, geoBox, numTileSize.Value, Convert.ToInt32(numLevels.Value), Convert.ToInt32(numImagePixelSize.Value), imageTileService, cmbTileServerFileExtension.Text, Convert.ToByte(chkShowOnAdd.Checked ? 255 : 0), m_worldWind.CurrentWorld, m_worldWind.WorldWindSettings.CachePath, m_worldWind.WorldWindSettings.CachePath, m_oParent); } Close(); } } // Change next to finish for those screens that end the wizard if (m_intCurrentTab != 0) { butNext.Text = "&OK"; } }
public virtual Texture GetTexture(DrawArgs drawArgs, GeographicBoundingBox geoBox, int level) { ImageTileInfo info = GetImageTileInfo(geoBox, level); if (File.Exists(info.ImagePath)) { return(ImageHelper.LoadTexture(drawArgs.device, info.ImagePath, this.m_TransparentColor)); } return(null); }
internal WMSLayerModelNode(DappleModel oModel, WMSLayer oData) : base(oModel) { m_oData = oData; m_oBounds = new GeographicBoundingBox((double)m_oData.North, (double)m_oData.South, (double)m_oData.West, (double)m_oData.East); m_oViewLegend = new ToolStripMenuItem("View Legend...", IconKeys.ImageList.Images[IconKeys.ViewLegendMenuItem], new EventHandler(c_miViewLegend_Click)); MarkLoaded(); }
internal static RenderableObject CreateKMLLayer(KMLFile oSource, World oWorld, out GeographicBoundingBox oBounds) { oBounds = GeographicBoundingBox.NullBox(); RenderableObject result = Construct(Path.GetDirectoryName(oSource.Filename), oSource.Document, oWorld, oBounds, null, null); if (!oBounds.IsValid) { oBounds = new GeographicBoundingBox(90.0, -90.0, -180.0, 180.0); } return(result); }
public bool Intersects(GeographicBoundingBox boundingBox) { if(this.North <= boundingBox.South || this.South >= boundingBox.North || this.West >= boundingBox.East || this.East <= boundingBox.West) { return false; } else { return true; } }
public virtual GeoSpatialDownloadRequest RequestTexture(DrawArgs drawArgs, GeographicBoundingBox geoBox, int level) { ImageTileInfo info = GetImageTileInfo(geoBox, level); GeoSpatialDownloadRequest request = GetDownloadRequest(geoBox, info); if (!request.IsComplete) { m_downloadQueue.AddToDownloadQueue(drawArgs, request); } return(request); }
internal ArcIMSLayerUri ToLayerUri(String strServiceName, GeographicBoundingBox oBox) { String strUri = base.ToString() + (base.ToString().IndexOf("?") > 0 ? "&" : "?") + "ServiceName=" + strServiceName + "&minx=" + oBox.West + "&miny=" + oBox.South + "&maxx=" + oBox.East + "&maxy=" + oBox.North; return(new ArcIMSLayerUri(strUri)); }
internal ArcIMSLayerModelNode(DappleModel oModel, String strTitle, String strID, GeographicBoundingBox oBounds, double dMinScale, double dMaxScale, CultureInfo oCultureInfo) : base(oModel) { m_strTitle = strTitle; m_strID = strID; m_oBounds = oBounds; m_dMinScale = dMinScale; m_dMaxScale = dMaxScale; m_oCultureInfo = oCultureInfo; MarkLoaded(); }
/// <summary> /// Updates a TreeNode to be loaded, loading, or broken. /// </summary> /// <param name="oParent">The TreeNode whose tag is this ServerBuilder.</param> /// <param name="oTree">The ServerTree which contains oParent.</param> internal override void updateTreeNode(TreeNode oParent, bool blnAOIFilter, GeographicBoundingBox oAOI, String strSearch) { if (m_blEnabled == false) { oParent.ImageIndex = MainForm.ImageListIndex(MainForm.DisabledServerIconKey); oParent.SelectedImageIndex = MainForm.ImageListIndex(MainForm.DisabledServerIconKey); oParent.Text = Title + " (Disabled)"; } else { base.updateTreeNode(oParent, blnAOIFilter, oAOI, strSearch); } }
internal KMLLayerBuilder(String strFilename, String strLayerName, WorldWindow oWorldWindow, IBuilder oParent, GeographicBoundingBox oBounds) : base(strLayerName, oWorldWindow, oParent) { m_strInitFilename = strFilename; if (File.Exists(m_strInitFilename)) { m_oSourceFile = new KMLFile(strFilename); m_oRenderable = KMLCreation.CreateKMLLayer(m_oSourceFile, oWorldWindow.CurrentWorld, out m_oBounds); if (oBounds != null) m_oBounds = oBounds; m_oRenderable.RenderPriority = RenderPriority.TerrainMappedImages; } }
public bool Intersects(GeographicBoundingBox boundingBox) { if (North <= boundingBox.South || South >= boundingBox.North || West >= boundingBox.East || East <= boundingBox.West) { return(false); } else { return(true); } }
internal KMLLayerBuilder(String strFilename, String strLayerName, WorldWindow oWorldWindow, IBuilder oParent, GeographicBoundingBox oBounds) : base(strLayerName, oWorldWindow, oParent) { m_strInitFilename = strFilename; if (File.Exists(m_strInitFilename)) { m_oSourceFile = new KMLFile(strFilename); m_oRenderable = KMLCreation.CreateKMLLayer(m_oSourceFile, oWorldWindow.CurrentWorld, out m_oBounds); if (oBounds != null) { m_oBounds = oBounds; } m_oRenderable.RenderPriority = RenderPriority.TerrainMappedImages; } }
internal ImageTileLayerModelNode(DappleModel oModel, String strName, Uri oUri, String strExtension, double dLZTS, String strDataset, int iLevels, GeographicBoundingBox oBounds, int iDistanceAboveSurface, int iTextureSize) : base(oModel) { m_strName = strName; m_oUri = oUri; m_strExtension = strExtension; m_dLZTS = dLZTS; m_strDataset = strDataset; m_iLevels = iLevels; m_oBounds = oBounds; m_iDistanceAboveSurface = iDistanceAboveSurface; m_iTextureSize = iTextureSize; MarkLoaded(); }
internal NltQuadLayerBuilder(string name, int height, bool isTerrainMapped, GeographicBoundingBox boundary, double levelZeroTileSize, int levels, int textureSize, string serverURL, string dataSetName, string imageExtension, byte opacity, WorldWindow worldWindow, IBuilder parent) : base(name, worldWindow, parent) { distAboveSurface = height; terrainMapped = isTerrainMapped; m_hBoundary = boundary; m_bOpacity = opacity; m_strWorldName = worldWindow.CurrentWorld.Name; m_iLevels = levels; m_iTextureSizePixels = textureSize; m_dLevelZeroTileSizeDegrees = levelZeroTileSize; m_strServerUrl = serverURL; m_strDatasetName = dataSetName; m_strImageExt = imageExtension; }
/// <summary> /// Constructor. /// </summary> internal ServerList() { InitializeComponent(); c_lvLayers.SmallImageList = Dapple.MainForm.DataTypeImageList; c_lvLayers.LargeImageList = Dapple.MainForm.DataTypeImageList; c_oPageNavigator.PageBack += BackPage; c_oPageNavigator.PageForward += ForwardPage; m_strSearchString = String.Empty; m_oSearchBox = null; m_oDragDropStartPoint = Point.Empty; SetNoServer(); }
internal override LayerBuilder getBuilder(DappleModel oModel) { oModel.AddArcIMSServer(m_oServer as ArcIMSServerUri, true, false, false); GeographicBoundingBox oLayerBounds = new GeographicBoundingBox(); double dMinScale, dMaxScale; if (!Double.TryParse(getAttribute("minx"), NumberStyles.Any, CultureInfo.InvariantCulture, out oLayerBounds.West)) { return(null); } if (!Double.TryParse(getAttribute("miny"), NumberStyles.Any, CultureInfo.InvariantCulture, out oLayerBounds.South)) { return(null); } if (!Double.TryParse(getAttribute("maxx"), NumberStyles.Any, CultureInfo.InvariantCulture, out oLayerBounds.East)) { return(null); } if (!Double.TryParse(getAttribute("maxy"), NumberStyles.Any, CultureInfo.InvariantCulture, out oLayerBounds.North)) { return(null); } if (!Double.TryParse(getAttribute("minscale"), NumberStyles.Any, CultureInfo.InvariantCulture, out dMinScale)) { return(null); } if (!Double.TryParse(getAttribute("maxscale"), NumberStyles.Any, CultureInfo.InvariantCulture, out dMaxScale)) { return(null); } return(new ArcIMSQuadLayerBuilder( m_oServer as ArcIMSServerUri, getAttribute("servicename"), getAttribute("title"), getAttribute("layerid"), oLayerBounds, new ArcIMSFeatureCoordSys(new CultureInfo("en-US")), MainForm.WorldWindowSingleton, null, dMinScale, dMaxScale, new CultureInfo("en-US"))); }
public XmlDocument MakeArcXmlRequest(GeographicBoundingBox source) { XmlDocument result = new XmlDocument(); result.AppendChild(result.CreateXmlDeclaration("1.0", "UTF-8", null)); XmlElement arcNode = result.CreateElement("ARCXML"); arcNode.SetAttribute("version", "1.1"); { XmlNode requestNode = result.CreateElement("REQUEST"); { XmlElement getProjectElement = result.CreateElement("GET_PROJECT"); getProjectElement.SetAttribute("envelope", "true"); { XmlElement fromCoordSysElement = result.CreateElement("FROMCOORDSYS"); if (!String.IsNullOrEmpty(stringAttribute)) { fromCoordSysElement.SetAttribute("string", stringAttribute); } else { fromCoordSysElement.SetAttribute("id", idAttribute); } getProjectElement.AppendChild(fromCoordSysElement); XmlElement toCoordSysElement = result.CreateElement("TOCOORDSYS"); toCoordSysElement.SetAttribute("id", "4326"); getProjectElement.AppendChild(toCoordSysElement); XmlElement envelopeElement = result.CreateElement("ENVELOPE"); envelopeElement.SetAttribute("minx", source.West.ToString(culture)); envelopeElement.SetAttribute("miny", source.South.ToString(culture)); envelopeElement.SetAttribute("maxx", source.East.ToString(culture)); envelopeElement.SetAttribute("maxy", source.North.ToString(culture)); getProjectElement.AppendChild(envelopeElement); } requestNode.AppendChild(getProjectElement); } arcNode.AppendChild(requestNode); } result.AppendChild(arcNode); return(result); }
/// <summary> /// Updates a TreeNode to be loaded, loading, or broken. /// </summary> /// <param name="oParent">The TreeNode whose tag is this ServerBuilder.</param> /// <param name="oTree">The ServerTree which contains oParent.</param> internal virtual void updateTreeNode(TreeNode oParent, bool blnAOIFilter, GeographicBoundingBox oAOI, String strSearch) { if (IsLoading) { oParent.ImageIndex = MainForm.ImageListIndex(MainForm.EnabledServerIconKey); oParent.SelectedImageIndex = MainForm.ImageListIndex(MainForm.EnabledServerIconKey); oParent.Text = Title + " (Loading...)"; } else if (LoadingErrorOccurred) { oParent.ImageIndex = MainForm.ImageListIndex(MainForm.OfflineServerIconKey); oParent.SelectedImageIndex = MainForm.ImageListIndex(MainForm.OfflineServerIconKey); oParent.Text = Title + " (" + ErrorMessage + ")"; } else { oParent.ImageIndex = MainForm.ImageListIndex(MainForm.EnabledServerIconKey); oParent.SelectedImageIndex = MainForm.ImageListIndex(MainForm.EnabledServerIconKey); oParent.Text = Title + " (" + iGetLayerCount(blnAOIFilter, oAOI, strSearch).ToString(CultureInfo.InvariantCulture) + ")"; } }
public XmlDocument MakeArcXmlRequest(GeographicBoundingBox source) { XmlDocument result = new XmlDocument(); result.AppendChild(result.CreateXmlDeclaration("1.0", "UTF-8", null)); XmlElement arcNode = result.CreateElement("ARCXML"); arcNode.SetAttribute("version", "1.1"); { XmlNode requestNode = result.CreateElement("REQUEST"); { XmlElement getProjectElement = result.CreateElement("GET_PROJECT"); getProjectElement.SetAttribute("envelope", "true"); { XmlElement fromCoordSysElement = result.CreateElement("FROMCOORDSYS"); if (!String.IsNullOrEmpty(stringAttribute)) fromCoordSysElement.SetAttribute("string", stringAttribute); else fromCoordSysElement.SetAttribute("id", idAttribute); getProjectElement.AppendChild(fromCoordSysElement); XmlElement toCoordSysElement = result.CreateElement("TOCOORDSYS"); toCoordSysElement.SetAttribute("id", "4326"); getProjectElement.AppendChild(toCoordSysElement); XmlElement envelopeElement = result.CreateElement("ENVELOPE"); envelopeElement.SetAttribute("minx", source.West.ToString(culture)); envelopeElement.SetAttribute("miny", source.South.ToString(culture)); envelopeElement.SetAttribute("maxx", source.East.ToString(culture)); envelopeElement.SetAttribute("maxy", source.North.ToString(culture)); getProjectElement.AppendChild(envelopeElement); } requestNode.AppendChild(getProjectElement); } arcNode.AppendChild(requestNode); } result.AppendChild(arcNode); return result; }
internal WMSQuadLayerBuilder(WMSLayer layer, WorldWindow worldWindow, WMSServerBuilder server, IBuilder parent) : base(layer.Title, worldWindow, parent) { m_Server = server; m_wmsLayer = layer; distAboveSurface = 0; m_hBoundary = new GeographicBoundingBox((double)layer.North, (double)layer.South, (double)layer.West, (double)layer.East); // Determine the needed levels (function of tile size and resolution, for which we just use ~5 meters because it is not available with WMS) double dRes = 5.0 / 100000.0; if (dRes > 0) { double dTileSize = LevelZeroTileSize; m_iLevels = 1; while (dTileSize / Convert.ToDouble(TextureSizePixels) > dRes / 4.0) { m_iLevels++; dTileSize /= 2; } } }
private GeographicBoundingBox ProcessResponse(XmlDocument document) { XmlElement envelopeElement = document.SelectSingleNode("/ARCXML/RESPONSE/PROJECT/ENVELOPE") as XmlElement; if (envelopeElement != null) { GeographicBoundingBox result = new GeographicBoundingBox(); bool success = true; success &= Double.TryParse(envelopeElement.GetAttribute("minx"), NumberStyles.Float, culture, out result.West); success &= Double.TryParse(envelopeElement.GetAttribute("miny"), NumberStyles.Float, culture, out result.South); success &= Double.TryParse(envelopeElement.GetAttribute("maxx"), NumberStyles.Float, culture, out result.East); success &= Double.TryParse(envelopeElement.GetAttribute("maxy"), NumberStyles.Float, culture, out result.North); if (success) { return(result); } } return(new GeographicBoundingBox(89.4, -89.4, -180, 180)); }
public override void Load() { string name = "Geocover 1990"; string description = "NASA derived global 30 meters per pixel satellite image mosaic"; //////////////////////////--------------- double north = 90.0; double south = -90.0; double west = -180.0; double east = 180.0; GeographicBoundingBox box = new GeographicBoundingBox(north, south, west, east); ///////////////////////////--------------------- string m_strDataSetName = "bmng.topo.bathy.200403"; string m_strServerUrl = "http://worldwind25.arc.nasa.gov/tile/tile.aspx"; ImageTileService m_oImageTileService = new ImageTileService(m_strDataSetName, m_strServerUrl); //////////////////////////------------------------------- decimal m_decLevelZeroTileSizeDegrees = 36.0m; int m_intNumberLevels = 20; int m_intTextureSizePixels = 256; string m_strImageFileExtension = "jpg"; string strCachePath = @"E:\项目\智岩切片工具\分块数据\DomTile";// Config.EarthSetting.CachePath + "\\bmng\\"; ImageAccessor m_oImageAccessor = new ImageAccessor(strCachePath, m_intTextureSizePixels, m_decLevelZeroTileSizeDegrees, m_intNumberLevels, m_strImageFileExtension, strCachePath, m_oImageTileService); QuadTileSet tile = new QuadTileSet(name, box, this.Viewer.CurrentWorld, 0, this.Viewer.CurrentWorld.TerrainAccessor, m_oImageAccessor, m_bOpacity, true); tile.IsVisible = true; this.Viewer.CurrentWorld.RenderLayerList.Add(tile); }
private void AddKML(String strKMLFile, String strKMLName, bool blTemporary, bool blGoTo, GeographicBoundingBox oBounds) { try { this.UseWaitCursor = true; Dapple.KML.KMLLayerBuilder oBuilder = new Dapple.KML.KMLLayerBuilder(strKMLFile, strKMLName, WorldWindowSingleton, null, oBounds); oBuilder.Temporary = blTemporary; c_oLayerList.AddLayer(oBuilder); oBuilder.GoToLookAt(WorldWindowSingleton); } catch (Exception ex) { Program.ShowMessageBox( "An error occurred while trying to add Keyhole file " + strKMLFile + ":" + Environment.NewLine + Environment.NewLine + ex.Message.ToString(), "Open KML File", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Error ); } finally { this.UseWaitCursor = false; } }
private void clearSearch() { SetSearchable(true); SetSearchClearable(false); m_oLastSearchROI = null; m_szLastSearchString = String.Empty; c_tbSearchKeywords.Text = NO_SEARCH; c_tbSearchKeywords.ForeColor = SystemColors.GrayText; applySearchCriteria(); }
private static RenderableObject Construct(String strRelativeDirectory, KMLObject oSource, World oWorld, GeographicBoundingBox oBounds, ProjectedVectorRenderer oPVR, Icons oIcons) { if (oSource is KMLContainer) { KMLContainer oCastSource = oSource as KMLContainer; KMLRenderableObjectList result = new KMLRenderableObjectList(oCastSource.Name); if (oPVR == null) { oPVR = new ProjectedVectorRenderer("Polygons and LineStrings", oWorld); result.Add(oPVR); } if (oIcons == null) { oIcons = new Icons("Icons"); result.Add(oIcons); } for (int count = 0; count < oCastSource.Count; count++) { if (oCastSource[count].Visibility == true) { RenderableObject oLayer = Construct(strRelativeDirectory, oCastSource[count], oWorld, oBounds, oPVR, oIcons); if (oLayer != null) { result.Add(oLayer); } } } return result; } else if (oSource is KMLPlacemark) { KMLPlacemark oCastSource = oSource as KMLPlacemark; return Construct(strRelativeDirectory, oCastSource.Geometry, oWorld, oBounds, oPVR, oIcons); } else if (oSource is KMLMultiGeometry) { KMLMultiGeometry oCastSource = oSource as KMLMultiGeometry; KMLRenderableObjectList result = new KMLRenderableObjectList("MultiGeometry"); for (int count = 0; count < oCastSource.Count; count++) { RenderableObject oLayer = Construct(strRelativeDirectory, oCastSource[count], oWorld, oBounds, oPVR, oIcons); if (oLayer != null) { result.Add(oLayer); } } return result; } else if (oSource is KMLPoint) { KMLPoint oCastSource = oSource as KMLPoint; KMLIcon result = new KMLIcon(oCastSource.Owner.Name, oCastSource.Coordinates.Latitude, oCastSource.Coordinates.Longitude, oCastSource.Coordinates.Altitude); result.DrawGroundStick = oCastSource.Extrude; result.Rotation = WorldWind.Angle.FromDegrees(oCastSource.Style.NormalStyle.IconStyle.Heading); result.IsRotated = oCastSource.Style.NormalStyle.IconStyle.Heading != 0.0f; result.NormalColor = oCastSource.Style.NormalStyle.LabelStyle.Color; result.HotColor = oCastSource.Style.HighlightStyle.LabelStyle.Color; oIcons.Add(result); oBounds.Union(oCastSource.Coordinates.Longitude, oCastSource.Coordinates.Latitude, oCastSource.Coordinates.Altitude); return null; } else if (oSource is KMLPolygon) { KMLPolygon oCastSource = oSource as KMLPolygon; Polygon oTool = new Polygon(); oTool.outerBoundary = new WorldWind.LinearRing(GetPoints(oCastSource.OuterBoundary)); oTool.innerBoundaries = GetInnerBoundaries(oCastSource); oTool.PolgonColor = oCastSource.Style.NormalStyle.PolyStyle.Color; oTool.Fill = oCastSource.Style.NormalStyle.PolyStyle.Fill; oTool.LineWidth = oCastSource.Style.NormalStyle.LineStyle.Width; oTool.Outline = oCastSource.Style.NormalStyle.PolyStyle.Outline; oTool.OutlineColor = oCastSource.Style.NormalStyle.LineStyle.Color; oPVR.Add(oTool); oBounds.Union(oTool.GetGeographicBoundingBox()); return null; } else if (oSource is KMLLineString) { KMLLineString oCastSource = oSource as KMLLineString; LineString oTool = new LineString(); oTool.Coordinates = GetPoints(oCastSource); oTool.Color = oCastSource.Style.NormalStyle.LineStyle.Color; oTool.LineWidth = oCastSource.Style.NormalStyle.LineStyle.Width; oPVR.Add(oTool); oBounds.Union(oTool.GetGeographicBoundingBox()); return null; } else if (oSource is KMLGroundOverlay) { KMLGroundOverlay oCastSource = oSource as KMLGroundOverlay; KMLGroundOverlayRenderable result = new KMLGroundOverlayRenderable(oCastSource, strRelativeDirectory); oBounds.Union(new GeographicBoundingBox(oCastSource.LatLonBox.North, oCastSource.LatLonBox.South, oCastSource.LatLonBox.West, oCastSource.LatLonBox.East)); return result; } else { return null; } }
/// <summary> /// Do a search programmatically. /// </summary> /// <remarks> /// Doesn't update MRU list or supress repeated searches. /// </remarks> /// <param name="szKeywords"></param> /// <param name="oAoI"></param> private void doSearch(String szKeywords, GeographicBoundingBox oAoI) { SetSearchable(false); SetSearchClearable(true); m_oLastSearchROI = oAoI; m_szLastSearchString = szKeywords; applySearchCriteria(); }
internal ArcIMSQuadLayerBuilder(ArcIMSServerUri oServerUri, String strServiceName, String szLayerTitle, String szLayerID, GeographicBoundingBox oEnvelope, ArcIMSFeatureCoordSys oProjection, WorldWindow oWorldWindow, IBuilder oParent, double dMinScale, double dMaxScale, CultureInfo oInfo) : base(szLayerTitle, oWorldWindow, oParent) { m_oServerUri = oServerUri; m_oCultureInfo = oInfo; m_oUnprojectedEnvelope = oEnvelope; m_oProjection = oProjection; m_szLayerID = szLayerID; m_szServiceName = strServiceName; m_dMinScale = dMinScale; if (m_dMinScale < DefaultMinScale) m_dMinScale = DefaultMinScale; m_dMaxScale = dMaxScale; if (m_dMaxScale > DefaultMaxScale) m_dMaxScale = DefaultMaxScale; if (m_dMaxScale < m_dMinScale) { // --- Weird scale values, ignore them and hope for the best --- m_dMaxScale = DefaultMaxScale; m_dMinScale = DefaultMinScale; } CalculateLevels(); }
internal KMLLayerBuilder(String strFilename, WorldWindow oWorldWindow, IBuilder oParent, GeographicBoundingBox oBounds) : this(strFilename, Path.GetFileNameWithoutExtension(strFilename), oWorldWindow, oParent, oBounds) { }
internal MainForm(string strView, string strGeoTiff, string strGeotiffName, bool bGeotiffTmp, string strKMLFile, string strKMLName, bool blKMLTmp, string strLastView, Dapple.Extract.Options.Client.ClientType eClientType, RemoteInterface oMRI, GeographicBoundingBox oAoi, string strAoiCoordinateSystem, string strMapFileName) { if (String.Compare(Path.GetExtension(strView), ViewExt, true) == 0 && File.Exists(strView)) this.openView = strView; m_strOpenGeoTiffFile = strGeoTiff; m_strOpenGeoTiffName = strGeotiffName; m_blOpenGeoTiffTmp = bGeotiffTmp; m_strOpenKMLFile = strKMLFile; m_strOpenKMLName = strKMLName; m_blOpenKMLTmp = blKMLTmp; this.lastView = strLastView; s_oMontajRemoteInterface = oMRI; // Establish the version number string used for user display, // such as the Splash and Help->About screens. // To change the Application.ProductVersion make the // changes in \WorldWind\AssemblyInfo.cs // For alpha/beta versions, include " alphaN" or " betaN" // at the end of the format string. Version ver = new Version(Application.ProductVersion); Release = string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build); if (ver.Build % 2 != 0) Release += " (BETA)"; // Name the main thread. System.Threading.Thread.CurrentThread.Name = ThreadNames.EventDispatch; // Copy/Update any configuration files and other files if needed now CurrentSettingsDirectory = Path.Combine(UserPath, "Config"); Directory.CreateDirectory(CurrentSettingsDirectory); Settings.CachePath = Path.Combine(UserPath, "Cache"); Directory.CreateDirectory(Settings.CachePath); this.metaviewerDir = Path.Combine(UserPath, "Metadata"); Directory.CreateDirectory(this.metaviewerDir); string[] cfgFiles = Directory.GetFiles(Path.Combine(DirectoryPath, "Config"), "*.xml"); foreach (string strCfgFile in cfgFiles) { string strUserCfg = Path.Combine(CurrentSettingsDirectory, Path.GetFileName(strCfgFile)); if (!File.Exists(strUserCfg)) File.Copy(strCfgFile, strUserCfg); } string[] metaFiles = Directory.GetFiles(Path.Combine(Path.Combine(DirectoryPath, "Data"), "MetaViewer"), "*.*"); foreach (string strMetaFile in metaFiles) { string strUserMeta = Path.Combine(this.metaviewerDir, Path.GetFileName(strMetaFile)); File.Copy(strMetaFile, strUserMeta, true); } // --- Set up a new user's favorites list and home view --- /*if (!File.Exists(Path.Combine(CurrentSettingsDirectory, "user.dapple_serverlist"))) { File.Copy(Path.Combine(Path.Combine(DirectoryPath, "Data"), "default.dapple_serverlist"), Path.Combine(CurrentSettingsDirectory, "user.dapple_serverlist")); }*/ HomeView.CreateDefault(); InitSettings(); if (Settings.NewCachePath.Length > 0) { try { // We want to make sure the new cache path is writable Directory.CreateDirectory(Settings.NewCachePath); if (Directory.Exists(Settings.CachePath)) Utility.FileSystem.DeleteFolderGUI(this, Settings.CachePath, "Deleting Existing Cache"); Settings.CachePath = Settings.NewCachePath; } catch { } Settings.NewCachePath = ""; } if (Settings.ConfigurationWizardAtStartup) { Wizard frm = new Wizard(Settings); frm.ShowDialog(this); Settings.ConfigurationWizardAtStartup = false; } if (Settings.ConfigurationWizardAtStartup) { // If the settings file doesn't exist, then we are using the // default settings, and the default is to show the Configuration // Wizard at startup. We only want that to happen the first time // World Wind is started, so change the setting to false(the user // can change it to true if they want). if (!File.Exists(Settings.FileName)) { Settings.ConfigurationWizardAtStartup = false; } ConfigurationWizard.Wizard wizard = new ConfigurationWizard.Wizard(Settings); wizard.TopMost = true; wizard.ShowInTaskbar = true; wizard.ShowDialog(); // TODO: should settings be saved now, in case of program crashes, // and so that XML file on disk matches in-memory settings? } //#if !DEBUG using (this.splashScreen = new Splash()) { this.splashScreen.Owner = this; this.splashScreen.Show(); Application.DoEvents(); //#endif // --- setup the list of images used for the different datatypes --- s_oImageList.ColorDepth = ColorDepth.Depth32Bit; s_oImageList.ImageSize = new Size(16, 16); s_oImageList.TransparentColor = Color.Transparent; s_oImageList.Images.Add(EnabledServerIconKey, Resources.enserver); s_oImageList.Images.Add(DisabledServerIconKey, Resources.disserver); s_oImageList.Images.Add(OfflineServerIconKey, Resources.offline); s_oImageList.Images.Add(DapIconKey, Resources.dap); s_oImageList.Images.Add(DapDatabaseIconKey, Resources.dap_database); s_oImageList.Images.Add(DapDocumentIconKey, Resources.dap_document); s_oImageList.Images.Add(DapGridIconKey, Resources.dap_grid); s_oImageList.Images.Add(DapMapIconKey, Resources.dap_map); s_oImageList.Images.Add(DapPictureIconKey, Resources.dap_picture); s_oImageList.Images.Add(DapPointIconKey, Resources.dap_point); s_oImageList.Images.Add(DapSpfIconKey, Resources.dap_spf); s_oImageList.Images.Add(DapVoxelIconKey, Resources.dap_voxel); s_oImageList.Images.Add(FolderIconKey, Resources.folder); s_oImageList.Images.Add(DapArcGisIconKey, global::Dapple.Properties.Resources.dap_arcgis); s_oImageList.Images.Add(KmlIconKey, Resources.kml); s_oImageList.Images.Add(ErrorIconKey, global::Dapple.Properties.Resources.error); s_oImageList.Images.Add(LayerIconKey, global::Dapple.Properties.Resources.layer); s_oImageList.Images.Add(LiveMapsIconKey, global::Dapple.Properties.Resources.live); s_oImageList.Images.Add(TileIconKey, global::Dapple.Properties.Resources.tile); s_oImageList.Images.Add(GeorefImageIconKey, global::Dapple.Properties.Resources.georef_image); s_oImageList.Images.Add(WmsIconKey, Resources.wms); s_oImageList.Images.Add(ArcImsIconKey, global::Dapple.Properties.Resources.arcims); s_oImageList.Images.Add(BlueMarbleIconKey, Dapple.Properties.Resources.blue_marble); s_oImageList.Images.Add(DesktopCatalogerIconKey, Dapple.Properties.Resources.dcat); c_oWorldWindow = new WorldWindow(); #if !DEBUG Utility.AbortUtility.ProgramAborting += new MethodInvoker(c_oWorldWindow.KillD3DAndWorkerThread); #endif c_oWorldWindow.AllowDrop = true; c_oWorldWindow.DragOver += new DragEventHandler(c_oWorldWindow_DragOver); c_oWorldWindow.DragDrop += new DragEventHandler(c_oWorldWindow_DragDrop); c_oWorldWindow.Resize += new EventHandler(c_oWorldWindow_Resize); InitializeComponent(); this.SuspendLayout(); c_oLayerList.ImageList = s_oImageList; /*#if DEBUG // --- Make the server tree HOOGE --- this.splitContainerMain.SplitterDistance = 400; this.splitContainerLeftMain.SplitterDistance = 400; #endif*/ this.Icon = new System.Drawing.Icon(@"app.ico"); DappleToolStripRenderer oTSR = new DappleToolStripRenderer(); c_tsSearch.Renderer = oTSR; c_tsLayers.Renderer = oTSR; c_tsOverview.Renderer = oTSR; c_tsMetadata.Renderer = oTSR; c_tsNavigation.Renderer = new BorderlessToolStripRenderer(); // set Upper and Lower limits for Cache size control, in bytes long CacheUpperLimit = (long)Settings.CacheSizeGigaBytes * 1024L * 1024L * 1024L; long CacheLowerLimit = (long)Settings.CacheSizeGigaBytes * 768L * 1024L * 1024L; //75% of upper limit try { Directory.CreateDirectory(Settings.CachePath); } catch { // We get here when people used a cache drive that since dissappeared (e.g. USB flash) // Revert to default cache directory in this case Settings.CachePath = Path.Combine(UserPath, "Cache"); Directory.CreateDirectory(Settings.CachePath); } //Set up the cache c_oWorldWindow.Cache = new Cache( Settings.CachePath, CacheLowerLimit, CacheUpperLimit, Settings.CacheCleanupInterval, Settings.TotalRunTime); #region Plugin + World Init. WorldWind.Terrain.TerrainTileService terrainTileService = new WorldWind.Terrain.TerrainTileService("http://worldwind25.arc.nasa.gov/wwelevation/wwelevation.aspx", "srtm30pluszip", 20, 150, "bil", 12, Path.Combine(Settings.CachePath, "Earth\\TerrainAccessor\\SRTM"), TimeSpan.FromMinutes(30), "Int16"); WorldWind.Terrain.TerrainAccessor terrainAccessor = new WorldWind.Terrain.NltTerrainAccessor("SRTM", -180, -90, 180, 90, terrainTileService, null); WorldWind.World world = new WorldWind.World("Earth", new Point3d(0, 0, 0), Quaternion4d.RotationYawPitchRoll(0, 0, 0), (float)6378137, System.IO.Path.Combine(c_oWorldWindow.Cache.CacheDirectory, "Earth"), terrainAccessor); c_oWorldWindow.CurrentWorld = world; c_oWorldWindow.DrawArgs.WorldCamera.CameraChanged += new EventHandler(c_oWorldWindow_CameraChanged); string strPluginsDir = Path.Combine(DirectoryPath, "Plugins"); this.scalebarPlugin = new NASA.Plugins.ScaleBarLegend(); this.scalebarPlugin.PluginLoad(this, strPluginsDir); this.scalebarPlugin.IsVisible = World.Settings.ShowScaleBar; this.starsPlugin = new Stars3D.Plugin.Stars3D(); this.starsPlugin.PluginLoad(this, Path.Combine(strPluginsDir, "Stars3D")); this.compassPlugin = new Murris.Plugins.Compass(); this.compassPlugin.PluginLoad(this, Path.Combine(strPluginsDir, "Compass")); String szGlobalCloudsCacheDir = Path.Combine(Settings.CachePath, @"Plugins\GlobalClouds"); Directory.CreateDirectory(szGlobalCloudsCacheDir); String szGlobalCloudsPluginDir = Path.Combine(CurrentSettingsDirectory, @"Plugins\GlobalClouds"); Directory.CreateDirectory(szGlobalCloudsPluginDir); if (!File.Exists(Path.Combine(szGlobalCloudsPluginDir, Murris.Plugins.GlobalCloudsLayer.serverListFileName))) { File.Copy(Path.Combine(Path.Combine(strPluginsDir, "GlobalClouds"), Murris.Plugins.GlobalCloudsLayer.serverListFileName), Path.Combine(szGlobalCloudsPluginDir, Murris.Plugins.GlobalCloudsLayer.serverListFileName)); } this.cloudsPlugin = new Murris.Plugins.GlobalClouds(szGlobalCloudsCacheDir); this.cloudsPlugin.PluginLoad(this, szGlobalCloudsPluginDir); this.skyPlugin = new Murris.Plugins.SkyGradient(); this.skyPlugin.PluginLoad(this, Path.Combine(strPluginsDir, "SkyGradient")); this.threeDConnPlugin = new ThreeDconnexion.Plugin.TDxWWInput(); this.threeDConnPlugin.PluginLoad(this, Path.Combine(strPluginsDir, "3DConnexion")); ThreadPool.QueueUserWorkItem(LoadPlacenames); c_scWorldMetadata.Panel1.Controls.Add(c_oWorldWindow); c_oWorldWindow.Dock = DockStyle.Fill; #endregion float[] verticalExaggerationMultipliers = { 0.0f, 1.0f, 1.5f, 2.0f, 3.0f, 5.0f, 7.0f, 10.0f }; foreach (float multiplier in verticalExaggerationMultipliers) { ToolStripMenuItem curItem = new ToolStripMenuItem(multiplier.ToString("f1", System.Threading.Thread.CurrentThread.CurrentCulture) + "x", null, new EventHandler(menuItemVerticalExaggerationChange)); c_miVertExaggeration.DropDownItems.Add(curItem); curItem.CheckOnClick = true; if (Math.Abs(multiplier - World.Settings.VerticalExaggeration) < 0.1f) curItem.Checked = true; } this.c_miShowCompass.Checked = World.Settings.ShowCompass; this.c_miShowDLProgress.Checked = World.Settings.ShowDownloadIndicator; this.c_miShowCrosshair.Checked = World.Settings.ShowCrosshairs; this.c_miShowInfoOverlay.Checked = World.Settings.ShowPosition; this.c_miShowGridlines.Checked = World.Settings.ShowLatLonLines; this.c_miShowGlobalClouds.Checked = World.Settings.ShowClouds; if (World.Settings.EnableSunShading) { if (!World.Settings.SunSynchedWithTime) this.c_miSunshadingEnabled.Checked = true; else this.c_miSunshadingSync.Checked = true; } else this.c_miSunshadingDisabled.Checked = true; this.c_miShowAtmoScatter.Checked = World.Settings.EnableAtmosphericScattering; this.c_miAskLastViewAtStartup.Checked = Settings.AskLastViewAtStartup; if (!Settings.AskLastViewAtStartup) this.c_miOpenLastViewAtStartup.Checked = Settings.LastViewAtStartup; #region OverviewPanel // Fix: earlier versions of Dapple set the DataPath as an absolute reference, so if Dapple was uninstalled, OMapple could not find // the file for the overview control. To fix this, switch the variable to a relative reference if the absolute one doesn't resolve. // Dapple will still work; the relative reference will be from whatever directory Dapple is being run. if (!Directory.Exists(Settings.DataPath)) Settings.DataPath = "Data"; #endregion c_oWorldWindow.MouseEnter += new EventHandler(this.c_oWorldWindow_MouseEnter); c_oWorldWindow.MouseLeave += new EventHandler(this.c_oWorldWindow_MouseLeave); c_oOverview.AOISelected += new Overview.AOISelectedDelegate(c_oOverview_AOISelected); #region Search view setup this.c_oServerList = new ServerList(); m_oModel = new DappleModel(c_oLayerList); m_oModel.SelectedNodeChanged += new EventHandler(m_oModel_SelectedNodeChanged); c_oLayerList.Attach(m_oModel); NewServerTree.View.ServerTree newServerTree = new NewServerTree.View.ServerTree(); newServerTree.Attach(m_oModel); c_oServerList.Attach(m_oModel); c_oLayerList.LayerSelectionChanged += new EventHandler(c_oLayerList_LayerSelectionChanged); m_oMetadataDisplay = new MetadataDisplayThread(this); m_oMetadataDisplay.AddBuilder(null); c_oServerList.LayerList = c_oLayerList; c_oLayerList.GoTo += new LayerList.GoToHandler(this.GoTo); c_oLayerList.ViewMetadata += new ViewMetadataHandler(m_oMetadataDisplay.AddBuilder); c_oServerList.ViewMetadata += new ViewMetadataHandler(m_oMetadataDisplay.AddBuilder); c_oServerList.LayerSelectionChanged += new EventHandler(c_oServerList_LayerSelectionChanged); this.cServerViewsTab = new JanaTab(); this.cServerViewsTab.SetImage(0, Resources.tab_tree); this.cServerViewsTab.SetImage(1, Resources.tab_list); this.cServerViewsTab.SetToolTip(0, "Server tree view"); this.cServerViewsTab.SetToolTip(1, "Server list view"); this.cServerViewsTab.SetNameAndText(0, "TreeView"); this.cServerViewsTab.SetNameAndText(1, "ListView"); this.cServerViewsTab.SetPage(0, newServerTree); this.cServerViewsTab.SetPage(1, this.c_oServerList); cServerViewsTab.PageChanged += new JanaTab.PageChangedDelegate(ServerPageChanged); c_oDappleSearch = new DappleSearchList(); c_oDappleSearch.LayerSelectionChanged += new EventHandler(c_oDappleSearch_LayerSelectionChanged); c_oDappleSearch.Attach(m_oModel, c_oLayerList); c_tcSearchViews.TabPages[0].Controls.Add(cServerViewsTab); cServerViewsTab.Dock = DockStyle.Fill; c_tcSearchViews.TabPages[1].Controls.Add(c_oDappleSearch); c_oDappleSearch.Dock = DockStyle.Fill; c_oLayerList.SetBaseLayer(new BlueMarbleBuilder()); this.ResumeLayout(false); #endregion this.PerformLayout(); while (!this.splashScreen.IsDone) System.Threading.Thread.Sleep(50); // Force initial render to avoid showing random contents of frame buffer to user. c_oWorldWindow.Render(); WorldWindow.Focus(); #region OM Forked Process configuration if (IsRunningAsDapClient) { c_oLayerList.OMFeaturesEnabled = true; this.MinimizeBox = false; if (oAoi != null && !string.IsNullOrEmpty(strAoiCoordinateSystem)) { s_oOMMapExtentNative = oAoi; s_strAoiCoordinateSystem = strAoiCoordinateSystem; s_strOpenMapFileName = strMapFileName; s_oOMMapExtentWGS84 = s_oOMMapExtentNative.Clone() as GeographicBoundingBox; s_oMontajRemoteInterface.ProjectBoundingRectangle(strAoiCoordinateSystem, ref s_oOMMapExtentWGS84.West, ref s_oOMMapExtentWGS84.South, ref s_oOMMapExtentWGS84.East, ref s_oOMMapExtentWGS84.North, Dapple.Extract.Resolution.WGS_84); } s_eClientType = eClientType; c_miLastView.Enabled = false; c_miLastView.Visible = false; c_miDappleHelp.Visible = false; c_miDappleHelp.Enabled = false; toolStripSeparator10.Visible = false; c_miOpenImage.Visible = false; c_miOpenImage.Enabled = false; c_miOpenKeyhole.Visible = false; c_miOpenKeyhole.Enabled = false; // Hide and disable the file menu c_miFile.Visible = false; c_miFile.Enabled = false; c_miOpenSavedView.Visible = false; c_miOpenSavedView.Enabled = false; c_miOpenHomeView.Visible = false; c_miOpenHomeView.Enabled = false; c_miSetHomeView.Visible = false; c_miSetHomeView.Enabled = false; c_miSaveView.Visible = false; c_miSaveView.Enabled = false; c_miSendViewTo.Visible = false; c_miSendViewTo.Enabled = false; c_miOpenKeyhole.Visible = false; c_miOpenKeyhole.Enabled = false; // Show the OM help menu c_miGetDatahelp.Enabled = true; c_miGetDatahelp.Visible = true; // Don't let the user check for updates. EVER. c_miCheckForUpdates.Visible = false; c_miCheckForUpdates.Enabled = false; } else { c_miExtractLayers.Visible = false; c_miExtractLayers.Enabled = false; } #endregion loadCountryList(); populateAoiComboBox(); LoadMRUList(); CenterNavigationToolStrip(); //#if !DEBUG c_tbSearchKeywords.Text = NO_SEARCH; } //#endif }
public GeographicBoundingBox ReprojectToWGS84(ArcIMSServerUri uri, String serviceName, GeographicBoundingBox source) { if (IsWGS84) return source; if (!defined) return new GeographicBoundingBox(89.1, -89.1, -180, 180); if (source == null) return new GeographicBoundingBox(89.2, -89.2, -180, 180); ArcIMSReprojectDownload download = new ArcIMSReprojectDownload(uri, 0, source, this, serviceName); try { download.DownloadMemory(); XmlDocument response = new XmlDocument(); response.Load(download.ContentStream); return ProcessResponse(response); } catch (Exception) { return new GeographicBoundingBox(89.3, -89.3, -180, 180); } }
void GoTo(GeographicBoundingBox extents, bool blImmediate) { c_oWorldWindow.GoToBoundingBox(extents, blImmediate); }
private void doSearch() { // --- Cancel if the search parameters are unchanged --- GeographicBoundingBox oCurrSearchROI = GeographicBoundingBox.FromQuad(c_oWorldWindow.CurrentAreaOfInterest); String szCurrSearchString = SearchKeyword; if (oCurrSearchROI.Equals(m_oLastSearchROI) && szCurrSearchString.Equals(m_szLastSearchString)) return; // --- Reorder the MRU list. Supress index changed is important because removing the current MRU will raise the event again --- m_blSupressSearchSelectedIndexChanged = true; c_tbSearchKeywords.SuspendLayout(); if (!SearchKeyword.Equals(String.Empty)) { c_tbSearchKeywords.Items.Remove(szCurrSearchString); while (c_tbSearchKeywords.Items.Count >= MAX_MRU_TERMS) { c_tbSearchKeywords.Items.RemoveAt(c_tbSearchKeywords.Items.Count - 1); } c_tbSearchKeywords.Items.Insert(0, szCurrSearchString); c_tbSearchKeywords.Text = szCurrSearchString; } c_tbSearchKeywords.ResumeLayout(); m_blSupressSearchSelectedIndexChanged = false; // --- Mop up and move out --- SetSearchable(false); SetSearchClearable(true); m_oLastSearchROI = GeographicBoundingBox.FromQuad(c_oWorldWindow.CurrentAreaOfInterest); m_szLastSearchString = SearchKeyword; applySearchCriteria(); }
private GeographicBoundingBox ProcessResponse(XmlDocument document) { XmlElement envelopeElement = document.SelectSingleNode("/ARCXML/RESPONSE/PROJECT/ENVELOPE") as XmlElement; if (envelopeElement != null) { GeographicBoundingBox result = new GeographicBoundingBox(); bool success = true; success &= Double.TryParse(envelopeElement.GetAttribute("minx"), NumberStyles.Float, culture, out result.West); success &= Double.TryParse(envelopeElement.GetAttribute("miny"), NumberStyles.Float, culture, out result.South); success &= Double.TryParse(envelopeElement.GetAttribute("maxx"), NumberStyles.Float, culture, out result.East); success &= Double.TryParse(envelopeElement.GetAttribute("maxy"), NumberStyles.Float, culture, out result.North); if (success) return result; } return new GeographicBoundingBox(89.4, -89.4, -180, 180); }
/// <summary> /// This method Loads a shapefile /// </summary> /// <param name="shapeConfigFilePath">Full Path to the Shapefiles XML configuration file</param> /// <param name="checkForUpdate">true if it should check for a newer version of the shapefile</param> public void loadShapeFileWithAlreadyExistingXML(string shapeConfigFilePath, bool checkForUpdate) { //Check for updates if(checkForUpdate) { try { XmlDocument doc=new XmlDocument(); doc.Load(shapeConfigFilePath); string downloadURL; if((downloadURL=doc.SelectSingleNode("/LayerSet/DownloadPage/URL").InnerText)!="") { if(checkIfUpdateNeeded(downloadURL,shapeConfigFilePath)) { //Update xml+files UpdateXMLAndFiles(shapeConfigFilePath, downloadURL); } } } catch{} } XPathNavigator nav; XPathDocument docNav; // Open the XML. docNav = new XPathDocument(shapeConfigFilePath); // Create a navigator to query with XPath. nav = docNav.CreateNavigator(); XPathNodeIterator layersetIter = nav.Select("/LayerSet"); if(layersetIter.Count > 0) { while(layersetIter.MoveNext()) { string layersetName = layersetIter.Current.GetAttribute("Name",""); if(layersetName == null) continue; string showOnlyOneLayerString = layersetIter.Current.GetAttribute("ShowOnlyOneLayer", ""); string showAtStartupString = layersetIter.Current.GetAttribute("ShowAtStartup", ""); bool showOnlyOneLayer = false; bool showAtStartup = false; try { showOnlyOneLayer = ParseBool(showOnlyOneLayerString); } catch(Exception) { } try { showAtStartup = ParseBool(showAtStartupString); } catch{} WorldWind.Renderable.RenderableObjectList newLayerSetList = new RenderableObjectList(layersetName); newLayerSetList.ShowOnlyOneLayer = showOnlyOneLayer; newLayerSetList.ParentList = ParentApplication.WorldWindow.CurrentWorld.RenderableObjects; if(World.Settings.UseDefaultLayerStates) { newLayerSetList.IsOn = showAtStartup; } else { newLayerSetList.IsOn = ConfigurationLoader.IsLayerOn(newLayerSetList); } XPathNodeIterator shapeIter = layersetIter.Current.Select("ShapeFileDescriptor"); if(shapeIter.Count > 0) { while(shapeIter.MoveNext()) { string name = getInnerTextFromFirstChild(shapeIter.Current.Select("Name")); string shapeFilePath = getInnerTextFromFirstChild(shapeIter.Current.Select("ShapeFilePath")); string dataKey = getInnerTextFromFirstChild(shapeIter.Current.Select("DataKey")); string showLabelsString = getInnerTextFromFirstChild(shapeIter.Current.Select("ShowLabels")); string polygonFillString = getInnerTextFromFirstChild(shapeIter.Current.Select("PolygonFill")); string outlinePolygonsString = getInnerTextFromFirstChild(shapeIter.Current.Select("OutlinePolygons")); string lineWidthString = getInnerTextFromFirstChild(shapeIter.Current.Select("LineWidth")); string iconFilePath = getInnerTextFromFirstChild(shapeIter.Current.Select("IconFilePath")); string iconWidthString = getInnerTextFromFirstChild(shapeIter.Current.Select("IconWidth")); string iconHeightString = getInnerTextFromFirstChild(shapeIter.Current.Select("IconHeight")); string iconOpacityString = getInnerTextFromFirstChild(shapeIter.Current.Select("IconOpacity")); string scaleColorsToDataString = getInnerTextFromFirstChild(shapeIter.Current.Select("ScaleColorsToData")); /*Altitude Rendering*/ string maxAltString = getInnerTextFromFirstChild(shapeIter.Current.Select("MaxAltitude")); string minAltString = getInnerTextFromFirstChild(shapeIter.Current.Select("MinAltitude")); /*Tile Size Rendering*/ string lztsdString = getInnerTextFromFirstChild(shapeIter.Current.Select("LevelZeroTileSize")); /*LatLong Bounding Box*/ string northString = getInnerTextFromFirstChild(shapeIter.Current.Select("North")); string southString = getInnerTextFromFirstChild(shapeIter.Current.Select("South")); string eastString = getInnerTextFromFirstChild(shapeIter.Current.Select("East")); string westString = getInnerTextFromFirstChild(shapeIter.Current.Select("West")); /*Opacity added by Argon helm*/ string layerOpacityString = getInnerTextFromFirstChild(shapeIter.Current.Select("LayerOpacity")); bool showLabels = false; bool polygonFill = false; float lineWidth = 1.0f; bool outlinePolygons = false; bool scaleColorsToData = false; int iconWidth = 32; int iconHeight = 32; byte iconOpacity = 255; /*Layer Opacity added by Argon Helm*/ byte layerOpacity = 255; /*Altitude Rendering*/ double maxAlt = double.MaxValue; double minAlt = 0; /*Tile Size Rendering*/ float lztsd = 180.0f/5; /*LatLong Bounding Box*/ GeographicBoundingBox bounds = new GeographicBoundingBox(90.0,-90,-180.0,180.0); System.Drawing.Color lineColor = System.Drawing.Color.Black; System.Drawing.Color polygonColor = System.Drawing.Color.Black; System.Drawing.Color labelColor = System.Drawing.Color.White; WorldWind.ShapeFillStyle shapeFillStyle = getShapeFillStyleFromString(getInnerTextFromFirstChild(shapeIter.Current.Select("PolygonFillStyle"))); XPathNodeIterator lineColorIter = shapeIter.Current.Select("LineColor"); if(lineColorIter.Count > 0) { lineColor = getColorFromXPathIter(lineColorIter); } XPathNodeIterator polygonColorIter = shapeIter.Current.Select("PolygonColor"); if(polygonColorIter.Count > 0) { polygonColor = getColorFromXPathIter(polygonColorIter); } XPathNodeIterator labelColorIter = shapeIter.Current.Select("LabelColor"); if(labelColorIter.Count > 0) { labelColor = getColorFromXPathIter(labelColorIter); } showAtStartupString = shapeIter.Current.GetAttribute("ShowAtStartup",""); try { if(showAtStartupString != null) { showAtStartup = ParseBool(showAtStartupString); } else { showAtStartup = false; } if(scaleColorsToDataString != null) { scaleColorsToData = ParseBool(scaleColorsToDataString); } if(showLabelsString != null) { showLabels = ParseBool(showLabelsString); } if(polygonFillString != null) { polygonFill = ParseBool(polygonFillString); } if(lineWidthString != null) { lineWidth = float.Parse(lineWidthString); } if(outlinePolygonsString != null) { outlinePolygons = ParseBool(outlinePolygonsString); } if(iconHeightString != null) { iconHeight = int.Parse(iconHeightString); } if(iconWidthString != null) { iconWidth = int.Parse(iconWidthString); } if(iconOpacityString != null) { iconOpacity = byte.Parse(iconOpacityString); } /*Altitude Rendering*/ if(minAltString!=null) { minAlt=ParseDouble(minAltString); } if(maxAltString!=null) { maxAlt=ParseDouble(maxAltString); } /*Lztsd rendering*/ if(lztsdString!=null) { lztsd=float.Parse(lztsdString); } /*latlon bounds*/ if(northString!=null&&southString!=null&&westString!=null&&eastString!=null) { bounds = new GeographicBoundingBox(ParseDouble(northString), ParseDouble(southString), ParseDouble(westString), ParseDouble(eastString)); } /*Layer Opacity added by argon helm*/ if(layerOpacityString != null) { layerOpacity = byte.Parse(layerOpacityString); } } catch(Exception ex) { Log.Write(ex); } string scalarMinString = getInnerTextFromFirstChild(shapeIter.Current.Select("ScalarMin")); string scalarMaxString = getInnerTextFromFirstChild(shapeIter.Current.Select("ScalarMax")); string scalarFilterMinString = getInnerTextFromFirstChild(shapeIter.Current.Select("ScalarFilterMin")); string scalarFilterMaxString = getInnerTextFromFirstChild(shapeIter.Current.Select("ScalarFilterMax")); string[] noDataValues = getStringValues(shapeIter.Current.Select("NoDataValue")); string[] activeDataValues = getStringValues(shapeIter.Current.Select("ActiveDataValue")); double scalarMin = double.NaN; double scalarMax = double.NaN; double scalarFilterMin = double.NaN; double scalarFilterMax = double.NaN; if(scalarMinString != null) { scalarMin = ParseDouble(scalarMinString); } if(scalarMaxString != null) { scalarMax = ParseDouble(scalarMaxString); } if(scalarFilterMinString != null) { scalarFilterMin = ParseDouble(scalarFilterMinString); } if(scalarFilterMaxString != null) { scalarFilterMax = ParseDouble(scalarFilterMaxString); } /*if(!Path.IsPathRooted(shapeFilePath)) { shapeFilePath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\" + shapeFilePath; }*/ //path is relative to xml file not to executing apps directory if(!Path.IsPathRooted(shapeFilePath)) { shapeFilePath = shapeConfigFilePath.Remove( shapeConfigFilePath.LastIndexOfAny(new char[]{'\\','/'}), shapeConfigFilePath.Length- shapeConfigFilePath.LastIndexOfAny(new char[]{'\\','/'})) + "\\" + shapeFilePath; } WorldWind.ShapeFileLayer shapeFileLayer = new ShapeFileLayer( name, ParentApplication.WorldWindow.CurrentWorld, shapeFilePath, minAlt, maxAlt, lztsd, bounds, dataKey, scaleColorsToData, scalarFilterMin, scalarFilterMax, scalarMin, scalarMax, noDataValues, activeDataValues, polygonFill, outlinePolygons, polygonColor, shapeFillStyle, lineColor, lineWidth, showLabels, labelColor, Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\" + iconFilePath, iconWidth, iconHeight, iconOpacity ); /*Layer Opacity added by Argon Helm*/ shapeFileLayer.Opacity = layerOpacity; shapeFileLayer.ParentList = newLayerSetList; // this goes after opacity because setting opacity "turns on" a renderable object if(World.Settings.UseDefaultLayerStates) { shapeFileLayer.IsOn = showAtStartup; } else { shapeFileLayer.IsOn = ConfigurationLoader.IsLayerOn(shapeFileLayer); } if(shapeFilePath.ToLower().EndsWith(".shp")) { shapeFileLayer.dbfPath=Path.ChangeExtension(shapeFilePath,".dbf"); shapeFileLayer.dbfIsInZip=false; } else if(shapeFilePath.ToLower().EndsWith(".zip")) { shapeFileLayer.dbfIsInZip=true; shapeFileLayer.dbfPath=shapeFilePath; } newLayerSetList.Add(shapeFileLayer); } } ParentApplication.WorldWindow.CurrentWorld.RenderableObjects.Add(newLayerSetList); } } }
private GeographicBoundingBox GetNewBox(GeographicBoundingBox input, double dScale) { GeographicBoundingBox result = new GeographicBoundingBox( input.CenterLatitude + (input.North - input.CenterLatitude) * dScale, input.CenterLatitude + (input.South - input.CenterLatitude) * dScale, input.CenterLongitude + (input.West - input.CenterLongitude) * dScale, input.CenterLongitude + (input.East - input.CenterLongitude) * dScale ); //result.North = Math.Min(m_oGroundOverlay.LatLonBox.North, Math.Min(90.0, result.North)); //result.South = Math.Max(m_oGroundOverlay.LatLonBox.South, Math.Max(-90.0, result.South)); if (!WraparoundLayer) { //result.East = Math.Min(m_oGroundOverlay.LatLonBox.East, Math.Min(180.0, result.East)); //result.West = Math.Max(m_oGroundOverlay.LatLonBox.West, Math.Max(-180.0, result.West)); } else { if (result.Longitude > 360.0) { result.East = 180.0; result.West = -180.0; } } return result; }
private void c_oOverview_AOISelected(object sender, GeographicBoundingBox bounds) { GoTo(bounds, false); }
private void populateAoiComboBox() { // --- Create list of AoIs to assign to the drop-down list --- List<KeyValuePair<String, GeographicBoundingBox>> oAois = new List<KeyValuePair<string, GeographicBoundingBox>>(); // --- Get the currently active DAP server if there is one --- Server oSelectedDapServer = null; if (m_oModel.SelectedServer != null && m_oModel.SelectedServer is DapServerModelNode) { oSelectedDapServer = (m_oModel.SelectedServer as DapServerModelNode).Server; } bool blViableDapServer = oSelectedDapServer != null && oSelectedDapServer.Enabled && oSelectedDapServer.Status == Server.ServerStatus.OnLine; // --- Add header line --- oAois.Add(new KeyValuePair<String, GeographicBoundingBox>("--- Select a specific region ---", null)); // --- Add server extent if available --- if (blViableDapServer) { oAois.Add(new KeyValuePair<String, GeographicBoundingBox>("Server extent", new GeographicBoundingBox(oSelectedDapServer.ServerExtents.MaxY, oSelectedDapServer.ServerExtents.MinY, oSelectedDapServer.ServerExtents.MinX, oSelectedDapServer.ServerExtents.MaxX))); } // --- If we're FDWD, add the original map extents --- if (IsRunningAsDapClient && s_oOMMapExtentWGS84 != null) { oAois.Add(new KeyValuePair<String, GeographicBoundingBox>("Original map extent", s_oOMMapExtentWGS84)); } // --- Add divider --- oAois.Add(new KeyValuePair<String, GeographicBoundingBox>("-----------------------------", null)); // --- Add list of AoIs: // --- if we've selected an enabled, online DAP server, get its AoI list // --- otherwise, add the countries of the world AoI list if (blViableDapServer) { ArrayList aAOIs = oSelectedDapServer.ServerConfiguration.GetAreaList(); foreach (String strAOI in aAOIs) { double minX, minY, maxX, maxY; String strCoord; oSelectedDapServer.ServerConfiguration.GetBoundingBox(strAOI, out maxX, out maxY, out minX, out minY, out strCoord); if (strCoord.Equals("WGS 84")) { GeographicBoundingBox oBox = new GeographicBoundingBox(maxY, minY, minX, maxX); oAois.Add(new KeyValuePair<String, GeographicBoundingBox>(strAOI, oBox)); } } } else { foreach (KeyValuePair<String, GeographicBoundingBox> country in m_oCountryAOIs) { oAois.Add(country); } } c_oOverview.SetAOIList(oAois); }
/// <summary> /// Extracts all the currently selected datasets (including blue marble). /// </summary> internal void CmdTakeSnapshot() { string szGeoTiff = null; List<ExportEntry> aExportList = new List<ExportEntry>(); // Gather info first foreach (LayerBuilder oBuilder in this.AllLayers) { if (oBuilder.Visible) { RenderableObject oRObj = oBuilder.GetLayer(); if (oRObj != null) { RenderableObject.ExportInfo oExportInfo = new RenderableObject.ExportInfo(); oRObj.InitExportInfo(MainForm.WorldWindowSingleton.DrawArgs, oExportInfo); if (oExportInfo.iPixelsX > 0 && oExportInfo.iPixelsY > 0) aExportList.Add(new ExportEntry(oBuilder, oRObj, oExportInfo)); } } } if (aExportList.Count == 0) { Program.ShowMessageBox( "There are no visible layers to export.", "Create GeoTIFF Snapshot", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Warning); return; } // Reverse the list to do render order right aExportList.Reverse(); if (DownloadsInProgress) { Program.ShowMessageBox( "It is not possible to create a snapshot while Dapple is downloading tiles for visible data layers.\nPlease wait for tile downloading to complete and try again.", "Create GeoTIFF Snapshot", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Warning); return; } WorldWind.Camera.MomentumCamera camera = MainForm.WorldWindowSingleton.DrawArgs.WorldCamera as WorldWind.Camera.MomentumCamera; if (camera.Tilt.Degrees > 5.0) { Program.ShowMessageBox( "It is not possible to create a snapshot of a tilted view.\nPlease reset the tilt using the navigation buttons and try again.", "Create GeoTIFF Snapshot", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Warning); return; } try { ExportView oExportDialog = null; if (MainForm.MontajInterface != null) { try { oExportDialog = new ExportView(Path.Combine(MainForm.UserPath, MainApplication.Settings.ConfigPath), MainForm.MontajInterface.BaseDirectory()); } catch (System.Runtime.Remoting.RemotingException) { oExportDialog = new ExportView(Path.Combine(MainForm.UserPath, MainApplication.Settings.ConfigPath)); } } else { oExportDialog = new ExportView(Path.Combine(MainForm.UserPath, MainApplication.Settings.ConfigPath)); } if (oExportDialog.ShowDialog(this) == DialogResult.OK) { String szFilename = Path.ChangeExtension(oExportDialog.FullFileName, ".tif"); // --- Delete all the files that OM generates, so we don't get invalid projections --- if (System.IO.File.Exists(szFilename)) System.IO.File.Delete(szFilename); if (System.IO.File.Exists(System.IO.Path.ChangeExtension(szFilename, ".ipj"))) System.IO.File.Delete(System.IO.Path.ChangeExtension(szFilename, ".ipj")); if (System.IO.File.Exists(System.IO.Path.ChangeExtension(szFilename, ".gi"))) System.IO.File.Delete(System.IO.Path.ChangeExtension(szFilename, ".gi")); if (System.IO.File.Exists(System.IO.Path.ChangeExtension(szFilename, ".tif.xml"))) System.IO.File.Delete(System.IO.Path.ChangeExtension(szFilename, ".tif.xml")); Cursor = Cursors.WaitCursor; // Stop the camera camera.SetPosition(camera.Latitude.Degrees, camera.Longitude.Degrees, camera.Heading.Degrees, camera.Altitude, camera.Tilt.Degrees); // Determine output parameters GeographicBoundingBox oViewedArea = GeographicBoundingBox.FromQuad(MainForm.WorldWindowSingleton.CurrentAreaOfInterest); int iExportPixelsX, iExportPixelsY; // Minimize the estimated extents to what is available double dMinX = double.MaxValue; double dMaxX = double.MinValue; double dMinY = double.MaxValue; double dMaxY = double.MinValue; foreach (ExportEntry oExportEntry in aExportList) { dMaxY = Math.Max(dMaxY, oExportEntry.Info.dMaxLat); dMinY = Math.Min(dMinY, oExportEntry.Info.dMinLat); dMaxX = Math.Max(dMaxX, oExportEntry.Info.dMaxLon); dMinX = Math.Min(dMinX, oExportEntry.Info.dMinLon); } GeographicBoundingBox oExtractArea = new GeographicBoundingBox(dMaxY, dMinY, dMinX, dMaxX); oViewedArea.East = Math.Min(oViewedArea.East, oExtractArea.East); oViewedArea.North = Math.Min(oViewedArea.North, oExtractArea.North); oViewedArea.West = Math.Max(oViewedArea.West, oExtractArea.West); oViewedArea.South = Math.Max(oViewedArea.South, oExtractArea.South); // Determine the maximum resolution based on the highest res in layers double dPixelsPerDegree = -1; foreach (ExportEntry oExportEntry in aExportList) { double dXRes = (double)oExportEntry.Info.iPixelsX / (oExportEntry.Info.dMaxLon - oExportEntry.Info.dMinLon); double dYRes = (double)oExportEntry.Info.iPixelsY / (oExportEntry.Info.dMaxLat - oExportEntry.Info.dMinLat); dPixelsPerDegree = Math.Max(dPixelsPerDegree, Math.Max(dXRes, dYRes)); } double dMaxPixelsPerDegree = Math.Sqrt((5120 * 2560) / (oViewedArea.Latitude * oViewedArea.Longitude)); if (dPixelsPerDegree > dMaxPixelsPerDegree) dPixelsPerDegree = dMaxPixelsPerDegree; iExportPixelsX = (int)(oViewedArea.Longitude * dPixelsPerDegree); iExportPixelsY = (int)(oViewedArea.Latitude * dPixelsPerDegree); // Make geotiff metadata file to use for georeferencing images szGeoTiff = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); using (StreamWriter sw = new StreamWriter(szGeoTiff, false)) { sw.WriteLine("Geotiff_Information:"); sw.WriteLine("Version: 1"); sw.WriteLine("Key_Revision: 1.0"); sw.WriteLine("Tagged_Information:"); sw.WriteLine("ModelTiepointTag (2,3):"); sw.WriteLine("0 0 0"); sw.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} {1} {2}", oViewedArea.West, oViewedArea.North, 0)); sw.WriteLine("ModelPixelScaleTag (1,3):"); sw.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} {1} {2}", (oViewedArea.East - oViewedArea.West) / (double)iExportPixelsX, (oViewedArea.North - oViewedArea.South) / (double)iExportPixelsY, 0)); sw.WriteLine("End_Of_Tags."); sw.WriteLine("Keyed_Information:"); sw.WriteLine("GTModelTypeGeoKey (Short,1): ModelTypeGeographic"); sw.WriteLine("GTRasterTypeGeoKey (Short,1): RasterPixelIsArea"); sw.WriteLine("GeogAngularUnitsGeoKey (Short,1): Angular_Degree"); sw.WriteLine("GeographicTypeGeoKey (Short,1): GCS_WGS_84"); sw.WriteLine("End_Of_Keys."); sw.WriteLine("End_Of_Geotiff."); } // Export image(s) try { using (Bitmap oExportedImage = new Bitmap(iExportPixelsX, iExportPixelsY)) { using (Graphics oEIGraphics = Graphics.FromImage(oExportedImage)) { oEIGraphics.FillRectangle(Brushes.White, new Rectangle(0, 0, iExportPixelsX, iExportPixelsY)); foreach (ExportEntry oExportEntry in aExportList) { // Clip layer export to viewed area if (oExportEntry.Info.dMinLon < oViewedArea.West) oExportEntry.Info.dMinLon = oViewedArea.West; if (oExportEntry.Info.dMaxLon > oViewedArea.East) oExportEntry.Info.dMaxLon = oViewedArea.East; if (oExportEntry.Info.dMinLat < oViewedArea.South) oExportEntry.Info.dMinLat = oViewedArea.South; if (oExportEntry.Info.dMaxLat > oViewedArea.North) oExportEntry.Info.dMaxLat = oViewedArea.North; // Re-scale pixels oExportEntry.Info.iPixelsX = (int)((oExportEntry.Info.dMaxLon - oExportEntry.Info.dMinLon) * dPixelsPerDegree); oExportEntry.Info.iPixelsY = (int)((oExportEntry.Info.dMaxLat - oExportEntry.Info.dMinLat) * dPixelsPerDegree); // Cancel if the layer doesn't intersect the viewed area if (oExportEntry.Info.iPixelsX < 0 || oExportEntry.Info.iPixelsY < 0) continue; try { using (Bitmap oLayerImage = new Bitmap(oExportEntry.Info.iPixelsX, oExportEntry.Info.iPixelsY)) { int iOffsetX, iOffsetY; int iWidth, iHeight; using (oExportEntry.Info.gr = Graphics.FromImage(oLayerImage)) oExportEntry.RO.ExportProcess(MainForm.WorldWindowSingleton.DrawArgs, oExportEntry.Info); iOffsetX = (int)Math.Round((oExportEntry.Info.dMinLon - oViewedArea.West) * (double)iExportPixelsX / (oViewedArea.East - oViewedArea.West)); iOffsetY = (int)Math.Round((oViewedArea.North - oExportEntry.Info.dMaxLat) * (double)iExportPixelsY / (oViewedArea.North - oViewedArea.South)); iWidth = oExportEntry.Info.iPixelsX; iHeight = oExportEntry.Info.iPixelsY; ImageAttributes imgAtt = new ImageAttributes(); float[][] fMat = { new float[] {1.0f, 0.0f, 0.0f, 0.0f, 0.0f}, new float[] {0.0f, 1.0f, 0.0f, 0.0f, 0.0f}, new float[] {0.0f, 0.0f, 1.0f, 0.0f, 0.0f}, new float[] {0.0f, 0.0f, 0.0f, (float)oExportEntry.Container.Opacity/255.0f, 0.0f}, new float[] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f} }; ColorMatrix clrMatrix = new ColorMatrix(fMat); imgAtt.SetColorMatrix(clrMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); oEIGraphics.DrawImage(oLayerImage, new Rectangle(iOffsetX, iOffsetY, iWidth, iHeight), 0, 0, oExportEntry.Info.iPixelsX, oExportEntry.Info.iPixelsY, GraphicsUnit.Pixel, imgAtt); } } catch (System.ArgumentException) { String szLayers = String.Empty; foreach (LayerBuilder oBuilder in this.AllLayers) { szLayers += "\"" + oBuilder.Title + "\"" + ", "; } throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "Error creating layer image for snapshot. Width[{0}] Height[{1}] Bounds[{2}] Layers[{3}]", oExportEntry.Info.iPixelsX, oExportEntry.Info.iPixelsY, oViewedArea.ToString(), szLayers)); } } } SaveGeoImage(oExportedImage, szFilename, szGeoTiff); } } catch (System.ArgumentException) { String szLayers = String.Empty; foreach (LayerBuilder oBuilder in this.AllLayers) { szLayers += "\"" + oBuilder.Title + "\"" + ", "; } throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "Error creating layer image for snapshot. Width[{0}] Height[{1}] Bounds[{2}] Layers[{3}]", iExportPixelsX, iExportPixelsY, oViewedArea.ToString(), szLayers)); } Program.ShowMessageBox( "GeoTIFF snapshot created.", "Create GeoTIFF Snapshot", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Information); } } finally { if (szGeoTiff != null && File.Exists(szGeoTiff)) File.Delete(szGeoTiff); Cursor = Cursors.Default; } }