Example #1
0
        public static Position GetPosition(this Location source, double distance)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return(LocationUtility.GetPosition(source, distance));
        }
Example #2
0
        public static double GetDistance(this Location source, double latitude, double longitude)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return(LocationUtility.GetDistance(source.Latitude, source.Longitude, latitude, longitude));
        }
Example #3
0
        public static double GetDistance(this Location source, Location target)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            return(LocationUtility.GetDistance(source, target));
        }
Example #4
0
        /// <summary>
        /// 监测指定的位置点 <paramref name="source"/> 是否在位置 <paramref name="target"/> 的指定公里范围内。
        /// </summary>
        /// <param name="source">位置点。</param>
        /// <param name="target">目标位置点。</param>
        /// <param name="distance">目标范围(公里)</param>
        /// <returns>如果在指定的范围内则为true,否则为false。</returns>
        public static bool IsInRange(Location source, Location target, double distance)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            // 计算目标位置的四个顶点。
            var position = LocationUtility.GetPosition(target, distance);

            return(source.Latitude < position.LeftTop.Latitude && source.Latitude > position.RightBottom.Latitude && source.Longitude > position.LeftTop.Longitude && source.Longitude < position.RightBottom.Longitude);
        }
Example #5
0
 public static bool IsInRange(this Location source, double latitude, double longitude, double distance)
 {
     return(LocationUtility.IsInRange(source, new Location(latitude, longitude), distance));
 }
Example #6
0
 public static bool IsInRange(this Location source, Location target, double distance)
 {
     return(LocationUtility.IsInRange(source, target, distance));
 }
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     return(LocationUtility.Parse(value as string));
 }