/// <summary>
        /// Calculate WGS84 coordinates from Cartesian
        /// </summary>
        /// <param name="p"> Cartesian coordenates of the object</param>
        /// <param name="SIC">SIC of the radar which detected the object, to know which radar is and where it's placed </param>
        /// <returns>Object WGS84 coordinates</returns>
        public PointLatLng ComputeWGS_84_from_Cartesian(Point p, string SIC)
        {
            PointLatLng      pos             = new PointLatLng();
            double           X               = p.X;
            double           Y               = p.Y;
            CoordinatesXYZ   ObjectCartesian = new CoordinatesXYZ(X, Y, 0);                                                                  //We pass from Point to CoordinatesXYZ to be able to work with the GeoUtils library
            PointLatLng      AirportPoint    = GetCoordenatesSMRMALT(Convert.ToInt32(SIC));                                                  //We get the Radar coordinates from its SIC
            CoordinatesWGS84 AirportGeodesic = new CoordinatesWGS84(AirportPoint.Lat * (Math.PI / 180), AirportPoint.Lng * (Math.PI / 180)); //We went from PointLatLng to Coordinates WGS84 to be able to work with GeoUtils. Coordinates must be passed from degrees to radians
            GeoUtils         geoUtils        = new GeoUtils();
            CoordinatesWGS84 MarkerGeodesic  = geoUtils.change_system_cartesian2geodesic(ObjectCartesian, AirportGeodesic);                  //We apply the change from CoordiantesXYZ to Coordinate GS83

            geoUtils = null;
            double LatitudeWGS_84_map  = MarkerGeodesic.Lat * (180 / Math.PI);
            double LongitudeWGS_84_map = MarkerGeodesic.Lon * (180 / Math.PI);

            pos.Lat = LatitudeWGS_84_map;
            pos.Lng = LongitudeWGS_84_map;
            return(pos);
        }
Exemple #2
0
        public double[] GetWGS84Coordinates()
        {
            if (!Double.IsNaN(wgs84latitude))
            {
                double[] wgs84 = { wgs84latitude, wgs84longitude };
                return(wgs84);
            }

            else
            {
                if (GetTypeOfMessage() == "SMR")
                {
                    GeoUtils         geoUtils         = new GeoUtils();
                    Coordinates      radarCoordinates = utilities.GetCoordinatesOfRadar("SMRLebl");
                    CoordinatesWGS84 radarWGS84       = new CoordinatesWGS84(radarCoordinates.GetLatitude() * (Math.PI / 180.0), radarCoordinates.GetLongitude() * (Math.PI / 180.0));
                    CoordinatesXYZ   objectCartesian  = new CoordinatesXYZ(cartesianX, cartesianY, 0);
                    CoordinatesXYZ   objectGeocentric = geoUtils.change_radar_cartesian2geocentric(radarWGS84, objectCartesian);
                    CoordinatesWGS84 objectWGS84      = geoUtils.change_geocentric2geodesic(objectGeocentric);
                    double[]         wgs84            = { objectWGS84.Lat *(180.0 / Math.PI), objectWGS84.Lon *(180.0 / Math.PI) };
                    return(wgs84);
                }
                else if (GetTypeOfMessage() == "MLAT")
                {
                    GeoUtils         geoUtils         = new GeoUtils();
                    Coordinates      radarCoordinates = utilities.GetCoordinatesOfRadar("ARPLebl");
                    CoordinatesWGS84 radarWGS84       = new CoordinatesWGS84(radarCoordinates.GetLatitude() * (Math.PI / 180.0), radarCoordinates.GetLongitude() * (Math.PI / 180.0));
                    CoordinatesXYZ   objectCartesian  = new CoordinatesXYZ(cartesianX, cartesianY, 0);
                    CoordinatesXYZ   objectGeocentric = geoUtils.change_radar_cartesian2geocentric(radarWGS84, objectCartesian);
                    CoordinatesWGS84 objectWGS84      = geoUtils.change_geocentric2geodesic(objectGeocentric);
                    double[]         wgs84            = { objectWGS84.Lat *(180.0 / Math.PI), objectWGS84.Lon *(180.0 / Math.PI) };
                    return(wgs84);
                }
                else
                {
                    return(null);
                }
            }
        }