/// <inheritdoc /> public NEE[] LLHToNEE(string csib, LLH[] coordinates, InputAs inputAs) { var requestId = Guid.NewGuid(); if (_log.IsTraceEnabled()) { _log.LogTrace($"{nameof(LLHToNEE)}: CoreXRequestID: {requestId}, LLH[]: {string.Concat(coordinates)}, InputAs: {inputAs}, CSIB: {csib}"); } if (inputAs == InputAs.Degrees) { for (var i = 0; i < coordinates.Length; i++) { var llh = coordinates[i]; llh.Latitude = llh.Latitude.DegreesToRadians(); llh.Longitude = llh.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[]: {string.Concat(result)}"); } return(result); }
public async Task <int> EditTreatment( int treatmentId, int beehiveId, DateTime dateOfTreatment, string name, string note, string disease, string medication, InputAs inputAs, double quantity, Dose dose) { var treatment = this.treatmentRepository .All() .FirstOrDefault(t => t.Id == treatmentId); treatment.DateOfTreatment = dateOfTreatment; treatment.Name = name; treatment.Note = note; treatment.Disease = disease; treatment.Medication = medication; treatment.InputAs = inputAs; treatment.Quantity = quantity; treatment.Dose = dose; await this.treatmentRepository.SaveChangesAsync(); return(treatmentId); }
/// <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); }
/// <inheritdoc /> public XYZ LLHToNEE(string csib, XYZ coordinates, InputAs inputAs) { var requestId = Guid.NewGuid(); if (_log.IsTraceEnabled()) { _log.LogTrace($"{nameof(LLHToNEE)}: CoreXRequestID: {requestId}, XYZ: {coordinates}, InputAs: {inputAs}, CSIB: {csib}"); } if (inputAs == InputAs.Degrees) { coordinates.X = coordinates.X.DegreesToRadians(); coordinates.Y = coordinates.Y.DegreesToRadians(); } var neeCoords = _coreX .TransformLLHToNEE(csib, coordinates.ToLLH(), fromType: CoordinateTypes.ReferenceGlobalLLH, toType: CoordinateTypes.OrientatedNEE); var result = new XYZ { X = neeCoords.East, Y = neeCoords.North, Z = neeCoords.Elevation }; if (_log.IsTraceEnabled()) { _log.LogTrace($"{nameof(LLHToNEE)}: CoreXRequestID: {requestId}, Returning XYZ: {result}"); } return(result); }
public async Task <int> CreateTreatmentAsync( string ownerId, string creatorId, DateTime dateOfTreatment, string name, string note, string disease, string medication, InputAs inputAs, double quantity, Dose dose, List <int> beehiveIds) { var treatment = new Treatment { CreatorId = creatorId, OwnerId = ownerId, DateOfTreatment = dateOfTreatment, Name = name, Note = note, Disease = disease, Medication = medication, InputAs = inputAs, Quantity = quantity, Dose = dose, }; await this.treatmentRepository.AddAsync(treatment); await this.treatmentRepository.SaveChangesAsync(); foreach (var id in beehiveIds) { var treatedBeehive = new TreatedBeehive { BeehiveId = id, TreatmentId = treatment.Id, }; await this.treatedBeehivesRepository.AddAsync(treatedBeehive); await this.treatedBeehivesRepository.SaveChangesAsync(); } return(treatment.Id); }
/// <inheritdoc/> public XYZ[] LLHToNEE(string csib, XYZ[] coordinates, InputAs inputAs) { var requestId = Guid.NewGuid(); if (_log.IsTraceEnabled()) { _log.LogTrace($"{nameof(LLHToNEE)}: CoreXRequestID: {requestId}, XYZ[]: {string.Concat(coordinates)}, InputAs: {inputAs}, CSIB: {csib}"); } if (inputAs == InputAs.Degrees) { for (var i = 0; i < coordinates.Length; i++) { var xyz = coordinates[i]; xyz.X = xyz.X.DegreesToRadians(); xyz.Y = xyz.Y.DegreesToRadians(); coordinates[i] = xyz; } } var neeCoords = _coreX .TransformLLHToNEE(csib, coordinates.ToLLH(), fromType: CoordinateTypes.ReferenceGlobalLLH, toType: CoordinateTypes.OrientatedNEE); var responseArray = new XYZ[neeCoords.Length]; for (var i = 0; i < neeCoords.Length; i++) { var nee = neeCoords[i]; responseArray[i] = new XYZ { X = nee.East, Y = nee.North, Z = nee.Elevation }; } if (_log.IsTraceEnabled()) { _log.LogTrace($"{nameof(LLHToNEE)}: CoreXRequestID: {requestId}, Returning XYZ[]: {string.Concat(responseArray)}"); } return(responseArray); }
/// <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); }
/// <inheritdoc/> public XYZ WGS84ToCalibration(string csib, WGS84Point wgs84Point, InputAs inputAs) { var requestId = Guid.NewGuid(); if (_log.IsTraceEnabled()) { _log.LogTrace($"{nameof(WGS84ToCalibration)}: CoreXRequestID: {requestId}, wgs84Point: {wgs84Point}, InputAs: {inputAs}, CSIB: {csib}"); } if (inputAs == InputAs.Degrees) { wgs84Point.Lat = wgs84Point.Lat.DegreesToRadians(); wgs84Point.Lon = wgs84Point.Lon.DegreesToRadians(); } var nee = _coreX .TransformLLHToNEE(csib, new LLH { Latitude = wgs84Point.Lat, Longitude = wgs84Point.Lon, Height = wgs84Point.Height }, fromType: CoordinateTypes.ReferenceGlobalLLH, toType: CoordinateTypes.OrientatedNEE); var result = new XYZ { X = nee.East, Y = nee.North, Z = nee.Elevation }; if (_log.IsTraceEnabled()) { _log.LogTrace($"{nameof(WGS84ToCalibration)}: CoreXRequestID: {requestId}, Returning XYZ: {result}"); } return(result); }
/// <inheritdoc/> public XYZ[] WGS84ToCalibration(string csib, WGS84Point[] wgs84Points, InputAs inputAs) { var requestId = Guid.NewGuid(); if (_log.IsTraceEnabled()) { _log.LogTrace($"{nameof(WGS84ToCalibration)}: CoreXRequestID: {requestId}, wgs84Points[]: {string.Concat<WGS84Point>(wgs84Points)}, InputAs: {inputAs} CSIB: {csib}"); } var neeCoords = _coreX .TransformLLHToNEE( csib, wgs84Points.ToLLH(inputAs), fromType: CoordinateTypes.ReferenceGlobalLLH, toType: CoordinateTypes.OrientatedNEE); var responseArray = new XYZ[neeCoords.Length]; for (var i = 0; i < neeCoords.Length; i++) { var llh = neeCoords[i]; responseArray[i] = new XYZ { X = llh.East, Y = llh.North, Z = llh.Elevation }; } if (_log.IsTraceEnabled()) { _log.LogTrace($"{nameof(WGS84ToCalibration)}: CoreXRequestID: {requestId}, Returning XYZ[]: {string.Concat(responseArray)}"); } return(responseArray); }
// VS vs XUnit test discovery bug means InlineData with skip reason string doesn't get skipped; https://github.com/xunit/xunit/issues/1782 //[InlineData(-15.202778, 130.309167, 0, 8318824.308952088, 640622.3420586593, -39.303228628288906, InputAs.Degrees, "JRAC Bradshaw Jun07.cal", Skip = "Requires ausgeoid.ggf")] public void Should_use_geodata_file_when_CS_defines_geoid(double lat, double lon, double height, double northing, double easting, double elevation, InputAs inputAs, string dcFilename) { var csib = GetCSIBFromDC(dcFilename); var nee = _convertCoordinates.LLHToNEE(csib, new LLH { Latitude = lat, Longitude = lon, Height = height }, inputAs); nee.Should().NotBeNull(); nee.North.Should().BeApproximately(northing, GRID_CM_TOLERANCE); nee.East.Should().BeApproximately(easting, GRID_CM_TOLERANCE); nee.Elevation.Should().BeApproximately(elevation, GRID_CM_TOLERANCE); }
public void CoordinateService_SimpleLLHToNEE(double lat, double lon, double height, double northing, double easting, double elevation, InputAs inputAs, string csib) { var neeCoords = _convertCoordinates.LLHToNEE(csib, new LLH { Latitude = lat, Longitude = lon, Height = height }, inputAs); neeCoords.Should().NotBeNull(); neeCoords.North.Should().BeApproximately(northing, GRID_CM_TOLERANCE); neeCoords.East.Should().BeApproximately(easting, GRID_CM_TOLERANCE); neeCoords.Elevation.Should().BeApproximately(elevation, GRID_CM_TOLERANCE); }
public void Should_convert_a_WGS84Point_to_XYZ_grid_coordinate(double lat, double lon, double height, double toY, double toX, double toZ, InputAs inputAs) { var xyzCoords = _convertCoordinates.WGS84ToCalibration( _csib, new WGS84Point(lon: lon, lat: lat, height: height), inputAs); xyzCoords.Should().NotBeNull(); xyzCoords.Y.Should().BeApproximately(toY, GRID_CM_TOLERANCE); xyzCoords.X.Should().BeApproximately(toX, GRID_CM_TOLERANCE); xyzCoords.Z.Should().BeApproximately(toZ, GRID_CM_TOLERANCE); }