Exemplo n.º 1
0
        /// <summary>
        ///     Registers the device location.
        /// </summary>
        /// <param name="deviceId">The device identifier.</param>
        /// <param name="latitude">The latitude.</param>
        /// <param name="longitude">The longitude.</param>
        /// <param name="altitude">The altitude.</param>
        /// <param name="bearing">The bearing.</param>
        /// <param name="speed">The speed.</param>
        /// <returns>DeviceLocation.</returns>
        public DeviceLocation RegisterDeviceLocation(string deviceId, double latitude, double longitude, double altitude,
                                                     float bearing, float speed)
        {
            DeviceLocation loc = null;

            try
            {
                loc = new DeviceLocation
                {
                    Device           = deviceId,
                    Accuracy         = (float)0.0,
                    Altitude         = altitude,
                    Bearing          = bearing,
                    Speed            = speed,
                    Latitude         = latitude,
                    Longitude        = longitude,
                    DisplayAltitude  = String.Format("{0:n0}m", altitude),
                    DisplayBearing   = GeoAngle.FromDouble(bearing).ToString(),
                    DisplayGrid      = CalculateGrid(latitude, longitude),
                    DisplayLatitude  = GeoAngle.FromDouble(latitude).ToString(LocationFormat.Latitude),
                    DisplayLongitude = GeoAngle.FromDouble(longitude).ToString(LocationFormat.Longtitude),
                    DisplaySpeed     = String.Format("{0:n1}m/s", speed)
                };
                LocationLog locLog = loc.ToLocationLog();
                locLog = LatiPortal
                         .Latis
                         .RegisterLocation(locLog);
                return(loc);
            }
            catch (Exception exception)
            {
                _logger.Error(exception.GetCombinedMessages());
                return(loc);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Gets the call sign information.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="clientLat">The client lat.</param>
        /// <param name="clientLon">The client lon.</param>
        /// <param name="unit">The unit.</param>
        /// <returns>CallSignInfo.</returns>
        public CallSignInfo GetCallSignInfo(string id, double clientLat, double clientLon, string unit)
        {
            id = id.ToUpper();
            CallSignInfo res = null;
            StationItem  it  = HamRadioProvider.HamRadio
                               .GetStationInfo(id);

            if (it.SessionId == "UNKNOWN")
            {
                res = it.ToUnknown();
            }
            else
            {
                res                 = it.ToCallSignInfo();
                res.LongPath        = GetLongPath(it, clientLat, clientLon, unit);
                res.ShortPath       = GetShortPath(it, clientLat, clientLon, unit);
                res.Bearing         = GetBearing(it, clientLat, clientLon);
                res.DisplayLatitude =
                    GeoAngle.FromDouble(Convert.ToDouble(it.Latitude)).ToString(LocationFormat.Latitude);
                res.DisplayLongitude =
                    GeoAngle.FromDouble(Convert.ToDouble(it.Longitude)).ToString(LocationFormat.Longtitude);
            }
            res.YourDisplayLatitude  = GeoAngle.FromDouble(clientLat).ToString(LocationFormat.Latitude);
            res.YourDisplayLongitude = GeoAngle.FromDouble(clientLon).ToString(LocationFormat.Longtitude);
            res.YourGrid             = CalculateGrid(clientLat, clientLon);
            return(res);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Gets the bearing.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="clientLat">The client lat.</param>
        /// <param name="clientLon">The client lon.</param>
        /// <returns>System.String.</returns>
        public static string GetBearing(StationItem item, double clientLat, double clientLon)
        {
            double lat = Convert.ToDouble(item.Latitude);
            double lon = Convert.ToDouble(item.Longitude);

            return(GeoAngle.FromDouble(GeoUtils.BearingTo(clientLat, lat, clientLon, lon)).ToString());
        }
    public static GeoAngle FromDouble(double angleInDegrees)
    {
        //ensure the value will fall within the primary range [-180.0..+180.0]
        while (angleInDegrees < -180.0)
        {
            angleInDegrees += 360.0;
        }
        while (angleInDegrees > 180.0)
        {
            angleInDegrees -= 360.0;
        }
        var result = new GeoAngle();

        //switch the value to positive
        result.IsNegative = angleInDegrees < 0;
        angleInDegrees    = Math.Abs(angleInDegrees);
        //gets the degree
        result.Degrees = (int)Math.Floor(angleInDegrees);
        var delta = angleInDegrees - result.Degrees;
        //gets minutes and seconds
        var seconds = (int)Math.Floor(3600.0 * delta);

        result.Seconds = seconds % 60;
        result.Minutes = (int)Math.Floor(seconds / 60.0);
        delta          = delta * 3600.0 - seconds;
        //gets fractions
        result.Milliseconds = (int)(1000.0 * delta);
        return(result);
    }
Exemplo n.º 5
0
        private void DisplayPixelPosition(NodeData nodePixel, SelectionItem pixel, IRasterSource raster)
        {
            var nodeBuffer = nodePixel.AddSubItem("Position", " ");

            double projX, projY;

            raster.ImageToProjection(pixel.Column, pixel.Row, out projX, out projY);

            double degX, degY;

            if (_context.Map.ProjToDegrees(projX, projY, out degX, out degY))
            {
                nodeBuffer.AddSubItem("Latitude", GeoAngle.FromDouble(degY).ToString());
                nodeBuffer.AddSubItem("Longitude", GeoAngle.FromDouble(degX).ToString());
            }

            nodeBuffer.AddSubItem("Projected X", projX.ToString("0.0"));
            nodeBuffer.AddSubItem("Projected Y", projY.ToString("0.0"));
        }