Exemplo n.º 1
0
 /// <summary>
 /// Date        Coder       Vers        Notes
 /// 2020-01-09  Clay        1.0         Initial
 ///
 /// There will be several overloads for the constructor.
 /// </summary>
 /// <param name="L"></param>
 /// <param name="N"></param>
 /// <param name="ZType"></param>
 /// <param name="Size"></param>
 public Horde(GeoEngine_Workspace.Location L, String N, ZType ZType, HordeSize Size)
 {
     this.ContactLocation  = L;
     this.ContactName      = N;
     this.ContactType      = ZType;
     this.ContactHordeSize = Size;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Name: Zombie
 /// Purpose: Default Constructor
 ///
 /// Date        Coder       Vers        Notes
 /// 2020-01-08  Clay        1.0         Initial
 /// 2020-01-09  Clay        1.1         Added the references to the new variables
 ///
 /// </summary>
 public Zombie()
 {
     //Beware the defaults used when not passing the details to the location
     //constructor.
     ContactLocation = new GeoEngine_Workspace.Location();
     ContactName     = "";
     //ContactType = ZType.Slow;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Date        Coder       Vers        Notes
 /// 2020-01-18  Clay        1.0         Initial
 ///
 ///
 /// This is the biggie constructor without the Serial Number.
 /// Why would I need to different constructors. The answer is
 /// to remember who gives out the serial numbers. The database. :)
 /// </summary>
 /// <param name="Lat"></param>
 /// <param name="Long"></param>
 /// <param name="Elevate"></param>
 /// <param name="Year"></param>
 /// <param name="Month"></param>
 /// <param name="Day"></param>
 /// <param name="ZType"></param>
 /// <param name="Name"></param>
 public Zombie(double Lat, double Long, double Elevate, int Year, int Month, int Day, ZType ZType, String Name)
 {
     ContactLocation = new GeoEngine_Workspace.Location(Lat, Long, Elevate);
     ContactLocation.SetDate(Year, Month, Day);
     ContactType        = ZType;
     ContactName        = Name;
     ZombieSerialNumber = 0;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Calculates a location object based on a location object start, a distance and a bearing
        /// </summary>
        /// <param name="loc1"></param>
        /// <param name="dist"></param>
        /// <param name="brng"></param>
        /// <param name="unit"></param>
        /// <returns></returns>
        public GeoEngine_Workspace.Location DestinationPoint(GeoEngine_Workspace.Location loc1, double dist, double brng, char unit)
        {
            var distRatio       = dist / EarthRadiusInKilometers;
            var distRatioSine   = Math.Sin(distRatio);
            var distRatioCosine = Math.Cos(distRatio);

            var startLatRad = deg2rad(loc1.Latitude);
            var startLonRad = deg2rad(loc1.Longitude);

            var startLatCos = Math.Cos(startLatRad);
            var startLatSin = Math.Sin(startLatRad);

            var endLatRads = Math.Asin((startLatSin * distRatioCosine) + (startLatCos * distRatioSine * Math.Cos(deg2rad(brng))));

            var endLonRads = startLonRad
                             + Math.Atan2(
                Math.Sin(deg2rad(brng)) * distRatioSine * startLatCos,
                distRatioCosine - startLatSin * Math.Sin(endLatRads));

            return(new Location(Math.Round(rad2deg(endLatRads), 3), Math.Round(rad2deg(endLonRads), 3)));


            //double R;
            //if (unit == 'm')
            //{
            //    R = EarthRadiusInKilometers;
            //}
            //else
            //{
            //    R = EarthRadiusInMiles;
            //}

            //dist = dist / R;
            //brng = Math.PI * brng / 180;
            //double lat1 = deg2rad(loc1.Latitude);
            //double lon1 = deg2rad(loc1.Longitude);
            //double lat2 = Math.Asin(Math.Sin(lat1) * Math.Cos(dist) + Math.Cos(lat1) * Math.Sin(dist) * Math.Cos(brng));
            //double lon2 = lon1 + Math.Atan2(Math.Sin(brng) * Math.Sin(dist) * Math.Cos(lat1), Math.Cos(dist) - Math.Sin(lat1) * Math.Sin(lat2));
            //lon2 = (lon2 + 3 * Math.PI) % (2 * Math.PI) - Math.PI;
            //lat2 = rad2deg(lat2);
            //lon2 = rad2deg(lon2);
            //GeoEngine_Workspace.Location temp = new GeoEngine_Workspace.Location(lat2, lon2);
            //return temp;
        }
Exemplo n.º 5
0
        public static int CreateMarker(String Name, Double Elevation, String Date, int Serial, String ContactType, Double Lat, Double Long)
        {
            //We are going to have to some syntax acrobatics to get the Zombie in the database.
            //Lets try to figure the date out

            DataObjects.Toolset Tools = new DataObjects.Toolset();

            NodaTime.LocalDate           D   = Tools.StringToNodaDate(Date);
            GeoEngine_Workspace.Location Loc = new GeoEngine_Workspace.Location(Lat, Long, Elevation);
            Loc.SetDate(D.Year, D.Month, D.Day);

            DataObjects.Zombie Z = new DataObjects.Zombie(Loc, Name, DataObjects.Zombie.ZType.Slow);
            Z.SetZType(ContactType);
            DataObjects.Zombie ReturnZombie = new DataObjects.Zombie();
            using (DataAccessClass.DataAccessClass TheDatabase = new DataAccessClass.DataAccessClass())
            {
                ReturnZombie = TheDatabase.InsertZombie(Z);
            }
            return(ReturnZombie.ZombieSerialNumber);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Calculates the distance between two location objects
        /// </summary>
        /// <param name="loc1"></param>
        /// <param name="loc2"></param>
        /// <param name="unit"></param>
        /// <returns></returns>
        public double Distance(GeoEngine_Workspace.Location loc1, GeoEngine_Workspace.Location loc2, char unit)
        {
            double R;

            if (unit == 'm')
            {
                R = EarthRadiusInKilometers;
            }
            else
            {
                R = EarthRadiusInMiles;
            }

            double dLat     = deg2rad(loc2.Latitude) - deg2rad(loc1.Latitude);
            double dLon     = deg2rad(loc2.Longitude) - deg2rad(loc1.Longitude);
            double a        = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) + Math.Cos(deg2rad(loc1.Latitude)) * Math.Cos(deg2rad(loc2.Latitude)) * Math.Sin(dLon / 2) * Math.Sin(dLon / 2);
            double c        = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
            double distance = c * R;

            return(Math.Round(distance, 2));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Calculates the bearing between two location objects
        /// Altered at 2019-10-30. New Code.
        /// </summary>
        /// <param name="loc1"></param>
        /// <param name="loc2"></param>
        /// <param name="lat1"></param>
        /// <returns></returns>
        public double BearingTo(GeoEngine_Workspace.Location loc1, GeoEngine_Workspace.Location loc2)
        {
            var dLon = deg2rad(loc2.Longitude - loc1.Longitude);
            var dPhi = Math.Log(
                Math.Tan(deg2rad(loc2.Latitude) / 2 + Math.PI / 4) / Math.Tan(deg2rad(loc1.Latitude) / 2 + Math.PI / 4));

            if (Math.Abs(dLon) > Math.PI)
            {
                dLon = dLon > 0 ? -(2 * Math.PI - dLon) : (2 * Math.PI + dLon);
            }
            return(ToBearing(Math.Atan2(dLon, dPhi)));

            //double dlat1 = deg2rad(loc1.Latitude);
            //double dlat2 = deg2rad(loc2.Latitude);
            //double dLon = deg2rad(loc1.Longitude) - deg2rad(loc2.Longitude);

            //double y = Math.Sin(dLon) * Math.Cos(dlat2);
            //double x = Math.Cos(dlat1) * Math.Sin(dlat2) - Math.Sin(dlat1) * Math.Cos(dlat2) * Math.Cos(dLon);
            //double brng = Math.Atan2(y, x);
            //return (rad2deg(brng) + 360) % 360;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Date        Coder       Vers        Notes
 /// 2020-01-09  Clay        1.0         Initial
 ///
 /// There will be several overloads for the constructor.
 /// </summary>
 /// <param name="L"></param>
 /// <param name="N"></param>
 /// <param name="ZType"></param>
 public Zombie(GeoEngine_Workspace.Location L, String N, ZType ZType)
 {
     ContactLocation = L;
     ContactName     = N;
     ContactType     = ZType;
 }
Exemplo n.º 9
0
 public void Add(GeoEngine_Workspace.Location Loc)
 {
     Route.Add(Loc);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Date        Coder       Vers        Notes
        /// 2020-01-17  Clay        1.0         Initial
        /// 2020-01-21  Clay        1.1         Refactored to always keep at least 20
        ///                                     records in the DB.
        ///
        /// </summary>
        /// <returns></returns>
        private static bool TestCode()
        {
            DataAccessClass.DataAccessClass TheDataBase = new DataAccessClass.DataAccessClass();

            List <DataObjects.Zombie> CurrentData = TheDataBase.GetAllZombies();

            if (CurrentData.Count < 200)
            {
                DataAccessClass.TestDataGenerator GenerateData = new DataAccessClass.TestDataGenerator(200, new NodaTime.LocalDate(2019, 01, 05), new NodaTime.LocalDate(2020, 01, 10));
                List <DataObjects.Zombie>         TestData     = GenerateData.GenerateTestData();
                foreach (DataObjects.Zombie Z in TestData)
                {
                    TheDataBase.InsertZombie(Z);
                }
            }

            List <DataObjects.TrackObject> TrackLists = new List <DataObjects.TrackObject>();

            TrackLists = TheDataBase.GetTrackByID(1);



            //Create a Zombie
            DataObjects.Zombie Z10 = new DataObjects.Zombie(45.5, -81.5, 110, 2020, 01, 18, DataObjects.Zombie.ZType.Slow, "Fred the Zombie", 0);
            //Send it to the database
            DataObjects.Zombie Z20 = TheDataBase.InsertZombie(Z10);
            //Get another back from the database.
            DataObjects.Zombie Z30 = TheDataBase.GetZombieByID(Z20.ZombieSerialNumber);
            if (Z20 == Z30)
            {
                int x = 0;
            }



            //Now I need to organize some tests before I go any further...
            //So I can build some tests.

            //Test down to the database.
            DataAccessClass.DataAccessClass TheDatabase = new DataAccessClass.DataAccessClass();

            //Lets add a Zombie to the database
            DataObjects.Zombie Z0 = new DataObjects.Zombie(23.5, 34.989, 100, 1990, 02, 13, DataObjects.Zombie.ZType.Medium, "Charles");
            DataObjects.Zombie Z1 = TheDatabase.InsertZombie(Z0);

            //Now are these two zombies the same. Aside from the SerialNumber they should
            //be. That would be an important test that system works. If only there was an
            //easy way to compare zombies. We cant use this code. It will not work..yet.

            //if(Z0 == Z1)
            //{
            //    Console.WriteLine("Insert functioning properly.")
            //}

            //So lets get all the zombies.
            List <DataObjects.Zombie> TheZombieList = TheDatabase.GetAllZombies();

            //Lets get a zombie by its Primary Key.
            if (TheZombieList.Count >= 1)
            {
                DataObjects.Zombie TestZombie = TheDatabase.GetZombieByID(TheZombieList[0].ZombieSerialNumber);
            }

            //Lets update a zombie and then compare what we get using the GetZombieByID again.
            Z1.ContactType = DataObjects.Zombie.ZType.Fast;
            Z1.ContactName = "Simon Pegg";

            DataObjects.Zombie Z2 = TheDatabase.UpdateZombieByID(Z1);

            DataObjects.Zombie Z3 = TheDatabase.GetZombieByID(Z2.ZombieSerialNumber);

            //And we have to delete a Zombie by its pk.
            int ZombieAlive = TheDatabase.DeleteZombieByID(Z2.ZombieSerialNumber);


            GeoEngine_Workspace.Location L = new GeoEngine_Workspace.Location();
            Z0.MakeNoise();
            Console.ReadLine();

            DataObjects.Zombie Z4 = new DataObjects.Zombie();
            Z2.ContactType = DataObjects.Zombie.ZType.Fast;

            if (Z2.ContactType == DataObjects.Zombie.ZType.Fast)
            {
                Console.WriteLine("Fast");
            }
            return(true);
        }