Esempio n. 1
0
        /// <summary>
        /// Converts WGS84-coordinate to UnityCoordinate
        /// </summary>
        /// <param name="coordinaat">Vector3RD WGS-coordinate</param>
        /// <returns>Vector Unity-Coordinate</returns>
        public static Vector3 WGS84toUnity(Vector3WGS coordinaat)
        {
            Vector3 output          = WGS84toUnity(coordinaat.lon, coordinaat.lat);
            double  hoogteCorrectie = RDCorrection(coordinaat.lon, coordinaat.lat, "Z", RDCorrectionZ);

            output.y = (float)(coordinaat.h - hoogteCorrectie);
            return(output);
        }
        /// <summary>
        /// Converts WGS84-coordinate to UnityCoordinate
        /// </summary>
        /// <param name="coordinaat">Vector3RD WGS-coordinate</param>
        /// <returns>Vector Unity-Coordinate</returns>
        public static Vector3 WGS84toUnity(Vector3WGS coordinaat)
        {
            Vector3 output = new Vector3();

            output   = WGS84toUnity(coordinaat.lon, coordinaat.lat);
            output.y = (float)(coordinaat.h - ReferenceWGS84.h);
            return(output);
        }
Esempio n. 3
0
        /// <summary>
        /// Converts Unity-Coordinate to WGS84-Coordinate
        /// </summary>
        /// <param name="coordinaat">Unity-coordinate XHZ</param>
        /// <returns>WGS-coordinate</returns>
        public static Vector3WGS UnitytoWGS84(Vector3 coordinaat)
        {
            Vector3RD  vectorRD        = UnitytoRD(coordinaat);
            Vector3WGS output          = RDtoWGS84(vectorRD.x, vectorRD.y);
            double     hoogteCorrectie = RDCorrection(output.lon, output.lat, "Z", RDCorrectionZ);

            output.h = vectorRD.z + hoogteCorrectie;
            return(output);
        }
        /// <summary>
        /// Converts Unity-Coordinate to RD-coordinate
        /// </summary>
        /// <param name="coordinaat">Unity-Coordinate</param>
        /// <returns>RD-coordinate</returns>
        public static Vector3RD UnitytoRD(Vector3 coordinaat)
        {
            Vector3WGS wgs = UnitytoWGS84(coordinaat);
            Vector3RD  RD  = WGS84toRD(wgs.lon, wgs.lat);

            RD.z = wgs.h - RDCorrection(wgs.lon, wgs.lat, "Z", RDCorrectionZ);
            RD.z = RD.z - Config.activeConfiguration.zeroGroundLevelY;
            return(RD);
        }
        /// <summary>
        /// Converts Unity-Coordinate to WGS84-Coordinate
        /// </summary>
        /// <param name="coordinaat">Unity-coordinate XHZ</param>
        /// <returns>WGS-coordinate</returns>
        public static Vector3WGS UnitytoWGS84(Vector3 coordinaat)
        {
            Vector3WGS output = new Vector3WGS();

            output.h   = coordinaat.y - ReferenceWGS84.h;;
            output.lon = (float)((coordinaat.x / UnitsPerDegreeX) + ReferenceWGS84.lon);
            output.lat = (float)((coordinaat.z / UnitsPerDegreeY) + ReferenceWGS84.lat);
            return(output);
        }
        /// <summary>
        /// calculate the necessary rotation for objects in rd-coordinates to sit nicely in the Unity-CoordinateSystem
        /// </summary>
        /// <param name="locatie">RD-coordinate</param>
        /// <returns>rotationAngle for RD-object (clockwise) in degrees around unity Y-axis</returns>
        public static double RDRotation(Vector3RD locatie)
        {
            double hoek = 0;

            Vector3WGS origin = RDtoWGS84(locatie.x, locatie.y);
            Vector3WGS punt2  = RDtoWGS84(locatie.x + 100, locatie.y);

            double deltaX  = (punt2.lon - origin.lon) * unitsPerDegreeX;
            double deltaY  = (punt2.lat - origin.lat) * unitsPerDegreeY;
            double hoekRad = Math.Tan(deltaY / deltaX);

            hoek = -1 * (hoekRad * 180 / Math.PI);

            return(hoek);
        }
Esempio n. 7
0
        public static Vector3WGS RDtoWGS84(double x, double y)
        {
            //coordinates of basepoint in RD
            double refRDX = 155000;
            double refRDY = 463000;

            //coordinates of basepoint in WGS84
            double refLon = 5.38720621;
            double refLat = 52.15517440;

            double correctionX = RDCorrection(x, y, "X", RDCorrectionX);
            double correctionY = RDCorrection(x, y, "Y", RDCorrectionY);

            double DeltaX = (x + correctionX - refRDX) * Math.Pow(10, -5);
            double DeltaY = (y + correctionY - refRDY) * Math.Pow(10, -5);



            //calculate lattitude
            double Deltalat = 0;

            for (int i = 0; i < Kpq.Length; i++)
            {
                Deltalat += Kpq[i] * Math.Pow(DeltaX, Kp[i]) * Math.Pow(DeltaY, Kq[i]);
            }
            Deltalat = Deltalat / 3600;
            double lat = Deltalat + refLat;

            //calculate longitude
            double Deltalon = 0;

            for (int i = 0; i < Lpq.Length; i++)
            {
                Deltalon += Lpq[i] * Math.Pow(DeltaX, Lp[i]) * Math.Pow(DeltaY, Lq[i]);
            }
            Deltalon = Deltalon / 3600;
            double lon = Deltalon + refLon;

            //output result
            Vector3WGS output = new Vector3WGS();

            output.lon = lon;
            output.lat = lat;
            return(output);
        }
        /// <summary>
        /// Convert RD-coordinate to Unity-coordinate
        /// </summary>
        /// <param name="x">RD X-coordinate</param>
        /// <param name="y">RD Y-coordinate</param>
        /// <param name="y">RD eleveation</param>
        /// <returns>Unity-Coordinate</returns>
        private static Vector3 RDtoUnity(double X, double Y, double Z)
        {
            Vector3 output = new Vector3();
            //if (RDIsValid(new Vector3((float)X, (float)Y)) == false) //check if RD-coordinate is valid
            //{
            //    Debug.Log("<color=red>coordinaat " + X + "," + X + " is geen geldig RD-coordinaat!</color>");
            //    return output;
            //}
            //convert to WGS84
            Vector3WGS wgs = RDtoWGS84(X, Y);

            //convert to Unity
            output = WGS84toUnity(wgs.lon, wgs.lat);
            double hoogte = RDCorrection(wgs.lon, wgs.lat, "Z", RDCorrectionZ);

            output.y = (float)(Z + Config.activeConfiguration.zeroGroundLevelY);
            return(output);
        }
Esempio n. 9
0
        /// <summary>
        /// checks if WGS-coordinate is valid
        /// </summary>
        /// <param name="coordinaat">Vector3 WGS84-coordinate</param>
        /// <returns>True if coordinate is valid</returns>
        public static bool WGS84IsValid(Vector3WGS coordinaat)
        {
            bool isValid = true;

            if (coordinaat.lon < -180)
            {
                isValid = false;
            }
            if (coordinaat.lon > 180)
            {
                isValid = false;
            }
            if (coordinaat.lat < -90)
            {
                isValid = false;
            }
            if (coordinaat.lat > 90)
            {
                isValid = false;
            }
            return(isValid);
        }