public async Task <List <ITimeCoordinate> > Filter(List <ITimeCoordinate> originalData)
        {
            var lines = new List <ITimeCoordinate>();

            await Task.Run(() =>
            {
                var numberOfErrorSpikes = 0;

                foreach (var timeCoordinate in originalData)
                {
                    var newPoint = new TimeCoordinate(
                        timeCoordinate.X,
                        timeCoordinate.Y,
                        timeCoordinate.Timestamp
                        );

                    if (!lines.Any())
                    {
                        lines.Add(newPoint);
                    }

                    if (!IsErrorSpike(lines.Last(), newPoint, numberOfErrorSpikes, ErrorSpike))
                    {
                        lines.Add(newPoint);
                        numberOfErrorSpikes = 0;
                    }
                    else
                    {
                        numberOfErrorSpikes++;
                    }
                }
            });

            return(lines);
        }
Example #2
0
        public ConstellationInfo(TimeCoordinate p, int coordRA, double coordDEC, StarPosition[] starInfo)
        {
            TimeCoordinate = p;
            CoordRA        = coordRA;
            CoordDEC       = coordDEC;
            StarPositions  = starInfo;

            Identifier = -1;
        }
Example #3
0
        public static int TimeCoordinateLocalization(TimeCoordinate TimeCoordinate)
        {
            switch (TimeCoordinate)
            {
            default:
            case TimeCoordinate.FiveToEight: return(1158506);

            case TimeCoordinate.NineToEleven: return(1158507);

            case TimeCoordinate.Midnight: return(1158508);

            case TimeCoordinate.OneToFour: return(1158509);
            }
        }
Example #4
0
        private static bool CheckExists(TimeCoordinate p, int ra, double dec)
        {
            for (var index = 0; index < Constellations.Count; index++)
            {
                var c = Constellations[index];

                if (c.TimeCoordinate == p && c.CoordRA == ra && c.CoordDEC == dec)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #5
0
        public static ConstellationInfo GetConstellation(TimeCoordinate p, int ra, double dec)
        {
            for (var index = 0; index < Constellations.Count; index++)
            {
                var c = Constellations[index];

                if (c.TimeCoordinate == p && c.CoordRA == ra && c.CoordDEC == dec)
                {
                    return(c);
                }
            }

            return(null);
        }
Example #6
0
        public static int RandomSkyImage(TimeCoordinate TimeCoordinate)
        {
            switch (TimeCoordinate)
            {
            default: return(0x67E);

            case TimeCoordinate.FiveToEight: return(0x67F);

            case TimeCoordinate.NineToEleven: return(Utility.RandomMinMax(0x680, 0x682));

            case TimeCoordinate.Midnight: return(0x686);

            case TimeCoordinate.OneToFour: return(Utility.RandomMinMax(0x683, 0x685));
            }
        }
Example #7
0
        private static void CreateConstellations(int amount)
        {
            TimeCoordinate next = TimeCoordinate.FiveToEight;

            if (LoadedConstellations > 0)
            {
                if (Constellations.Count(c => c.TimeCoordinate == TimeCoordinate.FiveToEight) > Constellations.Count(c => c.TimeCoordinate == TimeCoordinate.NineToEleven))
                {
                    next = TimeCoordinate.NineToEleven;
                }
                else if (Constellations.Count(c => c.TimeCoordinate == TimeCoordinate.NineToEleven) > Constellations.Count(c => c.TimeCoordinate == TimeCoordinate.Midnight))
                {
                    next = TimeCoordinate.Midnight;
                }
                else if (Constellations.Count(c => c.TimeCoordinate == TimeCoordinate.Midnight) > Constellations.Count(c => c.TimeCoordinate == TimeCoordinate.OneToFour))
                {
                    next = TimeCoordinate.OneToFour;
                }
            }

            for (int i = 0; i < amount; i++)
            {
                int    ra  = 0;
                double dec = 0.0;

                do
                {
                    ra  = Utility.RandomMinMax(0, MaxRA);
                    dec = Utility.RandomMinMax(0, (int)MaxDEC) + Utility.RandomList(.2, .4, .6, .8, .0);
                }while (CheckExists(next, ra, dec));

                ConstellationInfo info = new ConstellationInfo(next, ra, dec, ConstellationInfo.RandomStarPositions());
                Constellations.Add(info);

                info.Identifier = Constellations.Count - 1;

                switch (next)
                {
                case TimeCoordinate.FiveToEight: next = TimeCoordinate.NineToEleven; break;

                case TimeCoordinate.NineToEleven: next = TimeCoordinate.Midnight; break;

                case TimeCoordinate.Midnight: next = TimeCoordinate.OneToFour; break;

                case TimeCoordinate.OneToFour: next = TimeCoordinate.FiveToEight; break;
                }
            }
        }
Example #8
0
 private static bool CheckExists(TimeCoordinate p, int ra, double dec)
 {
     return(Constellations.Any(c => c.TimeCoordinate == p && c.CoordRA == ra && c.CoordDEC == dec));
 }
Example #9
0
 public static ConstellationInfo GetConstellation(TimeCoordinate p, int ra, double dec)
 {
     return(Constellations.FirstOrDefault(c => c.TimeCoordinate == p && c.CoordRA == ra && c.CoordDEC == dec));
 }
Example #10
0
        public override void OnResponse(RelayInfo info)
        {
            if (!User.InRange(Tele.Location, 2) || User.Map != Tele.Map)
            {
                return;
            }

            Tele.LastUse = DateTime.UtcNow;

            switch (info.ButtonID)
            {
            case 60000:     // RA 10's Up
                if (Tele.RA >= 20)
                {
                    Tele.RA -= 20;
                }
                else
                {
                    Tele.RA += 10;
                }
                User.SendSound(0x4A);
                break;

            case 60001:     // RA 10's Down
                if (Tele.RA < 10)
                {
                    Tele.RA += 20;
                }
                else
                {
                    Tele.RA -= 10;
                }
                User.SendSound(0x4A);
                break;

            case 60002:     // RA 1's Up
                int raOnes = GetPlace(Tele.RA, 1);

                if (raOnes >= 9)
                {
                    Tele.RA -= 9;
                }
                else
                {
                    Tele.RA++;
                }
                User.SendSound(0x4A);
                break;

            case 60003:     // RA 1's Down
                int raOnes1 = GetPlace(Tele.RA, 1);

                if (raOnes1 == 0)
                {
                    Tele.RA += 9;
                }
                else
                {
                    Tele.RA--;
                }
                User.SendSound(0x4A);
                break;

            case 60004:     // DEC 10's Up
                if (Tele.DEC >= 90)
                {
                    Tele.DEC -= 90;
                }
                else
                {
                    Tele.DEC += 10;
                }
                User.SendSound(0x4A);
                break;

            case 60005:     // DEC 10's Down
                if (Tele.DEC < 10)
                {
                    Tele.DEC += 90;
                }
                else
                {
                    Tele.DEC -= 10;
                }
                User.SendSound(0x4A);
                break;

            case 60006:     // DEC 1's Up
                int decOnes = GetPlace((int)Math.Truncate(Tele.DEC), 1);

                if (decOnes >= 9)
                {
                    Tele.DEC -= 9;
                }
                else
                {
                    Tele.DEC++;
                }
                User.SendSound(0x4A);
                break;

            case 60007:     // DEC 1's Down
                int decOnes1 = GetPlace((int)Math.Truncate(Tele.DEC), 1);

                if (decOnes1 <= 0)
                {
                    Tele.DEC += 9;
                }
                else
                {
                    Tele.DEC--;
                }
                User.SendSound(0x4A);
                break;

            case 60008:     // DEC .2 Up
                int dec = GetDecimalPlace(Tele.DEC);

                if (dec >= 8)
                {
                    Tele.DEC = Math.Truncate(Tele.DEC);
                }
                else
                {
                    Tele.DEC += .2;
                }
                User.SendSound(0x4A);
                break;

            case 60009:     // DEC .2 Down
                int dec1 = GetDecimalPlace(Tele.DEC);

                if (dec1 < 2)
                {
                    Tele.DEC += 0.8;
                }
                else if (dec1 == 2)
                {
                    Tele.DEC = Math.Truncate(Tele.DEC);
                }
                else
                {
                    Tele.DEC -= 0.2;
                }

                User.SendSound(0x4A);
                break;

            case 70000:     // View Coord
                if (Tele.RA > AstronomySystem.MaxRA || Tele.DEC > AstronomySystem.MaxDEC)
                {
                    User.SendLocalizedMessage(1158488);     // You have entered invalid coordinates.
                    User.SendSound(81);
                }
                else
                {
                    InterstellarObject = null;
                    Constellation      = null;
                    ImageID            = AstronomySystem.RandomSkyImage(User);

                    TimeCoordinate timeCoord = Tele.TimeCoordinate;

                    if (timeCoord == TimeCoordinate.Day)
                    {
                        User.SendLocalizedMessage(1158513);     // You won't have much luck seeing the night sky during the day...
                    }
                    else
                    {
                        ConstellationInfo constellation = AstronomySystem.GetConstellation(timeCoord, Tele.RA, Tele.DEC);

                        if (constellation != null)
                        {
                            Constellation = constellation;

                            User.SendLocalizedMessage(1158492, "", 0xBF);     // You peer into the heavens and see...a constellation!
                            User.SendSound(User.Female ? 0x32B : 0x43D);
                        }
                        else if (0.2 > Utility.RandomDouble())
                        {
                            InterstellarObject = AstronomySystem.GetRandomInterstellarObject();

                            User.SendLocalizedMessage(InterstellarObject.Item2, "", 0xBF);     //
                            User.SendSound(User.Female ? 0x32B : 0x43D);
                        }
                        else
                        {
                            User.SendLocalizedMessage(1158491, "", 0xBF);     // You peer into the heavens and see...only empty space...
                        }
                    }
                }

                Refresh();
                return;
            }

            if (info.ButtonID != 0)
            {
                Refresh();
            }
        }
Example #11
0
        private static void CreateConstellations(int amount)
        {
            TimeCoordinate next = TimeCoordinate.FiveToEight;

            if (LoadedConstellations > 0)
            {
                int count = 0;
                for (var index = 0; index < Constellations.Count; index++)
                {
                    var c = Constellations[index];

                    if (c.TimeCoordinate == TimeCoordinate.NineToEleven)
                    {
                        count++;
                    }
                }

                int count1 = 0;
                for (var index = 0; index < Constellations.Count; index++)
                {
                    var c = Constellations[index];
                    if (c.TimeCoordinate == TimeCoordinate.FiveToEight)
                    {
                        count1++;
                    }
                }

                if (count1 > count)
                {
                    next = TimeCoordinate.NineToEleven;
                }
                else
                {
                    int count2 = 0;
                    for (var index = 0; index < Constellations.Count; index++)
                    {
                        var c = Constellations[index];
                        if (c.TimeCoordinate == TimeCoordinate.Midnight)
                        {
                            count2++;
                        }
                    }

                    int count3 = 0;
                    for (var index = 0; index < Constellations.Count; index++)
                    {
                        var c = Constellations[index];
                        if (c.TimeCoordinate == TimeCoordinate.NineToEleven)
                        {
                            count3++;
                        }
                    }

                    if (count3 > count2)
                    {
                        next = TimeCoordinate.Midnight;
                    }
                    else
                    {
                        int count4 = 0;
                        for (var index = 0; index < Constellations.Count; index++)
                        {
                            var c = Constellations[index];
                            if (c.TimeCoordinate == TimeCoordinate.OneToFour)
                            {
                                count4++;
                            }
                        }

                        int count5 = 0;
                        for (var index = 0; index < Constellations.Count; index++)
                        {
                            var c = Constellations[index];
                            if (c.TimeCoordinate == TimeCoordinate.Midnight)
                            {
                                count5++;
                            }
                        }

                        if (count5 > count4)
                        {
                            next = TimeCoordinate.OneToFour;
                        }
                    }
                }
            }

            for (int i = 0; i < amount; i++)
            {
                int    ra  = 0;
                double dec = 0.0;

                do
                {
                    ra  = Utility.RandomMinMax(0, MaxRA);
                    dec = Utility.RandomMinMax(0, (int)MaxDEC) + Utility.RandomList(.2, .4, .6, .8, .0);
                }while (CheckExists(next, ra, dec));

                ConstellationInfo info = new ConstellationInfo(next, ra, dec, ConstellationInfo.RandomStarPositions());
                Constellations.Add(info);

                info.Identifier = Constellations.Count - 1;

                switch (next)
                {
                case TimeCoordinate.FiveToEight: next = TimeCoordinate.NineToEleven; break;

                case TimeCoordinate.NineToEleven: next = TimeCoordinate.Midnight; break;

                case TimeCoordinate.Midnight: next = TimeCoordinate.OneToFour; break;

                case TimeCoordinate.OneToFour: next = TimeCoordinate.FiveToEight; break;
                }
            }
        }