Пример #1
0
        /// <inheritdoc />
        public NEE LLHToNEE(string csib, LLH coordinates, InputAs inputAs)
        {
            var requestId = Guid.NewGuid();

            if (_log.IsTraceEnabled())
            {
                _log.LogTrace($"{nameof(LLHToNEE)}: CoreXRequestID: {requestId}, LLH: {coordinates}, InputAs: {inputAs}");
            }

            if (inputAs == InputAs.Degrees)
            {
                coordinates.Latitude  = coordinates.Latitude.DegreesToRadians();
                coordinates.Longitude = coordinates.Longitude.DegreesToRadians();
            }

            var result = _coreX.TransformLLHToNEE(
                csib,
                coordinates,
                fromType: CoordinateTypes.ReferenceGlobalLLH,
                toType: CoordinateTypes.OrientatedNEE);

            if (_log.IsTraceEnabled())
            {
                _log.LogTrace($"{nameof(LLHToNEE)}: CoreXRequestID: {requestId}, Returning NEE: {result}");
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Transform an array of NEE points to an array of LLH coordinates with variable from and to coordinate type inputs.
        /// </summary>
        /// <returns>Returns an array of LLH coordinates in radians.</returns>
        public LLH[] TransformNEEToLLH(string csib, NEE[] coordinates, CoordinateTypes fromType, CoordinateTypes toType)
        {
            var llhCoordinates = new LLH[coordinates.Length];

            using var transformer = GeodeticXTransformer(csib);

            for (var i = 0; i < coordinates.Length; i++)
            {
                var nee = coordinates[i];

                transformer.Transform(
                    (geoCoordinateTypes)fromType,
                    nee.North,
                    nee.East,
                    nee.Elevation,
                    (geoCoordinateTypes)toType,
                    out var toY, out var toX, out var toZ);

                // The toX and toY parameters mirror the order of the input parameters fromX and fromY; they are not grid coordinate positions.
                llhCoordinates[i] = new LLH
                {
                    Latitude  = toY,
                    Longitude = toX,
                    Height    = toZ
                };
            }

            return(llhCoordinates);
        }
Пример #3
0
        /// <inheritdoc/>
        public LLH[] NEEToLLH(string csib, NEE[] coordinates, ReturnAs returnAs = ReturnAs.Radians)
        {
            var requestId = Guid.NewGuid();

            if (_log.IsTraceEnabled())
            {
                _log.LogTrace($"{nameof(NEEToLLH)}: CoreXRequestID: {requestId}, NEE[]: {string.Concat(coordinates)}, ReturnAs: {returnAs}, CSIB: {csib}");
            }

            var llhCoords = _coreX
                            .TransformNEEToLLH(csib, coordinates, fromType: CoordinateTypes.OrientatedNEE, toType: CoordinateTypes.ReferenceGlobalLLH);

            var responseArray = new LLH[llhCoords.Length];
            var inDegrees     = returnAs == ReturnAs.Degrees;

            for (var i = 0; i < llhCoords.Length; i++)
            {
                var llh = llhCoords[i];

                responseArray[i] = new LLH
                {
                    Longitude = inDegrees ? llh.Longitude.RadiansToDegrees() : llh.Longitude,
                    Latitude  = inDegrees ? llh.Latitude.RadiansToDegrees() : llh.Latitude,
                    Height    = llh.Height
                };
            }

            if (_log.IsTraceEnabled())
            {
                _log.LogTrace($"{nameof(NEEToLLH)}: CoreXRequestID: {requestId}, Returning LLH[]: {string.Concat(responseArray)}");
            }

            return(responseArray);
        }
Пример #4
0
        /// <inheritdoc/>
        public LLH NEEToLLH(string csib, NEE coordinates, ReturnAs returnAs = ReturnAs.Radians)
        {
            var requestId = Guid.NewGuid();

            if (_log.IsTraceEnabled())
            {
                _log.LogTrace($"{nameof(NEEToLLH)}: CoreXRequestID: {requestId}, NEE: {coordinates}, ReturnAs: {returnAs}, CSIB: {csib}");
            }

            var llhCoords = _coreX
                            .TransformNEEToLLH(csib, coordinates, fromType: CoordinateTypes.OrientatedNEE, toType: CoordinateTypes.ReferenceGlobalLLH);

            var inDegrees = returnAs == ReturnAs.Degrees;

            var result = new LLH
            {
                Longitude = inDegrees ? llhCoords.Longitude.RadiansToDegrees() : llhCoords.Longitude,
                Latitude  = inDegrees ? llhCoords.Latitude.RadiansToDegrees() : llhCoords.Latitude,
                Height    = llhCoords.Height
            };

            if (_log.IsTraceEnabled())
            {
                _log.LogTrace($"{nameof(NEEToLLH)}: CoreXRequestID: {requestId}, Returning LLH: {result}");
            }

            return(result);
        }
Пример #5
0
        /// <summary>
        /// Converts an array of XYZ coordinate data to NEE formatted objects.
        /// </summary>
        public static LLH[] ToLLH(this XYZ[] data)
        {
            var result = new LLH[data.Length];

            for (var i = 0; i < data.Length; i++)
            {
                result[i] = new LLH
                {
                    Latitude  = data[i].Y,
                    Longitude = data[i].X,
                    Height    = data[i].Z
                };
            }

            return(result);
        }
Пример #6
0
        /// <summary>
        /// Converts the multi dimensional array of doubles from the Coordinate service to an array of <see cref="LLH"/> objects.
        /// </summary>
        /// <remarks>
        /// Note the deliberate order change, with Longitude preceeding Latitude in the sequence we read
        /// from the LLH data.
        /// </remarks>
        public static LLH[] ToLLHArray(this double[,] arrayData)
        {
            var result = new LLH[arrayData.Length / 3];

            for (var i = 0; i < arrayData.Length / 3; i++)
            {
                result[i] = new LLH
                {
                    Longitude = arrayData[i, 0],
                    Latitude  = arrayData[i, 1],
                    Height    = arrayData[i, 2]
                };
            }

            return(result);
        }
Пример #7
0
        /// <summary>
        /// Converts an array of WSG84 point coordinate data to LLH formatted objects.
        /// </summary>
        public static LLH[] ToLLH(this WGS84Point[] data, InputAs inputAs)
        {
            var result = new LLH[data.Length];

            var inDegrees = inputAs == InputAs.Degrees;

            for (var i = 0; i < data.Length; i++)
            {
                result[i] = new LLH
                {
                    Latitude  = inDegrees ? data[i].Lat.DegreesToRadians() : data[i].Lat,
                    Longitude = inDegrees ? data[i].Lon.DegreesToRadians() : data[i].Lon,
                    Height    = data[i].Height
                };
            }

            return(result);
        }
Пример #8
0
        /// <summary>
        /// Transform an LLH to NEE with variable from and to coordinate type inputs.
        /// </summary>
        /// <returns>A NEE point of the LLH provided coordinates in radians.</returns>
        public NEE TransformLLHToNEE(string csib, LLH coordinates, CoordinateTypes fromType, CoordinateTypes toType)
        {
            using var transformer = GeodeticXTransformer(csib);

            transformer.Transform(
                (geoCoordinateTypes)fromType,
                coordinates.Latitude,
                coordinates.Longitude,
                coordinates.Height,
                (geoCoordinateTypes)toType,
                out var toY, out var toX, out var toZ);

            return(new NEE
            {
                North = toY,
                East = toX,
                Elevation = toZ
            });
        }