/// <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); } }
/// <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()); }
/// <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); }
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")); }