예제 #1
0
 private void fromView_Click(object sender, EventArgs e)
 {
     ra.Text   = Coordinates.FormatHMS(Earth3d.MainWindow.RA);
     dec.Text  = Coordinates.FormatDMS(Earth3d.MainWindow.Dec);
     mag.Text  = editTarget.Magnitude.ToString();
     zoom.Text = Coordinates.FormatDMS(Earth3d.MainWindow.ZoomFactor / 6);
 }
예제 #2
0
        public IPlace HoverCheck(Vector3 searchPoint, IPlace defaultPlace, float distance)
        {
            searchPoint = -searchPoint;
            Vector3 dist;

            if (defaultPlace != null)
            {
                Vector3 testPoint = Coordinates.RADecTo3d(defaultPlace.RA, -defaultPlace.Dec, -1.0).Vector311;
                dist     = searchPoint - testPoint;
                distance = dist.Length();
            }

            int closestItem = -1;
            int index       = 0;

            foreach (Vector3 point in positions)
            {
                dist = searchPoint - point;
                if (dist.Length() < distance)
                {
                    distance    = dist.Length();
                    closestItem = index;
                }
                index++;
            }

            lastHoverIndex = closestItem;

            if (closestItem == -1)
            {
                return(defaultPlace);
            }

            Coordinates pnt  = Coordinates.CartesianToSpherical(positions[closestItem]);
            string      name = this.names[closestItem];

            if (String.IsNullOrEmpty(name))
            {
                name = string.Format("RA={0}, Dec={1}", Coordinates.FormatHMS(pnt.RA), Coordinates.FormatDMS(pnt.Dec));
            }
            TourPlace place = new TourPlace(name, pnt.Dec, pnt.RA, Classification.Unidentified, "", ImageSetType.Sky, -1);

            return(place);
        }
예제 #3
0
        private void LoadTargetValues()
        {
            names.Text = UiTools.GetNamesStringFromArray(editTarget.Names);
            ra.Text    = Coordinates.FormatHMS(editTarget.RA);
            dec.Text   = Coordinates.FormatDMS(editTarget.Dec);
            mag.Text   = editTarget.Magnitude.ToString();
            zoom.Text  = Coordinates.FormatDMS(editTarget.ZoomLevel / 6);
            // todo localize and format
            DistanceValue.Text = editTarget.Distance.ToString();
            string fullName = "";

            if (Constellations.FullNames.ContainsKey(editTarget.Constellation))
            {
                fullName = Constellations.FullNames[editTarget.Constellation];
            }

            constellation.Items.Add("Undefined/Not Applicable");
            constellation.SelectedIndex = 0;
            foreach (string name in Constellations.FullNames.Values)
            {
                int index = constellation.Items.Add(name);
                if (name == fullName)
                {
                    constellation.SelectedIndex = index;
                }
            }
            SortedList <string, string> list = new SortedList <string, string>();

            foreach (string s in Enum.GetNames(typeof(Classification)))
            {
                list.Add(s, s);
            }

            foreach (string s in list.Values)
            {
                classification.Items.Add(s);
            }
            classification.SelectedIndex = classification.Items.IndexOf(editTarget.Classification.ToString());
        }
        private void UpdateLiveValues()
        {
            if (target != null)
            {
                if (target.Type == ImageSetType.Planet || target.Type == ImageSetType.Earth)
                {
                    UpdateLiveValuesPlanet();
                    return;
                }

                raText.Text  = Coordinates.FormatHMS(target.RA);
                decText.Text = Coordinates.FormatDMSWide(target.Dec);
                Coordinates altAz = Coordinates.EquitorialToHorizon(Coordinates.FromRaDec(target.RA, target.Dec), SpaceTimeController.Location, SpaceTimeController.Now);
                altText.Text = Coordinates.FormatDMSWide(altAz.Alt);
                azText.Text  = Coordinates.FormatDMSWide(altAz.Az);

                AstroCalc.RiseSetDetails details;
                // try
                {
                    if (target.Classification == Classification.SolarSystem)
                    {
                        double jNow             = ((int)((int)SpaceTimeController.JNow) + .5);
                        AstroCalc.AstroRaDec p1 = Planets.GetPlanetLocation(target.Name, jNow - 1);
                        AstroCalc.AstroRaDec p2 = Planets.GetPlanetLocation(target.Name, jNow);
                        AstroCalc.AstroRaDec p3 = Planets.GetPlanetLocation(target.Name, jNow + 1);

                        int type = 0;
                        switch (target.Name)
                        {
                        case "Sun":
                            type = 1;
                            break;

                        case "Moon":
                            type = 2;
                            break;

                        default:
                            type = 0;
                            break;
                        }
                        details = AstroCalc.AstroCalc.GetRiseTrinsitSet(jNow, SpaceTimeController.Location.Lat, -SpaceTimeController.Location.Lng, p1.RA, p1.Dec, p2.RA, p2.Dec, p3.RA, p3.Dec, type);
                    }
                    else
                    {
                        details = AstroCalc.AstroCalc.GetRiseTrinsitSet(((int)SpaceTimeController.JNow) + .5, SpaceTimeController.Location.Lat, -SpaceTimeController.Location.Lng, target.RA, Target.Dec, target.RA, Target.Dec, target.RA, Target.Dec, 0);
                    }


                    if (details.bValid)
                    {
                        riseText.Text    = UiTools.FormatDecimalHours(details.Rise);
                        transitText.Text = UiTools.FormatDecimalHours(details.Transit);
                        setText.Text     = UiTools.FormatDecimalHours(details.Set);
                    }
                    else
                    {
                        if (details.bNeverRises)
                        {
                            riseText.Text = transitText.Text = setText.Text = Language.GetLocalizedText(934, "Never Rises");
                        }
                        else
                        {
                            riseText.Text = transitText.Text = setText.Text = Language.GetLocalizedText(935, "Never Sets");
                        }
                    }
                    if (target.Distance != 0)
                    {
                        this.distanceValue.Text = UiTools.FormatDistance(target.Distance);
                    }
                    else
                    {
                        this.distanceValue.Text = Language.GetLocalizedText(281, "n/a");
                    }
                }
                //catch
                {
                }
            }
        }
예제 #5
0
        public override IPlace FindClosest(Coordinates target, float distance, IPlace defaultPlace, bool astronomical)
        {
            Vector3d searchPoint = Coordinates.GeoTo3dDouble(target.Lat, target.Lng);

            //searchPoint = -searchPoint;
            Vector3d dist;

            if (defaultPlace != null)
            {
                Vector3d testPoint = Coordinates.RADecTo3d(defaultPlace.RA, -defaultPlace.Dec, -1.0);
                dist     = searchPoint - testPoint;
                distance = (float)dist.Length();
            }

            int closestItem = -1;
            int index       = 0;

            foreach (Vector3 point in positions)
            {
                dist = searchPoint - new Vector3d(point);
                if (dist.Length() < distance)
                {
                    distance    = (float)dist.Length();
                    closestItem = index;
                }
                index++;
            }


            if (closestItem == -1)
            {
                return(defaultPlace);
            }

            Coordinates pnt = Coordinates.CartesianToSpherical2(positions[closestItem]);

            string name = table.Rows[closestItem].ColumnData[this.nameColumn].ToString();

            if (nameColumn == startDateColumn || nameColumn == endDateColumn)
            {
                name = SpreadSheetLayer.ParseDate(name).ToString("u");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = string.Format("RA={0}, Dec={1}", Coordinates.FormatHMS(pnt.RA), Coordinates.FormatDMS(pnt.Dec));
            }
            TourPlace place = new TourPlace(name, pnt.Lat, pnt.RA, Classification.Unidentified, "", ImageSetType.Sky, -1);

            Dictionary <String, String> rowData = new Dictionary <string, string>();

            for (int i = 0; i < table.Columns.Count; i++)
            {
                string colValue = table.Rows[closestItem][i].ToString();
                if (i == startDateColumn || i == endDateColumn)
                {
                    colValue = SpreadSheetLayer.ParseDate(colValue).ToString("u");
                }

                if (!rowData.ContainsKey(table.Column[i].Name) && !string.IsNullOrEmpty(table.Column[i].Name))
                {
                    rowData.Add(table.Column[i].Name, colValue);
                }
                else
                {
                    rowData.Add("Column" + i.ToString(), colValue);
                }
            }
            place.Tag = rowData;
            if (Viewer != null)
            {
                Viewer.LabelClicked(closestItem);
            }
            return(place);
        }