Exemplo n.º 1
0
        /// <summary>
        /// Calculates the intersection of this extent and the other extent.  A result
        /// with a min greater than the max in either direction is considered invalid
        /// and represents no intersection.
        /// </summary>
        /// <param name="other">The other extent to intersect with.</param>
        public override Extent Intersection(Extent other)
        {
            IExtentZ zOther = other as IExtentZ;
            IExtentM mOther = other as IExtentM;
            Extent   result = null;

            if (HasZ && zOther != null && other.HasZ)
            {
                ExtentMZ zResult = new ExtentMZ
                {
                    MinZ = (MinZ > zOther.MinZ) ? MinZ : zOther.MinZ,
                    MaxZ = (MaxZ < zOther.MaxZ) ? MaxZ : zOther.MaxZ
                };

                result = zResult;
            }
            if (HasM && mOther != null && other.HasM)
            {
                ExtentM mResult = result as ExtentM ?? new ExtentM();
                mResult.MinM = (MinM > mOther.MinM) ? MinM : mOther.MinM;
                mResult.MaxM = (MaxM < mOther.MaxM) ? MaxM : mOther.MaxM;
                result       = mResult;
            }
            else
            {
                result = new Extent();
            }

            result.MinX = (MinX > other.MinX) ? MinX : other.MinX;
            result.MaxX = (MaxX < other.MaxX) ? MaxX : other.MaxX;
            result.MinY = (MinY > other.MinY) ? MinY : other.MinY;
            result.MaxY = (MaxY < other.MaxY) ? MaxY : other.MaxY;
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates the intersection of this extent and the other extent.  A result
        /// with a min greater than the max in either direction is considered invalid
        /// and represents no intersection.
        /// </summary>
        /// <param name="other">The other extent to intersect with.</param>
        public override Extent Intersection(Extent other)
        {
            IExtentM mOther = other as IExtentM;
            Extent   result;

            if (HasM && mOther != null && other.HasM)
            {
                ExtentM mResult = new ExtentM
                {
                    MinM = (MinM > mOther.MinM) ? MinM : mOther.MinM,
                    MaxM = (MaxM < mOther.MaxM) ? MaxM : mOther.MaxM
                };

                result = mResult;
            }
            else
            {
                result = new Extent();
            }

            result.MinX = (MinX > other.MinX) ? MinX : other.MinX;
            result.MaxX = (MaxX < other.MaxX) ? MaxX : other.MaxX;
            result.MinY = (MinY > other.MinY) ? MinY : other.MinY;
            result.MaxY = (MaxY < other.MaxY) ? MaxY : other.MaxY;
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Calculates the intersection of this extent and the other extent. A result
        /// with a min greater than the max in either direction is considered invalid
        /// and represents no intersection.
        /// </summary>
        /// <param name="other">The other extent to intersect with.</param>
        /// <returns>The resulting intersection.</returns>
        public override Extent Intersection(Extent other)
        {
            IExtentZ zOther = other as IExtentZ;
            IExtentM mOther = other as IExtentM;
            Extent   result = null;

            if (HasZ && zOther != null && other.HasZ)
            {
                ExtentMz zResult = new ExtentMz
                {
                    MinZ = MinZ > zOther.MinZ ? MinZ : zOther.MinZ,
                    MaxZ = MaxZ < zOther.MaxZ ? MaxZ : zOther.MaxZ
                };

                result = zResult;
            }

            if (HasM && mOther != null && other.HasM)
            {
                ExtentM mResult = (ExtentM)result ?? new ExtentM();
                mResult.MinM = MinM > mOther.MinM ? MinM : mOther.MinM;
                mResult.MaxM = MaxM < mOther.MaxM ? MaxM : mOther.MaxM;
                result       = mResult;
            }
            else
            {
                result = new Extent();
            }

            result.MinX = MinX > other.MinX ? MinX : other.MinX;
            result.MaxX = MaxX < other.MaxX ? MaxX : other.MaxX;
            result.MinY = MinY > other.MinY ? MinY : other.MinY;
            result.MaxY = MaxY < other.MaxY ? MaxY : other.MaxY;
            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// This allows parsing the X and Y values from a string version of the extent as: 'X[-180|180], Y[-90|90]'
        /// Where minimum always precedes maximum. The correct M or MZ version of extent will be returned if the string has those values.
        /// </summary>
        /// <param name="text">Text that contains the extent values.</param>
        /// <param name="result">Extent that was created.</param>
        /// <param name="nameFailed">Indicates which value failed.</param>
        /// <returns>True if the string could be parsed to an extent.</returns>
        public static bool TryParse(string text, out Extent result, out string nameFailed)
        {
            double xmin, xmax, ymin, ymax, mmin, mmax;

            result = null;
            if (text.Contains("Z"))
            {
                double zmin, zmax;
                nameFailed = "Z";
                ExtentMz mz = new ExtentMz();
                if (!TryExtract(text, "Z", out zmin, out zmax))
                {
                    return(false);
                }
                mz.MinZ    = zmin;
                mz.MaxZ    = zmax;
                nameFailed = "M";
                if (!TryExtract(text, "M", out mmin, out mmax))
                {
                    return(false);
                }
                mz.MinM = mmin;
                mz.MaxM = mmax;
                result  = mz;
            }
            else if (text.Contains("M"))
            {
                nameFailed = "M";
                ExtentM me = new ExtentM();
                if (!TryExtract(text, "M", out mmin, out mmax))
                {
                    return(false);
                }
                me.MinM = mmin;
                me.MaxM = mmax;
                result  = me;
            }
            else
            {
                result = new Extent();
            }

            nameFailed = "X";
            if (!TryExtract(text, "X", out xmin, out xmax))
            {
                return(false);
            }
            result.MinX = xmin;
            result.MaxX = xmax;
            nameFailed  = "Y";
            if (!TryExtract(text, "Y", out ymin, out ymax))
            {
                return(false);
            }
            result.MinY = ymin;
            result.MaxY = ymax;
            return(true);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Calculates the intersection of this extent and the other extent. A result
        /// with a min greater than the max in either direction is considered invalid
        /// and represents no intersection.
        /// </summary>
        /// <param name="other">The other extent to intersect with.</param>
        /// <returns>The intersection.</returns>
        public override Extent Intersection(Extent other)
        {
            Extent result;

            if (HasM && other is IExtentM mOther && other.HasM)
            {
                ExtentM mResult = new ExtentM
                {
                    MinM = (MinM > mOther.MinM) ? MinM : mOther.MinM,
                    MaxM = (MaxM < mOther.MaxM) ? MaxM : mOther.MaxM
                };

                result = mResult;
            }
Exemplo n.º 6
0
        /// <summary>
        /// Calculates the intersection of this extent and the other extent. A result
        /// with a min greater than the max in either direction is considered invalid
        /// and represents no intersection.
        /// </summary>
        /// <param name="other">The other extent to intersect with.</param>
        /// <returns>The resulting intersection.</returns>
        public override Extent Intersection(Extent other)
        {
            Extent result = null;

            if (HasZ && other is IExtentZ zOther && other.HasZ)
            {
                ExtentMz zResult = new ExtentMz
                {
                    MinZ = MinZ > zOther.MinZ ? MinZ : zOther.MinZ,
                    MaxZ = MaxZ < zOther.MaxZ ? MaxZ : zOther.MaxZ
                };

                result = zResult;
            }

            if (HasM && other is IExtentM mOther && other.HasM)
            {
                ExtentM mResult = (ExtentM)result ?? new ExtentM();
                mResult.MinM = MinM > mOther.MinM ? MinM : mOther.MinM;
                mResult.MaxM = MaxM < mOther.MaxM ? MaxM : mOther.MaxM;
                result       = mResult;
            }
Exemplo n.º 7
0
        /// <summary>
        /// Produces a clone, rather than using this same object.
        /// </summary>
        /// <returns>Returns a copy of this object.</returns>
        public override object Clone()
        {
            ExtentM copy = new ExtentM(MinX, MinY, MinM, MaxX, MaxY, MaxM);

            return(copy);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Calculates the intersection of this extent and the other extent.  A result
        /// with a min greater than the max in either direction is considered invalid
        /// and represents no intersection.
        /// </summary>
        /// <param name="other">The other extent to intersect with.</param>
        public override Extent Intersection(Extent other)
        {
            IExtentM mOther = other as IExtentM;
            Extent result;
            if (HasM && mOther != null && other.HasM)
            {
                ExtentM mResult = new ExtentM
                                  {
                                      MinM = (MinM > mOther.MinM) ? MinM : mOther.MinM,
                                      MaxM = (MaxM < mOther.MaxM) ? MaxM : mOther.MaxM
                                  };

                result = mResult;
            }
            else
            {
                result = new Extent();
            }

            result.MinX = (MinX > other.MinX) ? MinX : other.MinX;
            result.MaxX = (MaxX < other.MaxX) ? MaxX : other.MaxX;
            result.MinY = (MinY > other.MinY) ? MinY : other.MinY;
            result.MaxY = (MaxY < other.MaxY) ? MaxY : other.MaxY;
            return result;
        }
Exemplo n.º 9
0
 /// <summary>
 /// Produces a clone, rather than using this same object.
 /// </summary>
 /// <returns>Returns a copy of this object.</returns>
 public override object Clone()
 {
     ExtentM copy = new ExtentM(MinX, MinY, MinM, MaxX, MaxY, MaxM);
     return copy;
 }
Exemplo n.º 10
0
 /// <summary>
 /// This reads the string and attempts to derive values from the text.
 /// </summary>
 /// <param name="text"></param>
 /// <param name="result"></param>
 /// <param name="nameFailed"></param>
 /// <returns></returns>
 public static bool TryParse(string text, out Extent result, out string nameFailed)
 {
     double xmin, xmax, ymin, ymax, mmin, mmax;
     result = null;
     if (text.Contains("Z"))
     {
         double zmin, zmax;
         nameFailed = "Z";
         ExtentMZ mz = new ExtentMZ();
         if (TryExtract(text, "Z", out zmin, out zmax) == false) return false;
         mz.MinZ = zmin;
         mz.MaxZ = zmax;
         nameFailed = "M";
         if (TryExtract(text, "M", out mmin, out mmax) == false) return false;
         mz.MinM = mmin;
         mz.MaxM = mmax;
         result = mz;
     }
     else if (text.Contains("M"))
     {
         nameFailed = "M";
         ExtentM me = new ExtentM();
         if (TryExtract(text, "M", out mmin, out mmax) == false) return false;
         me.MinM = mmin;
         me.MaxM = mmax;
         result = me;
     }
     else
     {
         result = new Extent();
     }
     nameFailed = "X";
     if (TryExtract(text, "X", out xmin, out xmax) == false) return false;
     result.MinX = xmin;
     result.MaxX = xmax;
     nameFailed = "Y";
     if (TryExtract(text, "Y", out ymin, out ymax) == false) return false;
     result.MinY = ymin;
     result.MaxY = ymax;
     return true;
 }