private void OnWcsLoad(WcsImage wcsImage) { int width = (int)wcsImage.SizeX; int height = (int)wcsImage.SizeY; Imageset imageset = Imageset.Create( wcsImage.Description, Util.GetHashCode(wcsImage.Filename).ToString(), ImageSetType.Sky, BandPass.Visible, ProjectionType.SkyImage, Util.GetHashCode(wcsImage.Filename), 0, 0, 256, wcsImage.ScaleY, ".tif", wcsImage.ScaleX > 0, "", wcsImage.CenterX, wcsImage.CenterY, wcsImage.Rotation, false, "", false, false, 1, wcsImage.ReferenceX, wcsImage.ReferenceY, wcsImage.Copyright, wcsImage.CreditsUrl, "", "", 0, "" ); imageset.WcsImage = wcsImage; LayerManager.AddImageSetLayer(imageset, LayerManager.GetNextFitsName()); LayerManager.LoadTree(); WWTControl.Singleton.GotoRADecZoom(wcsImage.CenterX / 15, wcsImage.CenterY, 10 * wcsImage.ScaleY * height, false); }
public static Imageset FromXMLNode(XmlNode node) { try { ImageSetType type = ImageSetType.Sky; ProjectionType projection = ProjectionType.Tangent; if (node.Attributes.GetNamedItem("DataSetType") != null) { type = (ImageSetType)Enums.Parse("ImageSetType", node.Attributes.GetNamedItem("DataSetType").Value); } BandPass bandPass = BandPass.Visible; bandPass = (BandPass)Enums.Parse("BandPass", node.Attributes.GetNamedItem("BandPass").Value); int wf = 1; if (node.Attributes.GetNamedItem("WidthFactor") != null) { wf = int.Parse(node.Attributes.GetNamedItem("WidthFactor").Value); } if (node.Attributes.GetNamedItem("Generic") == null || !bool.Parse(node.Attributes.GetNamedItem("Generic").Value.ToString())) { projection = (ProjectionType)Enums.Parse("ProjectionType", node.Attributes.GetNamedItem("Projection").Value); string fileType = node.Attributes.GetNamedItem("FileType").Value.ToString(); if (!fileType.StartsWith(".")) { fileType = "." + fileType; } string thumbnailUrl = ""; XmlNode thumbUrl = Util.SelectSingleNode(node, "ThumbnailUrl"); if (thumbUrl != null) { if (string.IsNullOrEmpty(thumbUrl.InnerText)) { ChromeNode cn = (ChromeNode)(object)thumbUrl; thumbnailUrl = cn.TextContent; } else { thumbnailUrl = thumbUrl.InnerText; } } bool stockSet = false; bool elevationModel = false; if (node.Attributes.GetNamedItem("StockSet") != null) { stockSet = bool.Parse(node.Attributes.GetNamedItem("StockSet").Value.ToString()); } if (node.Attributes.GetNamedItem("ElevationModel") != null) { elevationModel = bool.Parse(node.Attributes.GetNamedItem("ElevationModel").Value.ToString()); } string demUrl = ""; if (node.Attributes.GetNamedItem("DemUrl") != null) { demUrl = node.Attributes.GetNamedItem("DemUrl").Value.ToString(); } string alturl = ""; if (node.Attributes.GetNamedItem("AltUrl") != null) { alturl = node.Attributes.GetNamedItem("AltUrl").Value.ToString(); } double offsetX = 0; if (node.Attributes.GetNamedItem("OffsetX") != null) { offsetX = double.Parse(node.Attributes.GetNamedItem("OffsetX").Value.ToString()); } double offsetY = 0; if (node.Attributes.GetNamedItem("OffsetY") != null) { offsetY = double.Parse(node.Attributes.GetNamedItem("OffsetY").Value.ToString()); } string creditText = ""; XmlNode credits = Util.SelectSingleNode(node, "Credits"); if (credits != null) { creditText = Util.GetInnerText(credits); } string creditsUrl = ""; credits = Util.SelectSingleNode(node, "CreditsUrl"); if (credits != null) { creditsUrl = Util.GetInnerText(credits); } double meanRadius = 0; if (node.Attributes.GetNamedItem("MeanRadius") != null) { meanRadius = double.Parse(node.Attributes.GetNamedItem("MeanRadius").Value.ToString()); } string referenceFrame = null; if (node.Attributes.GetNamedItem("ReferenceFrame") != null) { referenceFrame = node.Attributes.GetNamedItem("ReferenceFrame").Value; } string name = ""; if (node.Attributes.GetNamedItem("Name") != null) { name = node.Attributes.GetNamedItem("Name").Value.ToString(); } string url = ""; if (node.Attributes.GetNamedItem("Url") != null) { url = node.Attributes.GetNamedItem("Url").Value.ToString(); } int baseTileLevel = 0; if (node.Attributes.GetNamedItem("BaseTileLevel") != null) { baseTileLevel = int.Parse(node.Attributes.GetNamedItem("BaseTileLevel").Value.ToString()); } int tileLevels = 0; if (node.Attributes.GetNamedItem("TileLevels") != null) { tileLevels = int.Parse(node.Attributes.GetNamedItem("TileLevels").Value.ToString()); } double baseDegreesPerTile = 0; if (node.Attributes.GetNamedItem("BaseDegreesPerTile") != null) { baseDegreesPerTile = double.Parse(node.Attributes.GetNamedItem("BaseDegreesPerTile").Value.ToString()); } bool bottomsUp = false; if (node.Attributes.GetNamedItem("BottomsUp") != null) { bottomsUp = bool.Parse(node.Attributes.GetNamedItem("BottomsUp").Value.ToString()); } string quadTreeMap = ""; if (node.Attributes.GetNamedItem("QuadTreeMap") != null) { quadTreeMap = node.Attributes.GetNamedItem("QuadTreeMap").Value.ToString(); } double centerX = 0; if (node.Attributes.GetNamedItem("CenterX") != null) { centerX = double.Parse(node.Attributes.GetNamedItem("CenterX").Value.ToString()); } double centerY = 0; if (node.Attributes.GetNamedItem("CenterY") != null) { centerY = double.Parse(node.Attributes.GetNamedItem("CenterY").Value.ToString()); } double rotation = 0; if (node.Attributes.GetNamedItem("Rotation") != null) { rotation = double.Parse(node.Attributes.GetNamedItem("Rotation").Value.ToString()); } bool sparse = false; if (node.Attributes.GetNamedItem("Sparse") != null) { sparse = bool.Parse(node.Attributes.GetNamedItem("Sparse").Value.ToString()); } return(Imageset.Create(name, url, type, bandPass, projection, Math.Abs(Util.GetHashCode(url)), baseTileLevel, tileLevels, 256, baseDegreesPerTile, fileType, bottomsUp, quadTreeMap, centerX, centerY, rotation, sparse, thumbnailUrl, stockSet, elevationModel, wf, offsetX, offsetY, creditText, creditsUrl, demUrl, alturl, meanRadius, referenceFrame)); } else { return(Imageset.CreateGeneric(type, bandPass)); } } catch { return(null); } }
public ImageSetLayer LoadFitsLayer(string url, string name, bool gotoTarget, ImagesetLoaded loaded) { if (string.IsNullOrWhiteSpace(name)) { name = LayerManager.GetNextFitsName(); } ImageSetLayer imagesetLayer = new ImageSetLayer(); FitsImage img = new FitsImage(url, null, delegate(WcsImage wcsImage) { int width = (int)wcsImage.SizeX; int height = (int)wcsImage.SizeY; Imageset imageset = Imageset.Create( wcsImage.Description, Util.GetHashCode(wcsImage.Filename).ToString(), ImageSetType.Sky, BandPass.Visible, ProjectionType.SkyImage, Util.GetHashCode(wcsImage.Filename), 0, 0, 256, wcsImage.ScaleY, ".tif", wcsImage.ScaleX > 0, "", wcsImage.CenterX, wcsImage.CenterY, wcsImage.Rotation, false, "", false, false, 1, wcsImage.ReferenceX, wcsImage.ReferenceY, wcsImage.Copyright, wcsImage.CreditsUrl, "", "", 0, "" ); imageset.WcsImage = wcsImage; imagesetLayer.ImageSet = imageset; LayerManager.AddFitsImageSetLayer(imagesetLayer, name); LayerManager.LoadTree(); if (gotoTarget) { WWTControl.Singleton.GotoRADecZoom(wcsImage.CenterX / 15, wcsImage.CenterY, 10 * wcsImage.ScaleY * height, false); } if (loaded != null) { loaded(imagesetLayer); } }); return(imagesetLayer); }
public static Imageset FromXMLNode(XmlNode node) { try { ImageSetType type = ImageSetType.Sky; ProjectionType projection = ProjectionType.Tangent; if (node.Attributes.GetNamedItem("DataSetType") != null) { switch (node.Attributes.GetNamedItem("DataSetType").Value.ToLowerCase()) { case "earth": type = ImageSetType.Earth; break; case "planet": type = ImageSetType.Planet; break; case "sky": type = ImageSetType.Sky; break; case "panorama": type = ImageSetType.Panorama; break; case "solarsystem": type = ImageSetType.SolarSystem; break; } } BandPass bandPass = BandPass.Visible; switch (node.Attributes.GetNamedItem("BandPass").Value) { case "Gamma": bandPass = BandPass.Gamma; break; case "XRay": bandPass = BandPass.XRay; break; case "Ultraviolet": bandPass = BandPass.Ultraviolet; break; case "Visible": bandPass = BandPass.Visible; break; case "HydrogenAlpha": bandPass = BandPass.HydrogenAlpha; break; case "IR": bandPass = BandPass.IR; break; case "Microwave": bandPass = BandPass.Microwave; break; case "Radio": bandPass = BandPass.Radio; break; case "VisibleNight": bandPass = BandPass.VisibleNight; break; default: break; } int wf = 1; if (node.Attributes.GetNamedItem("WidthFactor") != null) { wf = int.Parse(node.Attributes.GetNamedItem("WidthFactor").Value); } if (node.Attributes.GetNamedItem("Generic") == null || !bool.Parse(node.Attributes.GetNamedItem("Generic").Value.ToString())) { switch (node.Attributes.GetNamedItem("Projection").Value.ToString().ToLowerCase()) { case "tan": case "tangent": projection = ProjectionType.Tangent; break; case "mercator": projection = ProjectionType.Mercator; break; case "equirectangular": projection = ProjectionType.Equirectangular; break; case "toast": projection = ProjectionType.Toast; break; case "spherical": projection = ProjectionType.Spherical; break; case "plotted": projection = ProjectionType.Plotted; break; case "skyimage": projection = ProjectionType.SkyImage; break; } string fileType = node.Attributes.GetNamedItem("FileType").Value.ToString(); if (!fileType.StartsWith(".")) { fileType = "." + fileType; } string thumbnailUrl = ""; XmlNode thumbUrl = Util.SelectSingleNode(node, "ThumbnailUrl"); if (thumbUrl != null) { if (string.IsNullOrEmpty(thumbUrl.InnerText)) { ChromeNode cn = (ChromeNode)(object)thumbUrl; thumbnailUrl = cn.TextContent; } else { thumbnailUrl = thumbUrl.InnerText; } } bool stockSet = false; bool elevationModel = false; if (node.Attributes.GetNamedItem("StockSet") != null) { stockSet = bool.Parse(node.Attributes.GetNamedItem("StockSet").Value.ToString()); } if (node.Attributes.GetNamedItem("ElevationModel") != null) { elevationModel = bool.Parse(node.Attributes.GetNamedItem("ElevationModel").Value.ToString()); } string demUrl = ""; if (node.Attributes.GetNamedItem("DemUrl") != null) { demUrl = node.Attributes.GetNamedItem("DemUrl").Value.ToString(); } string alturl = ""; if (node.Attributes.GetNamedItem("AltUrl") != null) { alturl = node.Attributes.GetNamedItem("AltUrl").Value.ToString(); } double offsetX = 0; if (node.Attributes.GetNamedItem("OffsetX") != null) { offsetX = double.Parse(node.Attributes.GetNamedItem("OffsetX").Value.ToString()); } double offsetY = 0; if (node.Attributes.GetNamedItem("OffsetY") != null) { offsetY = double.Parse(node.Attributes.GetNamedItem("OffsetY").Value.ToString()); } string creditText = ""; XmlNode credits = Util.SelectSingleNode(node, "Credits"); if (credits != null) { creditText = Util.GetInnerText(credits); } string creditsUrl = ""; credits = Util.SelectSingleNode(node, "CreditsUrl"); if (credits != null) { creditsUrl = Util.GetInnerText(credits); } double meanRadius = 0; if (node.Attributes.GetNamedItem("MeanRadius") != null) { meanRadius = double.Parse(node.Attributes.GetNamedItem("MeanRadius").Value.ToString()); } string referenceFrame = null; if (node.Attributes.GetNamedItem("ReferenceFrame") != null) { referenceFrame = node.Attributes.GetNamedItem("ReferenceFrame").Value; } string name = ""; if (node.Attributes.GetNamedItem("Name") != null) { name = node.Attributes.GetNamedItem("Name").Value.ToString(); } string url = ""; if (node.Attributes.GetNamedItem("Url") != null) { url = node.Attributes.GetNamedItem("Url").Value.ToString(); } int baseTileLevel = 0; if (node.Attributes.GetNamedItem("BaseTileLevel") != null) { baseTileLevel = int.Parse(node.Attributes.GetNamedItem("BaseTileLevel").Value.ToString()); } int tileLevels = 0; if (node.Attributes.GetNamedItem("TileLevels") != null) { tileLevels = int.Parse(node.Attributes.GetNamedItem("TileLevels").Value.ToString()); } double baseDegreesPerTile = 0; if (node.Attributes.GetNamedItem("BaseDegreesPerTile") != null) { baseDegreesPerTile = double.Parse(node.Attributes.GetNamedItem("BaseDegreesPerTile").Value.ToString()); } bool bottomsUp = false; if (node.Attributes.GetNamedItem("BottomsUp") != null) { bottomsUp = bool.Parse(node.Attributes.GetNamedItem("BottomsUp").Value.ToString()); } string quadTreeMap = ""; if (node.Attributes.GetNamedItem("QuadTreeMap") != null) { quadTreeMap = node.Attributes.GetNamedItem("QuadTreeMap").Value.ToString(); } double centerX = 0; if (node.Attributes.GetNamedItem("CenterX") != null) { centerX = double.Parse(node.Attributes.GetNamedItem("CenterX").Value.ToString()); } double centerY = 0; if (node.Attributes.GetNamedItem("CenterY") != null) { centerY = double.Parse(node.Attributes.GetNamedItem("CenterY").Value.ToString()); } double rotation = 0; if (node.Attributes.GetNamedItem("Rotation") != null) { rotation = double.Parse(node.Attributes.GetNamedItem("Rotation").Value.ToString()); } bool sparse = false; if (node.Attributes.GetNamedItem("Sparse") != null) { sparse = bool.Parse(node.Attributes.GetNamedItem("Sparse").Value.ToString()); } return(Imageset.Create(name, url, type, bandPass, projection, Math.Abs(Util.GetHashCode(url)), baseTileLevel, tileLevels, 256, baseDegreesPerTile, fileType, bottomsUp, quadTreeMap, centerX, centerY, rotation, sparse, thumbnailUrl, stockSet, elevationModel, wf, offsetX, offsetY, creditText, creditsUrl, demUrl, alturl, meanRadius, referenceFrame)); } else { return(Imageset.CreateGeneric(type, bandPass)); } } catch { return(null); } }