예제 #1
0
        public double GetScaledAltitudeForLatLong(double viewLat, double viewLong)
        {
            Imageset layer = BackgroundImageset;

            if (layer == null)
            {
                return(0);
            }

            int maxX = GetTilesXForLevel(layer, layer.BaseLevel);
            int maxY = GetTilesYForLevel(layer, layer.BaseLevel);

            for (int x = 0; x < maxX; x++)
            {
                for (int y = 0; y < maxY; y++)
                {
                    Tile tile = TileCache.GetTile(layer.BaseLevel, x, y, layer, null);
                    if (tile != null)
                    {
                        if (tile.IsPointInTile(viewLat, viewLong))
                        {
                            return(tile.GetSurfacePointAltitude(viewLat, viewLong, false));
                        }
                    }
                }
            }
            return(0);
        }
예제 #2
0
 public ImageSetLayer AddImageSetLayer(string url, string mode, string name, bool gotoTarget, ImagesetLoaded loaded)
 {
     if (mode != null && mode.ToLowerCase() == "fits")
     {
         return(AddFitsLayer(url, name, gotoTarget, loaded));
     }
     else if (mode != null && mode.ToLowerCase() == "preloaded")
     {
         Imageset imageset = WWTControl.Singleton.GetImageSetByUrl(url);
         if (imageset != null)
         {
             return(AddImageSet(name, gotoTarget, loaded, imageset));
         }
     }
     else
     {
         Imageset imageset = WWTControl.Singleton.GetImageSetByUrl(url);
         if (imageset != null)
         {
             return(AddImageSet(name, gotoTarget, loaded, imageset));
         }
         else if (ContainsFitsLikeExtentsion(url))
         {
             return(AddFitsLayer(url, name, gotoTarget, loaded));
         }
     }
     return(null);
 }
예제 #3
0
        public static Imageset CreateGeneric(ImageSetType dataSetType, BandPass bandPass)
        {
            Imageset temp = new Imageset();

            temp.generic         = true;
            temp.name            = "Generic";
            temp.sparse          = false;
            temp.dataSetType     = dataSetType;
            temp.bandPass        = bandPass;
            temp.quadTreeTileMap = "";
            temp.url             = "";
            temp.levels          = 0;
            temp.baseTileDegrees = 0;
            temp.imageSetID      = 0;
            temp.extension       = "";
            temp.projection      = ProjectionType.Equirectangular;
            temp.bottomsUp       = false;
            temp.baseLevel       = 0;
            temp.mercator        = (temp.projection == ProjectionType.Mercator);
            temp.centerX         = 0;
            temp.centerY         = 0;
            temp.rotation        = 0;
            //todo add scale
            temp.thumbnailUrl = "";

            temp.matrix = Matrix3d.Identity;
            temp.matrix.Multiply(Matrix3d.RotationX((((temp.Rotation)) / 180f * Math.PI)));
            temp.matrix.Multiply(Matrix3d.RotationZ(((temp.CenterY) / 180f * Math.PI)));
            temp.matrix.Multiply(Matrix3d.RotationY((((360 - temp.CenterX) + 180) / 180f * Math.PI)));

            return(temp);
        }
예제 #4
0
        private static int GetTilesYForLevel(Imageset layer, int level)
        {
            int maxY = 1;

            switch (layer.Projection)
            {
            case ProjectionType.Mercator:
                maxY = (int)Math.Pow(2, level);
                break;

            case ProjectionType.Equirectangular:
                //                    maxY = (int)Math.Pow(2, level-layer.BaseLevel) * (int)(180 / layer.BaseTileDegrees);

                maxY = (int)(Math.Pow(2, level) * (180 / layer.BaseTileDegrees));
                break;

            case ProjectionType.Tangent:
                maxY = (int)Math.Pow(2, level);

                break;

            case ProjectionType.Spherical:
                maxY = 1;
                break;

            default:
                maxY = (int)Math.Pow(2, level);
                break;
            }
            if (maxY == Double.PositiveInfinity)
            {
                maxY = 1;
            }
            return(maxY);
        }
예제 #5
0
        public double GetAltitudeForLatLongForPlanet(int planetID, double viewLat, double viewLong)
        {
            Imageset layer = WWTControl.Singleton.GetImagesetByName(Planets.GetNameFrom3dId(planetID));

            if (layer == null)
            {
                return(0);
            }

            int maxX = GetTilesXForLevel(layer, layer.BaseLevel);
            int maxY = GetTilesYForLevel(layer, layer.BaseLevel);

            for (int x = 0; x < maxX; x++)
            {
                for (int y = 0; y < maxY; y++)
                {
                    Tile tile = TileCache.GetTile(layer.BaseLevel, x, y, layer, null);
                    if (tile != null)
                    {
                        if (tile.IsPointInTile(viewLat, viewLong))
                        {
                            return(tile.GetSurfacePointAltitude(viewLat, viewLong, true));
                        }
                    }
                }
            }
            return(0);
        }
예제 #6
0
        public static Tile GetCachedTile(int level, int x, int y, Imageset dataset, Tile parent)
        {
            if (level < dataset.BaseLevel)
            {
                return(null);
            }

            Tile   retTile = null;
            string tileKey = Imageset.GetTileKey(dataset, level, x, y, parent);

            try
            {
                if (!tiles.ContainsKey(tileKey))
                {
                    return(null);
                }
                else
                {
                    retTile = tiles[tileKey];
                }
            }
            catch
            {
            }

            return(retTile);
        }
예제 #7
0
        public override void WriteLayerProperties(XmlTextWriter xmlWriter)
        {
            if (imageSet.WcsImage != null)
            {
                if (imageSet.WcsImage is FitsImage)
                {
                    extension = ".fit";
                }
                else
                {
                    extension = ".png";
                }
                xmlWriter.WriteAttributeString("Extension", extension);
            }

            if (imageSet.WcsImage is FitsImage)
            {
                FitsImage fi = imageSet.WcsImage as FitsImage;
                xmlWriter.WriteAttributeString("ScaleType", Enums.ToXml("ScaleTypes", (int)fi.lastScale));
                xmlWriter.WriteAttributeString("MinValue", fi.lastBitmapMin.ToString());
                xmlWriter.WriteAttributeString("MaxValue", fi.lastBitmapMax.ToString());
                if (fi.lastBitmapColorMapperName != null)
                {
                    xmlWriter.WriteAttributeString("ColorMapperName", fi.lastBitmapColorMapperName);
                }
            }

            xmlWriter.WriteAttributeString("OverrideDefault", overrideDefaultLayer.ToString());

            Imageset.SaveToXml(xmlWriter, imageSet, "");
            base.WriteLayerProperties(xmlWriter);
        }
예제 #8
0
        private Tile GetTileAtLatLong(double viewLat, double viewLong)
        {
            Imageset layer = BackgroundImageset;

            if (layer == null)
            {
                return(null);
            }

            int maxX = GetTilesXForLevel(layer, layer.BaseLevel);
            int maxY = GetTilesYForLevel(layer, layer.BaseLevel);

            for (int x = 0; x < maxX; x++)
            {
                for (int y = 0; y < maxY; y++)
                {
                    Tile tile = TileCache.GetTile(layer.BaseLevel, x, y, layer, null);
                    if (tile != null)
                    {
                        if (tile.IsPointInTile(viewLat, viewLong))
                        {
                            return(tile);
                        }
                    }
                }
            }
            return(null);
        }
예제 #9
0
        //internal static void AddTileToQueue(Tile tile)
        //{

        //    queue[tile.Key] = tile;
        //}

        public static Tile GetTile(int level, int x, int y, Imageset dataset, Tile parent)
        {
            Tile   retTile = null;
            string tileKey = Imageset.GetTileKey(dataset, level, x, y, parent);

            // try
            {
                if (!tiles.ContainsKey(tileKey))
                {
                    retTile = Imageset.GetNewTile(dataset, level, x, y, parent);
                    if (retTile != null)
                    {
                        tiles[tileKey] = retTile;
                    }
                }
                else
                {
                    retTile = tiles[tileKey];
                }
            }
            // catch
            {
                int p = 0;
            }

            return(retTile);
        }
예제 #10
0
        public static ImageSetLayer Create(Imageset set)
        {
            ImageSetLayer isl = new ImageSetLayer();

            isl.imageSet = set;
            return(isl);
        }
예제 #11
0
        public static PlotTile Create(int level, int xc, int yc, Imageset dataset, Tile parent)
        {
            PlotTile temp = new PlotTile();
            temp.Parent = parent;
            temp.Level = level;
            temp.tileX = xc;
            temp.tileY = yc;
            temp.dataset = dataset;
            temp.topDown = !dataset.BottomsUp;

            if (temp.tileX != (int)xc)
            {
                Script.Literal("alert('bad')");
            }
            //temp.ComputeQuadrant();

            if (dataset.MeanRadius != 0)
            {
                temp.DemScaleFactor = dataset.MeanRadius;
            }
            else
            {
                if (dataset.DataSetType == ImageSetType.Earth)
                {
                    temp.DemScaleFactor = 6371000;
                }
                else
                {
                    temp.DemScaleFactor = 3396010;
                }
            }

            temp.ComputeBoundingSphere();
            return temp;
        }
예제 #12
0
        public static FitsImageJs CreateHipsTile(Imageset dataset, string file, WcsLoaded callMeBack)
        {
            FitsImageJs fits = new FitsImageJs(dataset, file, null, callMeBack);

            fits.isHipsTile = true;
            return(fits);
        }
예제 #13
0
        public override void InitializeFromXml(XmlNode node)
        {
            XmlNode imageSetNode = Util.SelectSingleNode(node, "ImageSet");

            imageSet = Imageset.FromXMLNode(imageSetNode);


            if (node.Attributes.GetNamedItem("Extension") != null)
            {
                extension = node.Attributes.GetNamedItem("Extension").Value;
            }

            if (node.Attributes.GetNamedItem("ScaleType") != null)
            {
                lastScale = (ScaleTypes)Enums.Parse("ScaleTypes", node.Attributes.GetNamedItem("ScaleType").Value);
            }

            if (node.Attributes.GetNamedItem("MinValue") != null)
            {
                min = double.Parse(node.Attributes.GetNamedItem("MinValue").Value);
            }

            if (node.Attributes.GetNamedItem("MaxValue") != null)
            {
                max = double.Parse(node.Attributes.GetNamedItem("MaxValue").Value);
            }

            if (node.Attributes.GetNamedItem("OverrideDefault") != null)
            {
                overrideDefaultLayer = bool.Parse(node.Attributes.GetNamedItem("OverrideDefault").Value);
            }
        }
        public override void WriteLayerProperties(XmlTextWriter xmlWriter)
        {
            if (imageSet.WcsImage != null)
            {
                if (IsFitsImageset())
                {
                    extension = ".fit";
                }
                else
                {
                    extension = ".png";
                }

                xmlWriter.WriteAttributeString("Extension", extension);
            }

            if (IsFitsImageset())
            {
                xmlWriter.WriteAttributeString("ScaleType", Enums.ToXml("ScaleTypes", (int)imageSet.FitsProperties.ScaleType));
                xmlWriter.WriteAttributeString("MinValue", imageSet.FitsProperties.MinVal.ToString());
                xmlWriter.WriteAttributeString("MaxValue", imageSet.FitsProperties.MaxVal.ToString());
                xmlWriter.WriteAttributeString("LowerCut", imageSet.FitsProperties.LowerCut.ToString());
                xmlWriter.WriteAttributeString("UpperCut", imageSet.FitsProperties.UpperCut.ToString());

                if (imageSet.FitsProperties.ColorMapName != null)
                {
                    xmlWriter.WriteAttributeString("ColorMapperName", imageSet.FitsProperties.ColorMapName);
                }
            }

            xmlWriter.WriteAttributeString("OverrideDefault", overrideDefaultLayer.ToString());

            Imageset.SaveToXml(xmlWriter, imageSet, "");
            base.WriteLayerProperties(xmlWriter);
        }
        public static Imageset Create(string name, string url, ImageSetType dataSetType, BandPass bandPass, ProjectionType projection, int imageSetID, int baseLevel, int levels, int tileSize, double baseTileDegrees, string extension, bool bottomsUp, string quadTreeMap, double centerX, double centerY, double rotation, bool sparse, string thumbnailUrl, bool defaultSet, bool elevationModel, int wf, double offsetX, double offsetY, string credits, string creditsUrl, string demUrlIn, string alturl, double meanRadius, string referenceFrame)
        {
            Imageset temp = new Imageset();

            temp.SetInitialParameters(name, url, dataSetType, bandPass, projection, imageSetID, baseLevel, levels, baseTileDegrees, extension, bottomsUp, quadTreeMap, centerX, centerY, rotation, sparse, thumbnailUrl, defaultSet, elevationModel, wf, offsetX, offsetY, credits, creditsUrl, demUrlIn, alturl, meanRadius, referenceFrame);

            return(temp);
        }
예제 #16
0
 public void RemoveCatalogHips(Imageset imageset)
 {
     activeCatalogHipsImagesets.Remove(imageset);
     if (imageset.HipsProperties != null)
     {
         LayerManager.DeleteLayerByID(imageset.HipsProperties.CatalogSpreadSheetLayer.ID, true, true);
     }
 }
        public static Tile GetNewTile(Imageset imageset, int level, int x, int y, Tile parent)
        {
            switch (imageset.Projection)
            {
            case ProjectionType.Mercator:
            {
                MercatorTile newTile = MercatorTile.Create(level, x, y, imageset, parent);
                return(newTile);
            }

            case ProjectionType.Equirectangular:
            {
                return(EquirectangularTile.Create(level, x, y, imageset, parent));
            }

            //case ProjectionType.Spherical:
            //    {
            //        return new SphericalTile(level, x, y, imageset, parent);
            //    }
            default:
            case ProjectionType.Toast:
            {
                return(ToastTile.Create(level, x, y, imageset, parent));
            }

            case ProjectionType.SkyImage:
            {
                return(new SkyImageTile(level, x, y, imageset, parent));
            }

            case ProjectionType.Plotted:
            {
                return(PlotTile.Create(level, x, y, imageset, parent));
            }

            case ProjectionType.Healpix:
            {
                if (imageset.HipsProperties == null)
                {
                    imageset.HipsProperties = new HipsProperties(imageset);
                }
                if (imageset.HipsProperties.DownloadComplete)
                {
                    return(new HealpixTile(level, x, y, imageset, parent));
                }
                else
                {
                    return(null);
                }
            }

            case ProjectionType.Tangent:
            {
                TangentTile newTile = new TangentTile(level, x, y, imageset, parent);
                return(newTile);
            }
            }
        }
예제 #18
0
        private void TryGetAllDataInView(Imageset imageset, bool limit, CatalogSpreadSheetLayer catalogSpreadSheetLayer, Action <InViewReturnMessage> onComplete, int i)
        {
            int  maxX = GetTilesXForLevel(imageset, imageset.BaseLevel);
            int  maxY = GetTilesYForLevel(imageset, imageset.BaseLevel);
            bool anyTileStillDownloading = false;

            for (int x = 0; x < maxX; x++)
            {
                for (int y = 0; y < maxY; y++)
                {
                    Tile tile = TileCache.GetTile(imageset.BaseLevel, x, y, imageset, null);
                    if (tile != null)
                    {
                        bool tileAndChildrenReady = ((HealpixTile)tile).GetDataInView(this, limit, catalogSpreadSheetLayer);
                        anyTileStillDownloading = anyTileStillDownloading || !tileAndChildrenReady;
                    }
                    else
                    {
                        anyTileStillDownloading = true;
                    }
                }
            }
            if (anyTileStillDownloading)
            {
                int count = catalogSpreadSheetLayer.Table.Rows.Count;
                if ((count > 10000 || i > 100 * 60 * 5) && limit) // ~5 minutes
                {
                    Script.Literal("console.log('Too Many results - Aborting')");
                    Script.Literal("console.log(count)");
                    InViewReturnMessage returnMessage = new InViewReturnMessage();
                    returnMessage.aborted = true;
                    returnMessage.table   = catalogSpreadSheetLayer.GetTableDataInView();
                    onComplete.Invoke(returnMessage);
                    catalogSpreadSheetLayer.CleanUp();
                }
                else
                {
                    Script.SetTimeout(delegate() { TryGetAllDataInView(imageset, limit, catalogSpreadSheetLayer, onComplete, i); }, 10);
                    if (i % 200 == 0)
                    {
                        Script.Literal("console.log('Waiting for more tiles to load')");
                        Script.Literal("console.log(count)");
                    }
                    i++;
                }
            }
            else
            {
                int count = catalogSpreadSheetLayer.Table.Rows.Count;
                Script.Literal("console.log('Done!')");
                Script.Literal("console.log(count)");
                InViewReturnMessage returnMessage = new InViewReturnMessage();
                returnMessage.aborted = false;
                returnMessage.table   = catalogSpreadSheetLayer.GetTableDataInView();
                onComplete.Invoke(returnMessage);
                catalogSpreadSheetLayer.CleanUp();
            }
        }
 public static string GetTileKey(Imageset imageset, int level, int x, int y, Tile parent)
 {
     if (imageset.Projection == ProjectionType.Healpix && parent != null)
     {
         int ipix = ((HealpixTile)parent).ipix * 4 + y * 2 + x;
         return(imageset.ImageSetID.ToString() + @"\" + level.ToString() + @"\" + ipix.ToString());
     }
     return(imageset.ImageSetID.ToString() + @"\" + level.ToString() + @"\" + y.ToString() + "_" + x.ToString());
 }
예제 #20
0
 public TangentTile(int level, int x, int y, Imageset dataset, Tile parent)
 {
     this.Parent  = parent;
     this.Level   = level;
     this.tileX   = x;
     this.tileY   = y;
     this.dataset = dataset;
     this.topDown = !dataset.BottomsUp;
     this.ComputeBoundingSphere();
 }
예제 #21
0
 public static EquirectangularTile Create(int level, int x, int y, Imageset dataset, Tile parent)
 {
     EquirectangularTile temp = new EquirectangularTile();
     temp.Parent = parent;
     temp.Level = level;
     temp.tileX = x;
     temp.tileY = y;
     temp.dataset = dataset;
     temp.topDown = !dataset.BottomsUp;
     temp.ComputeBoundingSphere();
     return temp;
 }
예제 #22
0
        public static int GetTilesXForLevel(Imageset layer, int level)
        {
            int maxX = 1;

            switch (layer.Projection)
            {
            case ProjectionType.Plotted:
            case ProjectionType.Toast:
                maxX = (int)Math.Pow(2, level);
                break;

            case ProjectionType.Mercator:
                maxX = (int)Math.Pow(2, level) * (int)(layer.BaseTileDegrees / 360.0);
                break;

            case ProjectionType.Equirectangular:
                //maxX = (int)Math.Pow(2, level) * (int)(layer.BaseTileDegrees / 90.0);
                maxX = (int)Math.Pow(2, level) * (int)(360 / layer.BaseTileDegrees);

                break;

            case ProjectionType.Tangent:
                if (layer.WidthFactor == 1)
                {
                    maxX = (int)Math.Pow(2, level) * 2;
                }
                else
                {
                    maxX = (int)Math.Pow(2, level);
                }
                break;

            case ProjectionType.SkyImage:
                maxX = 1;
                break;

            case ProjectionType.Spherical:
                maxX = 1;
                break;

            case ProjectionType.Healpix:
                maxX = (int)Math.Pow(2, level) * 3;
                break;

            default:
                maxX = (int)Math.Pow(2, level) * 2;
                break;
            }


            return(maxX);
        }
        public static MercatorTile Create(int level, int X, int Y, Imageset dataset, Tile parent)
        {
            MercatorTile temp = new MercatorTile();

            temp.Parent  = parent;
            temp.Level   = level;
            temp.tileX   = X;
            temp.tileY   = Y;
            temp.dataset = dataset;
            temp.ComputeBoundingSphere();

            return(temp);
        }
        public static EquirectangularTile Create(int level, int x, int y, Imageset dataset, Tile parent)
        {
            EquirectangularTile temp = new EquirectangularTile();

            temp.Parent  = parent;
            temp.Level   = level;
            temp.tileX   = x;
            temp.tileY   = y;
            temp.dataset = dataset;
            temp.topDown = !dataset.BottomsUp;
            temp.ComputeBoundingSphere();
            return(temp);
        }
예제 #25
0
 public static SkyImageTile Create(int level, int x, int y, Imageset dataset, Tile parent)
 {
     SkyImageTile temp = new SkyImageTile();
     temp.Parent = parent;
     temp.Level = level;
     temp.tileX = x;
     temp.tileY = y;
     temp.dataset = dataset;
     temp.GetParameters();
     temp.ComputeMatrix();
     temp.sphereCenter = temp.GeoTo3dTan(0, 0);
     temp.radius = 1.25f;
     return temp;
 }
예제 #26
0
        //public static bool operator ==(ImageSet left, ImageSet right)
        //{
        //    if (left == right )
        //    {
        //        return true;
        //    }
        //    if (left == null ^ right == null)
        //    {
        //        return false;
        //    }
        //    return (left.Url.GetHashCode() == right.Url.GetHashCode());
        //}

        //public static bool operator !=(ImageSet left, ImageSet right)
        //{
        //    if (left == right )
        //    {
        //        return false;
        //    }
        //    if ( left == null ^ right == null)
        //    {
        //        return true;
        //    }

        //    return (left.Url.GetHashCode() != right.Url.GetHashCode());
        //}

        //public static bool operator ==(ImageSet o1, ImageSet o2)
        //{
        //    return (Object)o1 == null ? (Object)o2 == null : o1.Equals(o2);
        //}
        //public static bool operator !=(ImageSet o1, ImageSet o2)
        //{
        //    return (Object)o1 != null ? (Object)o2 != null : !o1.Equals(o2);
        //}



        public bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (!(obj is Imageset))
            {
                return(false);
            }
            Imageset b = (Imageset)obj;

            return(Util.GetHashCode(b.Url) == Util.GetHashCode(this.Url) && b.DataSetType == this.DataSetType && b.BandPass == this.BandPass && b.Generic == this.Generic);
        }
        public HipsProperties(Imageset dataset)
        {
            this.dataset     = dataset;
            this.datasetName = dataset.Name;
            url = dataset.Url;
            if (url.ToLowerCase().IndexOf("norder") > -1)
            {
                url = url.Substring(0, url.ToLowerCase().IndexOf("norder"));
            }

            url += "properties";

            Download();
        }
예제 #28
0
        internal void SaveToXml(XmlTextWriter xmlWriter, string elementName)
        {
            xmlWriter.WriteStartElement(elementName);
            xmlWriter.WriteAttributeString("Name", name);
            xmlWriter.WriteAttributeString("DataSetType", Enums.ToXml("ImageSetType", (int)type));
            if (this.Type == ImageSetType.Sky)
            {
                xmlWriter.WriteAttributeString("RA", camParams.RA.ToString());
                xmlWriter.WriteAttributeString("Dec", camParams.Dec.ToString());
            }
            else
            {
                xmlWriter.WriteAttributeString("Lat", Lat.ToString());
                xmlWriter.WriteAttributeString("Lng", Lng.ToString());
            }

            xmlWriter.WriteAttributeString("Constellation", constellation);
            xmlWriter.WriteAttributeString("Classification", Enums.ToXml("Classification", (int)classification));
            xmlWriter.WriteAttributeString("Magnitude", magnitude.ToString());
            xmlWriter.WriteAttributeString("Distance", distnace.ToString());
            xmlWriter.WriteAttributeString("AngularSize", AngularSize.ToString());
            xmlWriter.WriteAttributeString("ZoomLevel", ZoomLevel.ToString());
            xmlWriter.WriteAttributeString("Rotation", camParams.Rotation.ToString());
            xmlWriter.WriteAttributeString("Angle", camParams.Angle.ToString());
            xmlWriter.WriteAttributeString("Opacity", camParams.Opacity.ToString());
            xmlWriter.WriteAttributeString("Target", Enums.ToXml("SolarSystemObjects", (int)Target));
            xmlWriter.WriteAttributeString("ViewTarget", camParams.ViewTarget.ToString());
            xmlWriter.WriteAttributeString("TargetReferenceFrame", camParams.TargetReferenceFrame);
            //todo what do we do with full dome?
            // xmlWriter.WriteAttributeString("DomeAlt", camParams.DomeAlt.ToString());
            // xmlWriter.WriteAttributeString("DomeAz", camParams.DomeAz.ToString());
            xmlWriter.WriteStartElement("Description");
            xmlWriter.WriteCData(HtmlDescription);
            xmlWriter.WriteEndElement();


            if (backgroundImageSet != null)
            {
                xmlWriter.WriteStartElement("BackgroundImageSet");
                Imageset.SaveToXml(xmlWriter, backgroundImageSet, "");

                xmlWriter.WriteEndElement();
            }

            if (studyImageset != null)
            {
                Imageset.SaveToXml(xmlWriter, studyImageset, "");
            }
            xmlWriter.WriteEndElement();
        }
예제 #29
0
        public static void SaveToXml(XmlTextWriter xmlWriter, Imageset imageset, string alternateUrl)
        {
            xmlWriter.WriteStartElement("ImageSet");

            xmlWriter.WriteAttributeString("Generic", imageset.Generic.ToString());
            xmlWriter.WriteAttributeString("DataSetType", Enums.ToXml("ImageSetType", (int)imageset.DataSetType));
            xmlWriter.WriteAttributeString("BandPass", Enums.ToXml("BandPass", (int)imageset.BandPass));
            if (!imageset.Generic)
            {
                xmlWriter.WriteAttributeString("Name", imageset.Name);

                if (String.IsNullOrEmpty(alternateUrl))
                {
                    xmlWriter.WriteAttributeString("Url", imageset.Url);
                }
                else
                {
                    xmlWriter.WriteAttributeString("Url", alternateUrl);
                }
                xmlWriter.WriteAttributeString("DemUrl", imageset.DemUrl);
                xmlWriter.WriteAttributeString("BaseTileLevel", imageset.BaseLevel.ToString());
                xmlWriter.WriteAttributeString("TileLevels", imageset.Levels.ToString());
                xmlWriter.WriteAttributeString("BaseDegreesPerTile", imageset.BaseTileDegrees.ToString());
                xmlWriter.WriteAttributeString("FileType", imageset.Extension);
                xmlWriter.WriteAttributeString("BottomsUp", imageset.BottomsUp.ToString());
                xmlWriter.WriteAttributeString("Projection", Enums.ToXml("ProjectionType", (int)imageset.Projection));
                xmlWriter.WriteAttributeString("QuadTreeMap", imageset.QuadTreeTileMap);
                xmlWriter.WriteAttributeString("CenterX", imageset.CenterX.ToString());
                xmlWriter.WriteAttributeString("CenterY", imageset.CenterY.ToString());
                xmlWriter.WriteAttributeString("OffsetX", imageset.OffsetX.ToString());
                xmlWriter.WriteAttributeString("OffsetY", imageset.OffsetY.ToString());
                xmlWriter.WriteAttributeString("Rotation", imageset.Rotation.ToString());
                xmlWriter.WriteAttributeString("Sparse", imageset.Sparse.ToString());
                xmlWriter.WriteAttributeString("ElevationModel", imageset.ElevationModel.ToString());
                xmlWriter.WriteAttributeString("StockSet", imageset.DefaultSet.ToString());
                xmlWriter.WriteAttributeString("WidthFactor", imageset.WidthFactor.ToString());
                xmlWriter.WriteAttributeString("MeanRadius", imageset.MeanRadius.ToString());
                xmlWriter.WriteAttributeString("ReferenceFrame", imageset.ReferenceFrame);
                if (String.IsNullOrEmpty(alternateUrl))
                {
                    xmlWriter.WriteElementString("ThumbnailUrl", imageset.ThumbnailUrl);
                }
                else
                {
                    xmlWriter.WriteElementString("ThumbnailUrl", imageset.Url);
                }
            }
            xmlWriter.WriteEndElement();
        }
예제 #30
0
        public static SkyImageTile Create(int level, int x, int y, Imageset dataset, Tile parent)
        {
            SkyImageTile temp = new SkyImageTile();

            temp.Parent  = parent;
            temp.Level   = level;
            temp.tileX   = x;
            temp.tileY   = y;
            temp.dataset = dataset;
            temp.GetParameters();
            temp.ComputeMatrix();
            temp.sphereCenter = temp.GeoTo3dTan(0, 0);
            temp.radius       = 1.25f;
            return(temp);
        }
 public FitsImage(Imageset dataset, string file, Blob blob, WcsLoaded callMeBack)
 {
     this.dataset        = dataset;
     this.fitsProperties = dataset.FitsProperties;
     callBack            = callMeBack;
     filename            = file;
     if (blob != null)
     {
         ReadFromBlob(blob);
     }
     else
     {
         GetFile(file);
     }
 }
예제 #32
0
        public static Tile GetNewTile(Imageset imageset, int level, int x, int y, Tile parent)
        {
            switch (imageset.Projection)
            {
            case ProjectionType.Mercator:
            {
                MercatorTile newTile = MercatorTile.Create(level, x, y, imageset, parent);
                return(newTile);
            }

            case ProjectionType.Equirectangular:
            {
                return(EquirectangularTile.Create(level, x, y, imageset, parent));
            }

            //case ProjectionType.Spherical:
            //    {
            //        return new SphericalTile(level, x, y, imageset, parent);
            //    }
            default:
            case ProjectionType.Toast:
            {
                return(ToastTile.Create(level, x, y, imageset, parent));
            }

            case ProjectionType.SkyImage:
            {
                return(SkyImageTile.Create(level, x, y, imageset, parent));
            }

            case ProjectionType.Plotted:
            {
                return(PlotTile.Create(level, x, y, imageset, parent));
            }

            case ProjectionType.Healpix:
            {
                return(new HealpixTile(level, x, y, imageset, parent));
            }

            case ProjectionType.Tangent:
            {
                TangentTile newTile = TangentTile.Create(level, x, y, imageset, parent);
                return(newTile);
            }
            }
        }
예제 #33
0
        public void DrawImageSet(Imageset imageset, double opacity)
        {
            int maxX = GetTilesXForLevel(imageset, imageset.BaseLevel);
            int maxY = GetTilesYForLevel(imageset, imageset.BaseLevel);

            for (int x = 0; x < maxX; x++)
            {
                for (int y = 0; y < maxY; y++)
                {
                    Tile tile = TileCache.GetTile(imageset.BaseLevel, x, y, imageset, null);
                    if (tile != null)
                    {
                        tile.Draw3D(this, opacity);
                    }
                }
            }
        }
예제 #34
0
        private static int GetTilesYForLevel(Imageset layer, int level)
        {
            int maxY = 1;

            switch (layer.Projection)
            {
                case ProjectionType.Mercator:
                    maxY = (int)Math.Pow(2, level);
                    break;
                case ProjectionType.Equirectangular:
                    //                    maxY = (int)Math.Pow(2, level-layer.BaseLevel) * (int)(180 / layer.BaseTileDegrees);

                    maxY = (int)(Math.Pow(2, level) * (180 / layer.BaseTileDegrees));
                    break;
                case ProjectionType.Tangent:
                    maxY = (int)Math.Pow(2, level);

                    break;
                case ProjectionType.Spherical:
                    maxY = 1;
                    break;
                default:
                    maxY = (int)Math.Pow(2, level);
                    break;
            }
            if (maxY == Double.PositiveInfinity)
            {
                maxY = 1;
            }
            return maxY;
        }
예제 #35
0
        public static MercatorTile Create(int level, int X, int Y, Imageset dataset, Tile parent)
        {
            MercatorTile temp = new MercatorTile();
            temp.Parent = parent;
            temp.Level = level;
            temp.tileX = X;
            temp.tileY = Y;
            temp.dataset = dataset;
            temp.ComputeBoundingSphere();

            return temp;
        }
예제 #36
0
        private static int GetTilesXForLevel(Imageset layer, int level)
        {
            int maxX = 1;
            switch (layer.Projection)
            {
                case ProjectionType.Plotted:
                case ProjectionType.Toast:
                    maxX = (int)Math.Pow(2, level);
                    break;
                case ProjectionType.Mercator:
                    maxX = (int)Math.Pow(2, level) * (int)(layer.BaseTileDegrees / 360.0);
                    break;
                case ProjectionType.Equirectangular:
                    //maxX = (int)Math.Pow(2, level) * (int)(layer.BaseTileDegrees / 90.0);
                    maxX = (int)Math.Pow(2, level) * (int)(360 / layer.BaseTileDegrees);

                    break;
                case ProjectionType.SkyImage:
                case ProjectionType.Tangent:
                    if (layer.WidthFactor == 1)
                    {
                        maxX = (int)Math.Pow(2, level) * 2;
                    }
                    else
                    {
                        maxX = (int)Math.Pow(2, level);
                    }
                    break;
                case ProjectionType.Spherical:
                    maxX = 1;
                    break;
                default:
                    maxX = (int)Math.Pow(2, level) * 2;
                    break;
            }

            return maxX;
        }
예제 #37
0
        public static Imageset CreateGeneric(ImageSetType dataSetType, BandPass bandPass)
        {
            Imageset temp = new Imageset();
            temp.generic = true;
            temp.name = "Generic";
            temp.sparse = false;
            temp.dataSetType = dataSetType;
            temp.bandPass = bandPass;
            temp.quadTreeTileMap = "";
            temp.url = "";
            temp.levels = 0;
            temp.baseTileDegrees = 0;
            temp.imageSetID = 0;
            temp.extension = "";
            temp.projection = ProjectionType.Equirectangular;
            temp.bottomsUp = false;
            temp.baseLevel = 0;
            temp.mercator = (temp.projection == ProjectionType.Mercator);
            temp.centerX = 0;
            temp.centerY = 0;
            temp.rotation = 0;
            //todo add scale
            temp.thumbnailUrl = "";

            temp.matrix = Matrix3d.Identity;
            temp.matrix.Multiply(Matrix3d.RotationX((((temp.Rotation)) / 180f * Math.PI)));
            temp.matrix.Multiply(Matrix3d.RotationZ(((temp.CenterY) / 180f * Math.PI)));
            temp.matrix.Multiply(Matrix3d.RotationY((((360 - temp.CenterX) + 180) / 180f * Math.PI)));

            return temp;
        }
예제 #38
0
        public static Tile GetNewTile(Imageset imageset, int level, int x, int y, Tile parent)
        {
            switch (imageset.Projection)
            {
                case ProjectionType.Mercator:
                    {
                        MercatorTile newTile = MercatorTile.Create(level, x, y, imageset, parent);
                        return newTile;
                    }
                case ProjectionType.Equirectangular:
                    {
                        return EquirectangularTile.Create(level, x, y, imageset, parent);
                    }
                //case ProjectionType.Spherical:
                //    {
                //        return new SphericalTile(level, x, y, imageset, parent);
                //    }
                default:
                case ProjectionType.Toast:
                    {
                        return ToastTile.Create(level, x, y, imageset, parent);
                    }
                case ProjectionType.SkyImage:
                    {
                        return SkyImageTile.Create(level, x, y, imageset, parent);
                    }
                case ProjectionType.Plotted:
                    {
                        return PlotTile.Create(level, x, y, imageset, parent);
                    }

                case ProjectionType.Tangent:
                    {
                        TangentTile newTile = TangentTile.Create(level, x, y, imageset, parent);
                        return newTile;
                    }
            }
        }
예제 #39
0
 public static string GetTileKey(Imageset imageset, int level, int x, int y)
 {
     return imageset.ImageSetID.ToString() + @"\" + level.ToString() + @"\" + y.ToString() + "_" + x.ToString();
 }
예제 #40
0
        public void Render()
        {
            if (RenderContext.BackgroundImageset != null)
            {
                RenderType = RenderContext.BackgroundImageset.DataSetType;
            }
            else
            {
                RenderType = ImageSetType.Sky;
            }

            //Date date = Date.Now;

            //int hour = date.GetHours();

            //Date date2 = new Date(Date.UTC(0,0,0,0,0,0,date.GetTime()));
            //int hour1 = date.GetHours();

            //int hour3 = date.GetUTCHours();

            bool sizeChange = false;
            if (Canvas.Width != int.Parse(Canvas.ParentNode.Style.Width))
            {
                Canvas.Width = int.Parse(Canvas.ParentNode.Style.Width);
                sizeChange = true;
            }

            if (Canvas.Height != int.Parse(Canvas.ParentNode.Style.Height))
            {
                Canvas.Height = int.Parse(Canvas.ParentNode.Style.Height);
                sizeChange = true;
            }

            if (sizeChange)
            {
                if (Explorer != null)
                {
                    Explorer.Refresh();
                }
            }

            Tile.lastDeepestLevel = Tile.deepestLevel;

            RenderTriangle.Width = RenderContext.Width = Canvas.Width;
            RenderTriangle.Height = RenderContext.Height = Canvas.Height;
            Tile.TilesInView = 0;
            Tile.TilesTouched = 0;
            Tile.deepestLevel = 0;

            if (Mover != null)
            {
                SpaceTimeController.Now = Mover.CurrentDateTime;

                Planets.UpdatePlanetLocations(SolarSystemMode);

                if (Mover != null)
                {
                    CameraParameters newCam = Mover.CurrentPosition;

                    RenderContext.TargetCamera = newCam.Copy();
                    RenderContext.ViewCamera = newCam.Copy();
                    if (RenderContext.Space && Settings.Active.GalacticMode)
                    {
                        double[] gPoint = Coordinates.J2000toGalactic(newCam.RA * 15, newCam.Dec);

                        RenderContext.targetAlt = RenderContext.alt = gPoint[1];
                        RenderContext.targetAz = RenderContext.az = gPoint[0];
                    }
                    else if (RenderContext.Space && Settings.Active.LocalHorizonMode)
                    {
                        Coordinates currentAltAz = Coordinates.EquitorialToHorizon(Coordinates.FromRaDec(newCam.RA, newCam.Dec), SpaceTimeController.Location, SpaceTimeController.Now);

                        RenderContext.targetAlt = RenderContext.alt = currentAltAz.Alt;
                        RenderContext.targetAz = RenderContext.az = currentAltAz.Az;
                    }

                    if (Mover.Complete)
                    {
                        //Todo Notify interested parties that move is complete
                        scriptInterface.FireArrived(Mover.CurrentPosition.RA, Mover.CurrentPosition.Dec, WWTControl.Singleton.RenderContext.ViewCamera.Zoom);
                        Mover = null;

                        NotifyMoveComplete();
                    }

                }
            }
            else
            {
                SpaceTimeController.UpdateClock();

                Planets.UpdatePlanetLocations(SolarSystemMode);

                UpdateViewParameters();

            }

            RenderContext.Clear();

            //if (RenderContext.gl != null)
            //{
            //    Window.SetTimeout(delegate() { Render(); }, 0);
            //    return;
            //}

            if (RenderType == ImageSetType.SolarSystem)
            {
             {
                    if ((int)SolarSystemTrack < (int)SolarSystemObjects.Custom)
                    {
                        double radius = Planets.GetAdjustedPlanetRadius((int)SolarSystemTrack);
                        double distance = RenderContext.SolarSystemCameraDistance;
                        double camAngle = RenderContext.FovLocal;
                        //double distrad = distance / (radius * Math.Tan(.5 * camAngle));

                    }

                    if (trackingObject == null)
                    {
                 //todo fix this       trackingObject = Search.FindCatalogObject("Sun");
                    }

                    RenderContext.SetupMatricesSolarSystem(true);

                    //float skyOpacity = 1.0f - Planets.CalculateSkyBrightnessFactor(RenderContext11.View, viewCamera.ViewTarget);
                    //if (float.IsNaN(skyOpacity))
                    //{
                    //    skyOpacity = 0f;
                    //}

                    double zoom = RenderContext.ViewCamera.Zoom;
                    float milkyWayBlend = (float)Math.Min(1.0, Math.Max(0, (Math.Log(zoom) - 8.4)) / 4.2);
                    float milkyWayBlendIn = (float)Math.Min(1.0, Math.Max(0, (Math.Log(zoom) - 17.9)) / 2.3);

                    Matrix3d matOldMW = RenderContext.World;
                    Matrix3d matLocalMW = RenderContext.World.Clone();
                    matLocalMW.Multiply(Matrix3d.Scaling(100000, 100000, 100000));
                    matLocalMW.Multiply(Matrix3d.RotationX(23.5 / 180 * Math.PI));
                    //                              matLocalMW.Multiply(Matrix3d.RotationY(Math.PI));
                    matLocalMW.Multiply(Matrix3d.Translation(RenderContext.CameraPosition)); //todo change this when tracking is added back
                    RenderContext.World = matLocalMW;
                    RenderContext.WorldBase = matLocalMW;
                    RenderContext.Space = true;
                    RenderContext.MakeFrustum();
                    bool lighting = RenderContext.Lighting;
                    RenderContext.Lighting = false;
                    if (Settings.Active.SolarSystemMilkyWay)
                    {
                        if (milkyWayBlend < 1) // Solar System mode Milky Way background
                        {
                            if (milkyWayBackground == null)
                            {
                                milkyWayBackground = GetImagesetByName("Digitized Sky Survey (Color)");
                            }

                            if (milkyWayBackground != null)
                            {
                                RenderTriangle.CullInside = true;
                                float c = ((1 - milkyWayBlend)) / 2;

                                RenderContext.DrawImageSet( milkyWayBackground, 100 );

                                RenderTriangle.CullInside = false;
                            }
                        }
                    }

                    DrawSkyOverlays();
                    RenderContext.Lighting = lighting;

                    RenderContext.Space = false;
                    RenderContext.World = matOldMW;
                    RenderContext.WorldBase = matOldMW;
                    RenderContext.MakeFrustum();
                    //// CMB

                    //float cmbBlend = (float)Math.Min(1, Math.Max(0, (Math.Log(zoom) - 33)) / 2.3);

                    //double cmbLog = Math.Log(zoom);

                    //if (Properties.Settings.Default.SolarSystemCMB.State)
                    //{
                    //    if (cmbBlend > 0) // Solar System mode Milky Way background
                    //    {
                    //        if (cmbBackground == null)
                    //        {
                    //            cmbBackground = GetImagesetByName("Planck CMB");
                    //        }

                    //        if (cmbBackground != null)
                    //        {
                    //            float c = ((cmbBlend)) / 16;
                    //            Matrix3d matOldMW = RenderContext11.World;
                    //            Matrix3d matLocalMW = RenderContext11.World;
                    //            //double dist = UiTools.AuPerLightYear*46000000000;
                    //            matLocalMW.Multiply(Matrix3d.Scaling(2.9090248982E+15, 2.9090248982E+15, 2.9090248982E+15));
                    //            matLocalMW.Multiply(Matrix3d.RotationX(-23.5 / 180 * Math.PI));
                    //            matLocalMW.Multiply(Matrix3d.RotationY(Math.PI));
                    //            //  matLocalMW.Multiply(Matrix3d.Translation(cameraOffset));
                    //            RenderContext11.World = matLocalMW;
                    //            RenderContext11.WorldBase = matLocalMW;
                    //            Earth3d.MainWindow.MakeFrustum();

                    //            RenderContext11.SetupBasicEffect(BasicEffect.TextureColorOpacity, 1, Color.White);
                    //            //SetupMatricesSpace11(60, renderType);
                    //            RenderContext11.DepthStencilMode = DepthStencilMode.Off;
                    //            DrawTiledSphere(cmbBackground, c * Properties.Settings.Default.SolarSystemCMB.Opacity, Color.FromArgb(255, 255, 255, 255));
                    //            RenderContext11.World = matOldMW;
                    //            RenderContext11.WorldBase = matOldMW;
                    //            RenderContext11.DepthStencilMode = DepthStencilMode.ZReadWrite;
                    //        }
                    //    }
                    //}

                    //{
                    //    Matrix3d matOld = RenderContext11.World;

                    //    Matrix3d matLocal = RenderContext11.World;
                    //    matLocal.Multiply(Matrix3d.Translation(viewCamera.ViewTarget));
                    //    RenderContext11.World = matLocal;
                    //    Earth3d.MainWindow.MakeFrustum();

                    //    if (Properties.Settings.Default.SolarSystemCosmos.State)
                    //    {
                    //        RenderContext11.DepthStencilMode = DepthStencilMode.Off;
                    //        Grids.DrawCosmos3D(RenderContext11, Properties.Settings.Default.SolarSystemCosmos.Opacity * skyOpacity);
                    //        RenderContext11.DepthStencilMode = DepthStencilMode.ZReadWrite;
                    //    }

                    //    if (true)
                    //    {
                    //        RenderContext11.DepthStencilMode = DepthStencilMode.Off;

                    //        Grids.DrawCustomCosmos3D(RenderContext11, skyOpacity);

                    //        RenderContext11.DepthStencilMode = DepthStencilMode.ZReadWrite;
                    //    }

                    //    if (Properties.Settings.Default.SolarSystemMilkyWay.State && milkyWayBlendIn > 0)
                    //    {
                    //        Grids.DrawGalaxy3D(RenderContext11, Properties.Settings.Default.SolarSystemMilkyWay.Opacity * skyOpacity * milkyWayBlendIn);
                    //    }

                    //    if (Properties.Settings.Default.SolarSystemStars.State)
                    //    {
                    //        Grids.DrawStars3D(RenderContext11, Properties.Settings.Default.SolarSystemStars.Opacity * skyOpacity);
                    //    }

                    //    matLocal = matOld;
                    //    matLocal.Multiply(Matrix3d.Translation(-viewCamera.ViewTarget));
                    //    RenderContext11.World = matLocal;
                    //    Earth3d.MainWindow.MakeFrustum();

                    //    LayerManager.Draw(RenderContext11, 1.0f, true, "Sky", true, false);

                    //    RenderContext11.World = matOld;
                    //    Earth3d.MainWindow.MakeFrustum();
                    //}

                    if (RenderContext.SolarSystemCameraDistance < 15000)
                    {
                        RenderContext.SetupMatricesSolarSystem(false);

                        //if (Properties.Settings.Default.SolarSystemMinorPlanets.State)// && !RenderContext11.Downlevel)
                        //{
                        //    MinorPlanets.DrawMPC3D(RenderContext11, Properties.Settings.Default.SolarSystemMinorPlanets.Opacity, viewCamera.ViewTarget);
                        //}

                        Planets.DrawPlanets3D(RenderContext, 1, RenderContext.ViewCamera.ViewTarget);
                    }

                    //double p = Math.Log(zoom);
                    //double d = (180 / SolarSystemCameraDistance) * 100; // (SolarSystemCameraDistance * SolarSystemCameraDistance) * 10000000;

                    //float sunAtDistance = (float)Math.Min(1, Math.Max(0, (Math.Log(zoom) - 7.5)) / 3);

                    //if (sunAtDistance > 0)
                    //{
                    //    Planets.DrawPointPlanet(RenderContext11, new Vector3d(0, 0, 0), (float)d * sunAtDistance, Color.FromArgb(192, 191, 128), false, 1);
                    //}

                    //if ((SolarSystemMode) && label != null && !TourPlayer.Playing)
                    //{
                    //    label.Draw(RenderContext11, true);
                    //}
                }

            }
            else
            {

                if (RenderType == ImageSetType.Earth || RenderType == ImageSetType.Planet)
                {
                    RenderContext.SetupMatricesLand3d();
                }
                else
                {
                    RenderContext.SetupMatricesSpace3d(RenderContext.Width, RenderContext.Height);
                }

                RenderContext.DrawImageSet(RenderContext.BackgroundImageset, 100);

                if (RenderContext.ForegroundImageset != null)
                {
                    if (RenderContext.ViewCamera.Opacity != 100 && RenderContext.gl == null)
                    {
                        if (foregroundCanvas.Width != RenderContext.Width || foregroundCanvas.Height != RenderContext.Height)
                        {
                            foregroundCanvas.Width = (int)RenderContext.Width;
                            foregroundCanvas.Height = (int)RenderContext.Height;
                        }

                        CanvasContext2D saveDevice = RenderContext.Device;
                        fgDevice.ClearRect(0, 0, RenderContext.Width, RenderContext.Height);
                        RenderContext.Device = fgDevice;
                        RenderContext.DrawImageSet(RenderContext.ForegroundImageset, 100);
                        RenderContext.Device = saveDevice;
                        RenderContext.Device.Save();
                        RenderContext.Device.Alpha = RenderContext.ViewCamera.Opacity / 100;
                        RenderContext.Device.DrawImage(foregroundCanvas, 0, 0);
                        RenderContext.Device.Restore();
                    }
                    else
                    {
                        RenderContext.DrawImageSet(RenderContext.ForegroundImageset, RenderContext.ViewCamera.Opacity);
                    }

                }

                if (RenderType == ImageSetType.Sky)
                {
                    Planets.DrawPlanets(RenderContext, 1);

                    Constellation = Constellations.Containment.FindConstellationForPoint(RenderContext.ViewCamera.RA, RenderContext.ViewCamera.Dec);

                    DrawSkyOverlays();

                    LayerManager.Draw(RenderContext, 1.0f, true, "Sky", true, true);
                }

                if (RenderType == ImageSetType.Earth)
                {

                    LayerManager.Draw(RenderContext, 1.0f, false, "Earth", false, false);
                }

                if (Settings.Current.ShowCrosshairs)
                {
                    DrawCrosshairs(RenderContext);
                }

                if (uiController != null)
                {
                    uiController.Render(RenderContext);
                }
                else
                {
                    int index = 0;
                    foreach (Annotation item in annotations)
                    {
                        item.Draw(RenderContext);
                        index++;
                    }

                    if ((Date.Now - lastMouseMove) > 400)
                    {
                        Vector2d raDecDown = GetCoordinatesForScreenPoint(hoverTextPoint.X, hoverTextPoint.Y);
                        this.AnnotationHover(raDecDown.X, raDecDown.Y, hoverTextPoint.X, hoverTextPoint.Y);
                        lastMouseMove = new Date(2100, 1, 1);
                    }

                    if (!string.IsNullOrEmpty(hoverText))
                    {
                        DrawHoverText(RenderContext);
                    }
                }
            }
            //int tilesInView = Tile.TilesInView;
            //int itlesTouched = Tile.TilesTouched;

            frameCount++;

            //TileCache.PurgeLRU();
            TileCache.DecimateQueue();
            TileCache.ProcessQueue(RenderContext);
            Tile.CurrentRenderGeneration++;

            Date now = Date.Now;

            int ms = now-lastUpdate;
            if (ms > 1000)
            {

                lastUpdate = now;
                frameCount = 0;
                RenderTriangle.TrianglesRendered = 0;
                RenderTriangle.TrianglesCulled = 0;

            }

            //TileCache.PurgeLRU();
            Script.SetTimeout(delegate() { Render(); }, 20);
        }
예제 #41
0
        private Imageset GetRealImagesetFromGeneric(Imageset generic)
        {
            foreach (Imageset imageset in ImageSets)
            {
                if (imageset.DefaultSet && imageset.BandPass == generic.BandPass && imageset.DataSetType == generic.DataSetType)
                {
                    return imageset;
                }

            }

            foreach (Imageset imageset in ImageSets)
            {
                if (imageset.BandPass == generic.BandPass && imageset.DataSetType == generic.DataSetType)
                {
                    return imageset;
                }

            }
            return ImageSets[0];
        }
예제 #42
0
 public void FadeInImageSet(Imageset newImageSet)
 {
     if (RenderContext.BackgroundImageset != null &&
         newImageSet.DataSetType != RenderContext.BackgroundImageset.DataSetType)
     {
         TileCache.PurgeQueue();
         TileCache.ClearCache();
     }
     RenderContext.BackgroundImageset = newImageSet;
 }
예제 #43
0
        public void GotoTargetFull(bool noZoom, bool instant, CameraParameters cameraParams, Imageset studyImageSet, Imageset backgroundImageSet)
        {
            RenderNeeded = true;
            //if (cameraParams == this.viewCamera)
            //{
            //    instant = true;
            //}
            tracking = false;
            trackingObject = null;
            targetStudyImageset = studyImageSet;
            targetBackgroundImageset = backgroundImageSet;

            if (noZoom)
            {
                cameraParams.Zoom = RenderContext.ViewCamera.Zoom;
                cameraParams.Angle = RenderContext.ViewCamera.Angle;
                cameraParams.Rotation = RenderContext.ViewCamera.Rotation;
            }
            else
            {
                if (cameraParams.Zoom == -1 || cameraParams.Zoom == 0)
                {
                    if (RenderContext.Space)
                    {
                        cameraParams.Zoom = 1.40625;
                    }
                    else
                    {
                        cameraParams.Zoom = 0.09F;
                    }
                }
            }

            // if (instant || (Math.Abs(ViewLat - cameraParams.Lat) < .000000000001 && Math.Abs(ViewLong - cameraParams.Lng) < .000000000001 && Math.Abs(ZoomFactor - cameraParams.Zoom) < .000000000001))
            if (instant || (Math.Abs(RenderContext.ViewCamera.Lat - cameraParams.Lat) < .000000000001 && Math.Abs(RenderContext.ViewCamera.Lng - cameraParams.Lng) < .000000000001 && Math.Abs(RenderContext.ViewCamera.Zoom - cameraParams.Zoom) < .000000000001))
            {
                Mover = null;
                RenderContext.TargetCamera = cameraParams.Copy();
                RenderContext.ViewCamera = RenderContext.TargetCamera.Copy();

                //if (Space && Settings.Active.LocalHorizonMode)
                //{
                //    Coordinates currentAltAz = Coordinates.EquitorialToHorizon(Coordinates.FromRaDec(viewCamera.RA, viewCamera.Dec), SpaceTimeController.Location, SpaceTimeController.Now);

                //    targetAlt = alt = currentAltAz.Alt;
                //    targetAz = az = currentAltAz.Az;
                //}
                mover_Midpoint();
                moving = true;
            }
            else
            {

                Mover = ViewMoverSlew.Create(RenderContext.ViewCamera, cameraParams);
                RenderNeeded = true;
                Mover.Midpoint = mover_Midpoint;
            }
        }
예제 #44
0
        public static Imageset Create(string name, string url, ImageSetType dataSetType, BandPass bandPass, ProjectionType projection, int imageSetID, int baseLevel, int levels, int tileSize, double baseTileDegrees, string extension, bool bottomsUp, string quadTreeMap, double centerX, double centerY, double rotation, bool sparse, string thumbnailUrl, bool defaultSet, bool elevationModel, int wf, double offsetX, double offsetY, string credits, string creditsUrl, string demUrlIn, string alturl, double meanRadius, string referenceFrame)
        {
            Imageset temp = new Imageset();

            temp.ReferenceFrame = referenceFrame;
            temp.MeanRadius = meanRadius;
            temp.altUrl = alturl;
            temp.demUrl = demUrlIn;
            temp.creditsText = credits;
            temp.creditsUrl = creditsUrl;
            temp.offsetY = offsetY;
            temp.offsetX = offsetX;
            temp.widthFactor = wf;
            temp.elevationModel = elevationModel;
            temp.defaultSet = defaultSet;
            temp.name = name;
            temp.sparse = sparse;
            temp.dataSetType = dataSetType;
            temp.bandPass = bandPass;
            temp.quadTreeTileMap = quadTreeMap;
            temp.url = url;
            temp.levels = levels;
            temp.baseTileDegrees = baseTileDegrees;
            temp.imageSetID = imageSetID;
            temp.extension = extension;
            temp.projection = projection;
            temp.bottomsUp = bottomsUp;
            temp.baseLevel = baseLevel;
            temp.mercator = (projection == ProjectionType.Mercator);
            temp.centerX = centerX;
            temp.centerY = centerY;
            temp.rotation = rotation;
            temp.thumbnailUrl = thumbnailUrl;
            temp.ComputeMatrix();

            return temp;
        }
예제 #45
0
        public static Tile GetCachedTile(int level, int x, int y, Imageset dataset, Tile parent)
        {
            if (level < dataset.BaseLevel)
            {
                return null;
            }

            Tile retTile = null;
            string tileKey = Imageset.GetTileKey(dataset, level, x, y);
            try
            {
                if (!tiles.ContainsKey(tileKey))
                {
                    return null;
                }
                else
                {
                    retTile = tiles[tileKey];
                }
            }
            catch
            {
            }

            return retTile;
        }
예제 #46
0
        //internal static void AddTileToQueue(Tile tile)
        //{
        //    queue[tile.Key] = tile;
        //}
        public static Tile GetTile(int level, int x, int y, Imageset dataset, Tile parent)
        {
            Tile retTile = null;
            string tileKey = Imageset.GetTileKey(dataset, level, x, y);
               // try
            {
                if (!tiles.ContainsKey(tileKey))
                {
                    retTile = Imageset.GetNewTile(dataset, level, x, y, parent);
                    tiles[tileKey] = retTile;

                }
                else
                {
                    retTile = tiles[tileKey];
                }
            }
               // catch
            {
                int p = 0;
            }

            return retTile;
        }
예제 #47
0
        public void DrawImageSet(Imageset imageset, double opacity)
        {
            int maxX = GetTilesXForLevel(imageset, imageset.BaseLevel);
            int maxY = GetTilesYForLevel(imageset, imageset.BaseLevel);

            for (int x = 0; x < maxX; x++)
            {
                for (int y = 0; y < maxY; y++)
                {
                    Tile tile = TileCache.GetTile(imageset.BaseLevel, x, y, imageset, null);
                    if (tile != null)
                    {
                        tile.Draw3D(this, opacity);
                    }
                }
            }
        }