Example #1
0
        /// <summary>
        /// 为了增强索引,将线的Envelop扩大
        /// </summary>
        /// <returns>增强后的Envelop</returns>
        public Envelope GetOptimizeEnvelop()
        {
            //这要有一个优化逻辑,如果接近90度或者0度的话需要增加rectangle

            double direction = UsefulUtility.RadianToDegree(Angle);

            if (Math.Abs(direction - 90) < threhold)
            {
                double stlo = 0f, edlo = 0f;
                //表示垂直的情况,小的经度更小,大的经度更大
                if (P0.X < P1.X)
                {
                    stlo = P0.X - extension;
                    edlo = P1.X + extension;
                }
                else
                {
                    stlo = P0.X + extension;
                    edlo = P1.X - extension;
                }
                return(new Envelope(stlo, edlo, P0.Y, P1.Y));
            }
            else if ((90 - Math.Abs(direction - 90)) < threhold)
            {
                double stla = 0, edla = 0;
                if (P0.Y < P1.Y)
                {
                    stla = P0.Y - extension;
                    edla = P1.Y + extension;
                }
                else
                {
                    stla = P0.Y + extension;
                    edla = P1.Y - extension;
                }
                return(new Envelope(P0.X, P1.X, stla, edla));
            }
            return(new Envelope(P0.X, P1.X, P0.Y, P1.Y));
        }
Example #2
0
 public double DistanceToOtherPointOnEarth(Coordinate c)
 {
     return(UsefulUtility.DistanceOnEarth(this, c));
 }