/// <summary> /// Transform an array of LLH coordinates to an array of NEE points with variable from and to coordinate type inputs. /// </summary> /// <returns>Returns an array of NEE points in radians.</returns> public NEE[] TransformLLHToNEE(string csib, LLH[] coordinates, CoordinateTypes fromType, CoordinateTypes toType) { var neeCoordinates = new NEE[coordinates.Length]; using var transformer = GeodeticXTransformer(csib); for (var i = 0; i < coordinates.Length; i++) { var llh = coordinates[i]; transformer.Transform( (geoCoordinateTypes)fromType, llh.Latitude, llh.Longitude, llh.Height, (geoCoordinateTypes)toType, out var toY, out var toX, out var toZ); neeCoordinates[i] = new NEE { North = toY, East = toX, Elevation = toZ }; } return(neeCoordinates); }
/// <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); }
/// <summary> /// Converts an array of XYZ coordinate data to NEE formatted objects. /// </summary> public static NEE[] ToNEE(this XYZ[] data) { var result = new NEE[data.Length]; for (var i = 0; i < data.Length; i++) { result[i] = new NEE { North = data[i].Y, East = data[i].X, Elevation = data[i].Z }; } return(result); }
/// <summary> /// Converts the multi dimensional array of doubles from the Coordinate service to an array of <see cref="NEE"/> objects. /// </summary> public static NEE[] ToNEEArray(this double[,] arrayData) { var result = new NEE[arrayData.Length / 3]; for (var i = 0; i < arrayData.Length / 3; i++) { result[i] = new NEE { North = arrayData[i, 1], East = arrayData[i, 0], Elevation = arrayData[i, 2] }; } return(result); }
/// <summary> /// Transform an NEE to LLH with variable from and to coordinate type inputs. /// </summary> /// <returns>Returns LLH object in radians.</returns> public LLH TransformNEEToLLH(string csib, NEE nee, CoordinateTypes fromType, CoordinateTypes toType) { using var transformer = GeodeticXTransformer(csib); 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. return(new LLH { Latitude = toY, Longitude = toX, Height = toZ }); }