Пример #1
0
        /// <summary>
        /// Add a node to this storm.
        ///
        /// STM is temporary until globalstate is ported over
        ///
        /// create NodeInformation class later
        /// </summary>
        public void AddNode(int Intensity, StormType2 Type, Point Pos, int Pressure) // String in this case bad but swnabhfabg
        {
            Node NewNode = new Node();

            // Determine intensity.
            NewNode.Intensity = Intensity;

            // Get node type.
            NewNode.NodeType = Type;

            // Get id.
            NewNode.Id = NodeList.Count;

            if (Pressure < 0)
            {
                Error.Throw("Warning", "Pressure cannot be less than zero!", ErrorSeverity.Warning, 400);
            }
            else
            {
                NewNode.Pressure = Pressure;
            }

            // Set node position.

            RelativePositionConverter RPC = new RelativePositionConverter();
            RelativePosition          RP  = (RelativePosition)RPC.ConvertBack(Pos, typeof(RelativePosition), null, null);

            NewNode.Position = RP;

            Logging.Log($"Adding node");
            // Add.
            NodeList.Add(NewNode);
        }
Пример #2
0
        /// <summary>
        /// Add a node to this storm.
        ///
        /// STM is temporary until globalstate is ported over
        ///
        /// create NodeInformation class later
        /// </summary>
        public void AddNode(int Intensity, string Type, Point Pos, int Pressure, StormTypeManager TEMP__ST2Manager) // String in this case bad but swnabhfabg
        {
            Node NewNode = new Node();

            // Determine intensity.
            NewNode.Intensity = Intensity;

            // Get node type.
            NewNode.NodeType = TEMP__ST2Manager.GetStormTypeWithName(Type);

            // Get id.
            NewNode.Id = NodeList.Count;

            if (Pressure < 0)
            {
                Error.Throw("Warning", "Pressure cannot be less than zero!", ErrorSeverity.Warning, 400);
            }
            else
            {
                NewNode.Pressure = Pressure;
            }

            // dumb but it works!
            RelativePositionConverter RPC = new RelativePositionConverter();

            NewNode.Position = (RelativePosition)RPC.Convert(Pos, typeof(RelativePosition), null, null);


            Logging.Log($"Adding node");
            // Add.
            NodeList.Add(NewNode);
        }
Пример #3
0
        public RelativePosition FromCoordinateToRelativeNodePosition(Coordinate Coord, Point WindowSize)
        {
            Debug.Assert(Coord.Directions.Count == 2);

            double LowX  = CoordsLower.Coordinates.X;
            double LowY  = CoordsLower.Coordinates.Y;
            double HighX = CoordsHigher.Coordinates.X;
            double HighY = CoordsHigher.Coordinates.Y;

            // convert to absolute coordinate
            foreach (CardinalDirection CD in CoordsLower.Directions)
            {
                switch (CD)
                {
                case CardinalDirection.W:
                    LowX = -LowX;
                    continue;

                case CardinalDirection.S:
                    LowY = -LowY;
                    continue;
                }
            }

            // convert to absolute coordinate
            foreach (CardinalDirection CD in CoordsHigher.Directions)
            {
                switch (CD)
                {
                case CardinalDirection.W:
                    HighX = -HighX;
                    continue;

                case CardinalDirection.S:
                    HighY = -HighY;
                    continue;
                }
            }

            // get the multiplier from the coordshigher.

            double PreFinalX = 0.991823613;
            double PreFinalY = 0.991823613;

            if (HighX > LowX)
            {
                PreFinalX = Coord.Coordinates.X / (HighX - LowX);
            }
            else
            {
                PreFinalX = Coord.Coordinates.X / (LowX - HighX);
            }

            if (HighY > LowY)
            {
                PreFinalY = Coord.Coordinates.Y / (HighY - LowY);
            }
            else
            {
                PreFinalY = Coord.Coordinates.Y / (LowY - HighY);
            }

            if (PreFinalX == 0.991823613 || PreFinalY == 0.991823613)
            {
                Error.Throw("Error", "Error translating coordinates - internal ATCF import error", ErrorSeverity.Error, 320);
                return(new RelativePosition(0.991823613, 0.991823613));
            }

            // atcf fix
            Point FinalPos = new Point(WindowSize.Y * PreFinalY, WindowSize.X * PreFinalX);

            RelativePositionConverter RPC = new RelativePositionConverter();
            RelativePosition          RP  = (RelativePosition)RPC.Convert(FinalPos, typeof(RelativePosition), null, null);

            return(RP);
        }
Пример #4
0
        // Basin API for Priscilla
        public Coordinate FromNodePositionToCoordinate(RelativePosition NodePosition, Point WindowSize)
        {
            RelativePositionConverter RPC = new RelativePositionConverter();
            Point Pt = (Point)RPC.ConvertBack(NodePosition, typeof(Point), null, null);

            Coordinate Coord = new Coordinate();

            //Convert
            double X1 = CoordsLower.Coordinates.X;
            double Y1 = CoordsLower.Coordinates.Y;
            double X2 = CoordsHigher.Coordinates.X;
            double Y2 = CoordsHigher.Coordinates.Y;

            // Convert to negative

            foreach (CardinalDirection Cardir in CoordsLower.Directions)
            {
                switch (Cardir)
                {
                case CardinalDirection.W:
                    X1 = -X1;
                    continue;

                case CardinalDirection.S:
                    Y1 = -Y1;
                    continue;
                }
            }

            foreach (CardinalDirection Cardir in CoordsHigher.Directions)
            {
                switch (Cardir)
                {
                case CardinalDirection.W:
                    X2 = -X2;
                    continue;

                case CardinalDirection.S:
                    Y2 = -Y2;
                    continue;
                }
            }


            double WindowMultiplierPositionX = Pt.X / WindowSize.X;
            double WindowMultiplierPositionY = Pt.Y / WindowSize.Y;

            double FinalX = -2.999126165;
            double FinalY = -2.999126165;

            if (X1 <= 0 && X2 <= 0)
            {
                WindowMultiplierPositionX = -WindowMultiplierPositionX;
            }
            if (Y1 <= 0 && Y2 <= 0)
            {
                WindowMultiplierPositionY = -WindowMultiplierPositionY;
            }

            // this is so the user can input the coordinates in any way they want.
            if (X2 < X1)
            {
                FinalX = (X1 - X2) * WindowMultiplierPositionX;
            }
            else
            {
                FinalX = (X2 - X1) * WindowMultiplierPositionX;
            }

            if (Y2 < Y1)
            {
                FinalY = (Y1 - Y2) * WindowMultiplierPositionY;
            }
            else
            {
                FinalY = (Y2 - Y1) * WindowMultiplierPositionY;
            }

            if (FinalX == -2.999126165 || FinalY == -2.999126125)
            {
                Error.Throw("Error!", "Failed to set FinalX!", ErrorSeverity.Error, 277);
                return(null);
            }

            string _s  = FinalX.ToString();
            string _s2 = FinalY.ToString();

            string[] _s3 = _s.Split('.');
            string[] _s5 = _s2.Split('.');

            if (_s3.Length != 0)
            {
                // Truncate to the first decimal point if there are decimal points

                // rename this in iris
                string _s4 = "";

                if (_s3.Length == 1)
                {
                    _s4 = _s3[0];
                }
                else
                {
                    _s4 = _s3[1].Substring(0, 1);
                }


                // Concanectate
                _s4 = $"{_s3[0]}{_s4}";

                // Convert back
                FinalX = Convert.ToDouble(_s4);
            }

            if (_s5.Length != 0)
            {
                // Truncate to the first decimal point if there are decimal points

                string _s6 = "";

                // fixes crash with nodes that are very high up
                // on the screen
                if (_s5.Length == 1)
                {
                    _s6 = _s5[0];
                }
                else
                {
                    _s6 = _s5[1].Substring(0, 1);
                }

                // Concanectate
                _s6 = $"{_s5[0]}{_s6}";

                // Convert back
                FinalY = Convert.ToDouble(_s6);
            }

            Coord.Directions = new List <CardinalDirection>();


            if (FinalY < 0)
            {
                FinalY = -FinalY;
                Coord.Directions.Add(CardinalDirection.S);
            }
            else
            {
                Coord.Directions.Add(CardinalDirection.N);
            }

            if (FinalX < 0)
            {
                FinalX = -FinalX;
                Coord.Directions.Add(CardinalDirection.W);
            }
            else
            {
                Coord.Directions.Add(CardinalDirection.E);
            }


            // ATCF moment
            Coord.Coordinates = new Point(FinalY, FinalX);

            return(Coord);
        }