public static JsonObject AIS(GpsLocation location) { JsonObject obj = CreateBasicObject(ProtocolConstants.METHOD_AIS); JsonObject args = RetrieveArgObject(obj); args.Put(ProtocolConstants.ARG_GPS_LONGITUDE, location.Longitude); args.Put(ProtocolConstants.ARG_GPS_LATITUDE, location.Latitude); return obj; }
private void UpdateRadians(RadarItem item, GpsLocation remoteLoc) { GpsLocation localLoc = GPSUnit.Instance.Location; /*double g = remoteLoc.Longitude - localLoc.Longitude; double grad = g / RADIANS_MAGIC_NUMBER; double nrad = localLoc.Longitude / RADIANS_MAGIC_NUMBER; double lrad = localLoc.Latitude / RADIANS_MAGIC_NUMBER; double srad = remoteLoc.Longitude / RADIANS_MAGIC_NUMBER; #if TRACE Trace.WriteLine(String.Format("localLoc: {0}", localLoc)); Trace.WriteLine(String.Format("remoteLoc: {0}", remoteLoc)); Trace.WriteLine(String.Format("grad={0}, nrad={1}, lrad={2}, srad={3}", grad, nrad, lrad, srad)); #endif double azi = (Math.PI - (-Math.Atan((Math.Tan(grad) / Math.Sin(lrad))))); item.Azimuth = azi * RADIANS_MAGIC_NUMBER; double a = Math.Cos(grad); double b = Math.Cos(lrad); double ele = Math.Atan((a * b) / (Math.Sqrt(1 - (a * a) * (b * b)))); //item.Elevation = ele > 0 ? ele : -ele * RADIANS_DIVISOR; item.Elevation = ele * RADIANS_MAGIC_NUMBER; #if TRACE Trace.WriteLine(String.Format("azi={0},ele={1}", azi, ele)); Trace.WriteLine(String.Format("item.Azimuth={0}, item.Elevation={1}", item.Azimuth, item.Elevation)); #endif */ item.Azimuth = remoteLoc.Latitude - localLoc.Latitude * 50; double y = remoteLoc.Longitude - localLoc.Longitude * 1.5; item.Elevation = y < 0 ? -y : y; }