예제 #1
0
 public bool IntersectsWith(PrjEnvelopeF rect)
 {
     return(_minX < rect.MaxX &&
            _maxX > rect.MinX &&
            _minY < rect.MaxY &&
            _maxY > rect.MinY);
 }
예제 #2
0
        public override bool Equals(object obj)
        {
            // Check the identity case for reference equality
            if (base.Equals(obj))
            {
                return(true);
            }
            PrjEnvelopeF other = obj as PrjEnvelopeF;

            if (other == null)
            {
                return(false);
            }
            if (MinX != other.MinX)
            {
                return(false);
            }
            if (MaxX != other.MaxX)
            {
                return(false);
            }
            if (MinY != other.MinY)
            {
                return(false);
            }
            if (MaxY != other.MaxY)
            {
                return(false);
            }
            return(true);
        }
예제 #3
0
 public bool Contains(PrjEnvelopeF ext)
 {
     Contract.Requires(ext != null);
     return((this.MinX <= ext.MinX) &&
            ((ext.MaxX) <= (this.MaxX)) &&
            (this.MinY <= ext.MinY) &&
            ((ext.MaxY) <= (this.MaxY)));
 }
예제 #4
0
        public void Intersect(PrjEnvelopeF rect)
        {
            PrjEnvelopeF result = PrjEnvelopeF.Intersect(rect, this);

            this.MinX = result.MinX;
            this.MinY = result.MinY;
            this.MaxX = result.MaxX;
            this.MaxY = result.MaxY;
        }
예제 #5
0
        public static PrjEnvelopeF GetEnvelope(double[] srcXs, double[] srcYs, PrjEnvelopeF maskEnvelope)
        {
            float MaxX = float.MaxValue;
            float MinX = float.MinValue;
            float MaxY = float.MaxValue;
            float MinY = float.MinValue;

            if (maskEnvelope != null)
            {
                MaxX = (float)maskEnvelope.MaxX;
                MinX = (float)maskEnvelope.MinX;
                MaxY = (float)maskEnvelope.MaxY;
                MinY = (float)maskEnvelope.MinY;
            }
            double curMinX = MaxX;
            double curMaxX = MinX;
            double curMinY = MaxY;
            double curMaxY = MinY;

            unsafe
            {
                fixed(double *xP = srcXs, yP = srcYs)
                {
                    double *px     = xP;
                    double *py     = yP;
                    int     length = srcXs.Length;

                    for (int i = 0; i < length; i++, px++, py++)
                    {
                        if (*px < MinX || *px > MaxX || *py < MinY || *py > MaxY)
                        {
                            continue;
                        }
                        if (curMaxX < *px)
                        {
                            curMaxX = *px;
                        }
                        else if (curMinX > *px)
                        {
                            curMinX = *px;
                        }
                        if (curMaxY < *py)
                        {
                            curMaxY = *py;
                        }
                        else if (curMinY > *py)
                        {
                            curMinY = *py;
                        }
                    }
                }
            }
            PrjEnvelopeF dstEnvelope = new PrjEnvelopeF(curMinX, curMaxX, curMinY, curMaxY);

            return(dstEnvelope);
        }
예제 #6
0
        public static PrjEnvelopeF Union(PrjEnvelopeF a, PrjEnvelopeF b)
        {
            if (a == null)
            {
                return(b);
            }
            if (b == null)
            {
                return(a);
            }
            float minx = a.MinX < b.MinX ? a.MinX : b.MinX;
            float maxx = a.MaxX > b.MaxX ? a.MaxX : b.MaxX;
            float miny = a.MinY < b.MinY ? a.MinY : b.MinY;
            float maxy = a.MaxY > b.MaxY ? a.MaxY : b.MaxY;

            return(new PrjEnvelopeF(minx, maxx, miny, maxy));
        }
예제 #7
0
        public static PrjEnvelopeF Intersect(PrjEnvelopeF a, PrjEnvelopeF b)
        {
            Contract.Requires(a != null && b != null);
            float minx = a.MinX > b.MinX ? a.MinX : b.MinX; //Math.Max(a.MinX, b.MinX);
            float maxx = a.MaxX < b.MaxX ? a.MaxX : b.MaxX; //Math.Min(a.MaxX, b.MaxX);
            float miny = a.MinY > b.MinY ? a.MinY : b.MinY; //Math.Max(a.MinY, b.MinY);
            float maxy = a.MaxY < b.MaxY ? a.MaxY : b.MaxY; //Math.Min(a.MaxY, b.MaxY);

            if (minx > maxx)
            {
                return(null);
            }
            if (miny > maxy)
            {
                return(null);
            }
            return(new PrjEnvelopeF(minx, maxx, miny, maxy));
        }
예제 #8
0
        public static PrjEnvelopeF GetEnvelope(float[] srcXs, float[] srcYs, PrjEnvelopeF maskEnvelope)
        {
            double MaxX = float.MaxValue;
            double MinX = float.MinValue;
            double MaxY = float.MaxValue;
            double MinY = float.MinValue;

            if (maskEnvelope != null)
            {
                MaxX = maskEnvelope.MaxX;
                MinX = maskEnvelope.MinX;
                MaxY = maskEnvelope.MaxY;
                MinY = maskEnvelope.MinY;
            }
            int   length  = srcXs.Length;
            float curMinX = srcXs[0];
            float curMaxX = srcXs[0];
            float curMinY = srcYs[0];
            float curMaxY = srcYs[0];

            for (int i = 0; i < length; i++)
            {
                if (srcXs[i] < MinX || srcXs[i] > MaxX || srcYs[i] < MinY || srcYs[i] > MaxY)
                {
                    continue;
                }
                curMinX = srcXs[i];
                curMaxX = srcXs[i];
                curMinY = srcYs[i];
                curMaxY = srcYs[i];
                break;
            }
            unsafe
            {
                fixed(float *xP = srcXs, yP = srcYs)
                {
                    float *px = xP;
                    float *py = yP;

                    for (int i = 0; i < length; i++, px++, py++)
                    {
                        if (*px < MinX || *px > MaxX || *py < MinY || *py > MaxY)
                        {
                            continue;
                        }
                        if (curMaxX < *px)
                        {
                            curMaxX = *px;
                        }
                        else if (curMinX > *px)
                        {
                            curMinX = *px;
                        }
                        if (curMaxY < *py)
                        {
                            curMaxY = *py;
                        }
                        else if (curMinY > *py)
                        {
                            curMinY = *py;
                        }
                    }
                }
            }
            PrjEnvelopeF dstEnvelope = new PrjEnvelopeF(curMinX, curMaxX, curMinY, curMaxY);

            return(dstEnvelope);
        }