public void LinearDimensionEqualTest() { var depth1 = new LinearDimension(43.81234123, LinearDimensionUnit.Foot); var depth2 = new LinearDimension(depth1.GetMeters(), LinearDimensionUnit.Meter); Assert.AreEqual(depth1, depth2); Assert.IsTrue(depth1 == depth2); }
public void LinearDimensionOperationsTest() { var depth1 = new LinearDimension(43.81, LinearDimensionUnit.Foot); var depth2 = new LinearDimension(12.34, LinearDimensionUnit.Meter); var depth3 = new LinearDimension(depth1.GetMeters() + depth2.GetMeters(), LinearDimensionUnit.Meter); Assert.IsTrue(depth1 > depth2); Assert.IsTrue(depth2 < depth1); Assert.IsTrue(depth3 == depth1 + depth2); }
public void LinearDimensionCreationTest() { //45 foots == 13.716 meters var depth1 = new LinearDimension(45, LinearDimensionUnit.Foot); Assert.AreEqual(13.716, depth1.GetMeters(), 0.001); //20 meters == 65.61679 meters var depth2 = new LinearDimension(20, LinearDimensionUnit.Meter); Assert.AreEqual(65.61679, depth2.GetFoots(), 0.001); }
private static byte[] GetArrayForNoiseAndBottomSurfaces(short packetSize, LinearDimension depth, LinearDimension upperLimit, LinearDimension lowerLimit) { //calc packet size for all the water column (from water surface to lower limit) var allTheWaterColumnPacketSize = (uint)Math.Ceiling(lowerLimit * packetSize / (lowerLimit - upperLimit)); //create byte array for all the column var allTheWaterColumnBytesArray = new byte[allTheWaterColumnPacketSize]; //and fill it with patterns for water surface noises and bottom surface // lets water surface noises always has 0.5 meter depth. then one meter packet size is var oneMeterPacketSize = (uint)(allTheWaterColumnPacketSize / lowerLimit.GetMeters()); //then noise array is var noiseArray = GetDecreasingByteSurface(oneMeterPacketSize); //copy noise array to begin of allTheWaterColumnBytesArray noiseArray.CopyTo(allTheWaterColumnBytesArray, 0); //lets fill by bottom surface all the place beyond depth and lower limit if (depth < lowerLimit) { //calc bottom surface packet size var bottomSurfacePacketSize = (uint)((lowerLimit - depth) * allTheWaterColumnPacketSize / lowerLimit); //then bottom array is var bottomArray = GetDecreasingByteSurface(bottomSurfacePacketSize); //and copy bottom array to the end of allTheWaterColumnBytesArray bottomArray.CopyTo(allTheWaterColumnBytesArray, allTheWaterColumnPacketSize - bottomSurfacePacketSize); } //finally cut allTheWaterColumnBytesArray to array from upper to lower limit and return SoundedData var arrayForSoundedData = new byte[packetSize]; allTheWaterColumnBytesArray.CopyTo(arrayForSoundedData, allTheWaterColumnPacketSize - packetSize); return(arrayForSoundedData); }
/// <summary> /// Create instance of <see cref="SoundedData"/> with generated <see cref="Data"/>. /// </summary> /// <param name="packetSize"><see cref="Frame.PacketSize"/>.</param> /// <param name="channelType"><see cref="Frame.ChannelType"/>.</param> /// <param name="depth"><see cref="Frame.Depth"/>.</param> /// <param name="upperLimit"><see cref="UpperLimit"/>.</param> /// <param name="lowerLimit"><see cref="LowerLimit"/>.</param> /// <returns>Instance of <see cref="SoundedData"/> with generated <see cref="Data"/>.</returns> public static SoundedData GenerateData(short packetSize, ChannelType channelType, LinearDimension depth, LinearDimension upperLimit, LinearDimension lowerLimit) { if (depth.GetMeters() < 0) { throw new ArgumentOutOfRangeException(nameof(depth), channelType, nameof(depth) + "cant be less then zero."); } if (packetSize < 0) { throw new ArgumentOutOfRangeException(nameof(packetSize), packetSize, nameof(packetSize) + "cant be less then zero."); } if (upperLimit.GetMeters() > lowerLimit.GetMeters()) { throw new ArgumentOutOfRangeException(nameof(upperLimit), nameof(upperLimit) + " more then " + nameof(lowerLimit)); } switch (channelType) { case ChannelType.Primary: case ChannelType.Secondary: case ChannelType.DownScan: case ChannelType.SidescanRight: if (upperLimit.GetMeters() < 0) { throw new ArgumentOutOfRangeException(nameof(upperLimit), upperLimit, nameof(upperLimit) + "cant be less then zero for " + channelType); } if (lowerLimit.GetMeters() < 0) { throw new ArgumentOutOfRangeException(nameof(lowerLimit), lowerLimit, nameof(lowerLimit) + "cant be less then zero for " + channelType); } var verticalArrayForSoundedData = GetArrayForNoiseAndBottomSurfaces(packetSize, depth, upperLimit, lowerLimit); return(new SoundedData(verticalArrayForSoundedData, channelType, upperLimit, lowerLimit)); case ChannelType.SidescanLeft: if (upperLimit.GetMeters() > 0) { throw new ArgumentOutOfRangeException(nameof(upperLimit), upperLimit, nameof(upperLimit) + "cant be more then zero for " + channelType); } if (lowerLimit.GetMeters() > 0) { throw new ArgumentOutOfRangeException(nameof(lowerLimit), lowerLimit, nameof(lowerLimit) + "cant be more then zero for " + channelType); } var sraightArrayForSidescanLeft = GetArrayForNoiseAndBottomSurfaces(packetSize, depth, lowerLimit * -1, upperLimit * -1); return(new SoundedData(sraightArrayForSidescanLeft.Reverse().ToArray(), channelType, upperLimit, lowerLimit)); case ChannelType.SidescanComposite: if (upperLimit.GetMeters() > 0) { throw new ArgumentOutOfRangeException(nameof(upperLimit), upperLimit, nameof(upperLimit) + "cant be more then zero for " + channelType); } if (lowerLimit.GetMeters() < 0) { throw new ArgumentOutOfRangeException(nameof(lowerLimit), lowerLimit, nameof(lowerLimit) + "cant be less then zero for " + channelType); } var sraightArrayForSidescanComposite = GetArrayForNoiseAndBottomSurfaces((short)(packetSize / 2), depth, LinearDimension.FromMeters(0), lowerLimit); var fullSidescan = new byte[packetSize]; sraightArrayForSidescanComposite.Reverse().ToArray().CopyTo(fullSidescan, 0); sraightArrayForSidescanComposite.CopyTo(fullSidescan, packetSize / 2); return(new SoundedData(fullSidescan, channelType, upperLimit, lowerLimit)); case ChannelType.ThreeD: throw new NotImplementedException(); default: throw new ArgumentOutOfRangeException(nameof(channelType), channelType, null); } }