Beispiel #1
0
        //Formats the decimal degree value into Degree Minute and Seconds according to the increment. It also looks
        //if the longitude is East or West and the latitude North or South.
        private string FormatLatLong(double value, LineType lineType, double increment)
        {
            string result = "";

            try
            {
                if (increment >= 1)
                {
                    result = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(Math.Abs(value));
                    result = result.Substring(0, result.Length - 9);
                }
                else if (increment >= 0.1)
                {
                    result = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(Math.Abs(value));
                    result = result.Substring(0, result.Length - 5);
                }
                else if (increment >= 0.01)
                {
                    result = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(Math.Abs(value));
                }
                else
                {
                    result = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(Math.Abs(value), 2);
                }

                if (lineType == LineType.Meridian)
                {
                    if (value > 0)
                    {
                        result = result + " E";
                    }
                    else if (value < 0)
                    {
                        result = result + " W";
                    }
                }

                if (lineType == LineType.Parallel)
                {
                    if (value > 0)
                    {
                        result = result + " N";
                    }
                    else if (value < 0)
                    {
                        result = result + " S";
                    }
                }
            }
            catch
            { result = "N/A"; }
            finally {}

            return(result);
        }
Beispiel #2
0
        //Displays the world coordinates for the mouse pointer in decimal degrees and Degrees Minutes Seconds form.
        private void winformsMap1_MouseMove(object sender, MouseEventArgs e)
        {
            PointShape worldPointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, new ScreenPointF(e.X, e.Y), winformsMap1.Width, winformsMap1.Height);

            try
            {
                lblLongitudeDMS.Text = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(worldPointShape.X);
                lblLatitudeDMS.Text  = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(worldPointShape.Y);

                lblLongitude.Text = System.Convert.ToString(worldPointShape.X);
                lblLatitude.Text  = System.Convert.ToString(worldPointShape.Y);
            }
            catch
            {
                lblLongitudeDMS.Text = "N/A";
                lblLatitudeDMS.Text  = "N/A";

                lblLongitude.Text = "N/A";
                lblLatitude.Text  = "N/A";
            }
            finally { }
        }