public static bool IsInsideAngle(double targetLongitude, double targetLatitude, double targetDirection, GeoPosition point1, GeoPosition point2)
 {
     return(IsInsideAngle(targetLongitude, targetLatitude, targetDirection, point1, point2, true));
 }
 public static bool IsInsideAngle(double targetLongitude, double targetLatitude, GeoPosition point1, GeoPosition point2)
 {
     return(IsInsideAngle(targetLongitude, targetLatitude, 0, point1, point2, false));
 }
示例#3
0
        public double Distance(GeoPosition target)
        {
            var distanceKilomoters = MathHelper.GetGPSDistance(this.Latitude, target.Latitude, this.Longitude, target.Longitude);

            return(distanceKilomoters < 0 ? distanceKilomoters * -1 : distanceKilomoters);
        }
        private static bool IsInsideAngle(double targetLongitude, double targetLatitude, double targetDirection, GeoPosition point1, GeoPosition point2, bool mustHaveDirection)
        {
            bool result = false;

            double degreesAperture = 3;

            double degreesOne             = GetAngle(point1.Longitude, point2.Longitude, point1.Latitude, point2.Latitude);
            double degreesTwo             = GetAngle(point2.Longitude, point1.Longitude, point2.Latitude, point1.Latitude);
            double degreesOneFromPosition = GetAngle(point1.Longitude, targetLongitude, point1.Latitude, targetLatitude);
            double degreesTwoFromPosition = GetAngle(point2.Longitude, targetLongitude, point2.Latitude, targetLatitude);

            bool isTargetInAngleFromOne = degreesOne - degreesAperture <degreesOneFromPosition && degreesOne + degreesAperture> degreesOneFromPosition ||
                                          degreesTwo - degreesAperture <degreesTwoFromPosition && degreesTwo + degreesAperture> degreesTwoFromPosition;
            bool targetCompatibleHasAngle = targetDirection - degreesAperture <degreesOneFromPosition && targetDirection + degreesAperture> degreesOneFromPosition ||
                                            targetDirection - degreesAperture <degreesTwoFromPosition && targetDirection + degreesAperture> degreesTwoFromPosition;

            if (isTargetInAngleFromOne && targetCompatibleHasAngle && mustHaveDirection)
            {
                result = true;
            }
            else if (isTargetInAngleFromOne && !mustHaveDirection)
            {
                result = true;
            }

            return(result);
        }
 public async Task <IEnumerable <IAircraft> > GetAirplanes(GeoPosition centerPosition = null, double radiusDistanceKilometers = 100)
 {
     return(await source.GetAirplanes(centerPosition, radiusDistanceKilometers, this.IsCacheEnabled));
 }