string GetStringValue(object value)
        {
            if (value == null)
            {
                return("null");
            }

            if (value is string)
            {
                return((string)value + " " + units);
            }

            if (value is int)
            {
                return(((int)value).ToString() + " " + units);
            }

            double doubleValue = -999;

            if (value is double)
            {
                doubleValue = (double)value;
            }
            else if (value is float)
            {
                doubleValue = (float)value;
            }
            else if (value is MovingAverage)
            {
                doubleValue = (MovingAverage)value;
            }
            else if (value is Vector3d)
            {
                doubleValue = ((Vector3d)value).magnitude;
            }
            else if (value is Vector3)
            {
                doubleValue = ((Vector3)value).magnitude;
            }
            else if (value is EditableDouble)
            {
                doubleValue = (EditableDouble)value;
            }

            if (format == TIME)
            {
                return(GuiUtils.TimeToDHMS(doubleValue, timeDecimalPlaces));
            }
            else if (format == ANGLE)
            {
                return(Coordinates.AngleToDMS(doubleValue));
            }
            else if (format == ANGLE_NS)
            {
                return(Coordinates.AngleToDMS(doubleValue) + " " + (doubleValue > 0 ? "N" : "S"));
            }
            else if (format == ANGLE_EW)
            {
                return(Coordinates.AngleToDMS(doubleValue) + " " + (doubleValue > 0 ? "E" : "W"));
            }
            else if (format == SI)
            {
                return(MuUtils.ToSI(doubleValue, siMaxPrecision, siSigFigs) + units);
            }
            else
            {
                return(doubleValue.ToString(format) + " " + units);
            }
        }
Beispiel #2
0
 public string GetCoordinateString()
 {
     return(Coordinates.ToStringDMS(vesselState.latitude, vesselState.longitude, true));
 }