PointOnBearingRAD() public static method

public static PointOnBearingRAD ( double startLat, double startLon, double distanceRAD, double bearingRAD, SpatialContext ctx, System.Point reuse ) : System.Point
startLat double
startLon double
distanceRAD double
bearingRAD double
ctx Spatial4n.Core.Context.SpatialContext
reuse System.Point
return System.Point
Exemplo n.º 1
0
        private void AssertDistanceConversionImpl(double dist)
        {
            double radius = DistanceUtils.EARTH_MEAN_RADIUS_KM;
            //test back & forth conversion for both
            double distRAD = DistanceUtils.Dist2Radians(dist, radius);

            CustomAssert.EqualWithDelta(dist, DistanceUtils.Radians2Dist(distRAD, radius), EPS);
            double distDEG = DistanceUtils.Dist2Degrees(dist, radius);

            CustomAssert.EqualWithDelta(dist, DistanceUtils.Degrees2Dist(distDEG, radius), EPS);
            //test across rad & deg
            CustomAssert.EqualWithDelta(distDEG, DistanceUtils.ToDegrees(distRAD), EPS);
            //test point on bearing
            CustomAssert.EqualWithDelta(
                DistanceUtils.PointOnBearingRAD(0, 0, DistanceUtils.Dist2Radians(dist, radius),
                                                DistanceUtils.DEG_90_AS_RADS, ctx, new Point(0, 0, ctx)).X,
                distRAD, 10e-5);
        }
        private readonly double radiusDEG = DistanceUtils.ToDegrees(1);        //in degrees

        public override Point PointOnBearing(Point @from, double distDEG, double bearingDEG, SpatialContext ctx, Point reuse)
        {
            if (distDEG == 0)
            {
                if (reuse == null)
                {
                    return(from);
                }
                reuse.Reset(from.GetX(), from.GetY());
                return(reuse);
            }
            Point result = DistanceUtils.PointOnBearingRAD(
                DistanceUtils.ToRadians(from.GetY()), DistanceUtils.ToRadians(from.GetX()),
                DistanceUtils.ToRadians(distDEG),
                DistanceUtils.ToRadians(bearingDEG), ctx, reuse);//output result is in radians

            result.Reset(DistanceUtils.ToDegrees(result.GetX()), DistanceUtils.ToDegrees(result.GetY()));
            return(result);
        }