public void GetCoordinatePointAtDistanceAndDirectionTest() { var baseCoordinatePoint = new CoordinatePoint(new Latitude(60, 07.328), new Longitude(32, 18.719)); var _d2R = Math.PI / 180D; //expected values taken from http://edwilliams.org/gccalc.htm var pointWithSphereFormula = CoordinatePoint.GetCoordinatePointAtDistanceAndDirectionWithHaversine(baseCoordinatePoint, LinearDimension.FromMeters(3.1d), 70 * _d2R, out _); var pointWithEllipsoidFormula = CoordinatePoint.GetCoordinatePointAtDistanceAndDirectionOnAnEllipsoid(baseCoordinatePoint, LinearDimension.FromMeters(3.1d), 70 * _d2R, out _); //Sphere Assert.AreEqual(60 + 7.3286 / 60d, pointWithSphereFormula.Latitude.ToDegrees(), 0.000001d); Assert.AreEqual(32 + 18.7221 / 60d, pointWithSphereFormula.Longitude.ToDegrees(), 0.000001d); //Ellipsoid Assert.AreEqual(60 + 7.3286 / 60d, pointWithEllipsoidFormula.Latitude.ToDegrees(), 0.000001d); Assert.AreEqual(32 + 18.7221 / 60d, pointWithEllipsoidFormula.Longitude.ToDegrees(), 0.000001d); pointWithSphereFormula = CoordinatePoint.GetCoordinatePointAtDistanceAndDirectionWithHaversine(baseCoordinatePoint, LinearDimension.FromMeters(10.9d), 71 * _d2R, out _); pointWithEllipsoidFormula = CoordinatePoint.GetCoordinatePointAtDistanceAndDirectionOnAnEllipsoid(baseCoordinatePoint, LinearDimension.FromMeters(10.9d), 71 * _d2R, out _); //Sphere Assert.AreEqual(60 + 7.3299 / 60d, pointWithSphereFormula.Latitude.ToDegrees(), 0.000001d); Assert.AreEqual(32 + 18.7301 / 60d, pointWithSphereFormula.Longitude.ToDegrees(), 0.000002d); //2*10-6 !!!! //Ellipsoid Assert.AreEqual(60 + 7.3299 / 60d, pointWithEllipsoidFormula.Latitude.ToDegrees(), 0.000001d); Assert.AreEqual(32 + 18.7301 / 60d, pointWithEllipsoidFormula.Longitude.ToDegrees(), 0.000001d); pointWithSphereFormula = CoordinatePoint.GetCoordinatePointAtDistanceAndDirectionWithHaversine(baseCoordinatePoint, LinearDimension.FromMeters(97.8d), 88 * _d2R, out _); pointWithEllipsoidFormula = CoordinatePoint.GetCoordinatePointAtDistanceAndDirectionOnAnEllipsoid(baseCoordinatePoint, LinearDimension.FromMeters(97.8d), 88 * _d2R, out _); //Sphere Assert.AreEqual(60 + 7.3298 / 60d, pointWithSphereFormula.Latitude.ToDegrees(), 0.000001d); Assert.AreEqual(32 + 18.8245 / 60d, pointWithSphereFormula.Longitude.ToDegrees(), 0.000007d); //7*10-6 !!!! //Ellipsoid Assert.AreEqual(60 + 7.3298 / 60d, pointWithEllipsoidFormula.Latitude.ToDegrees(), 0.000001d); Assert.AreEqual(32 + 18.8245 / 60d, pointWithEllipsoidFormula.Longitude.ToDegrees(), 0.000001d); pointWithSphereFormula = CoordinatePoint.GetCoordinatePointAtDistanceAndDirectionWithHaversine(baseCoordinatePoint, LinearDimension.FromMeters(1400), 233 * _d2R, out _); pointWithEllipsoidFormula = CoordinatePoint.GetCoordinatePointAtDistanceAndDirectionOnAnEllipsoid(baseCoordinatePoint, LinearDimension.FromMeters(1400), 233 * _d2R, out _); //Sphere //poor accuracy Assert.AreEqual(60 + 6.8742 / 60d, pointWithSphereFormula.Latitude.ToDegrees(), 0.00002d); //2*10-5 !!!! Assert.AreEqual(32 + 17.5126 / 60d, pointWithSphereFormula.Longitude.ToDegrees(), 0.00008d); //8*10-5 !!!! //Ellipsoid Assert.AreEqual(60 + 6.8742 / 60d, pointWithEllipsoidFormula.Latitude.ToDegrees(), 0.0000011d); Assert.AreEqual(32 + 17.5126 / 60d, pointWithEllipsoidFormula.Longitude.ToDegrees(), 0.000003d); }
/// <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); } }