コード例 #1
0
        //MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)), ((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1)))
        public static string ToWkt(RingBag2 <double> geom)
        {
            if (geom != null)
            {
                Ring2 <double> cur;

                StringBuilder sb = new StringBuilder();
                sb.Append("MULTIPOLYGON(");
                for (uint i = 0; i < geom.PartCount; i++)
                {
                    sb.Append("((");
                    cur = geom[i];

                    for (uint j = 0; j < cur.VertexCount; j++)
                    {
                        sb.Append(cur[j].X);
                        sb.Append(' ');
                        sb.Append(cur[j].Y);
                        sb.Append(',');
                    }
                    sb.Length = sb.Length - 1; //truncate last ,
                    sb.Append(")),");
                }
                if (geom.PartCount > 0)
                {
                    sb[sb.Length - 1] = ')';
                }
                else
                {
                    sb.Append(')');
                }
                return(sb.ToString());
            }
            return(string.Empty);
        }
コード例 #2
0
ファイル: RingBag2.cs プロジェクト: OSRS/Oncor_OsrsLegacy
 public RingBag2(RingBag2 <T> other)
 {
     if (other == null)
     {
         throw new ArgumentNullException();
     }
     this.Rings = other.Rings;
 }
コード例 #3
0
ファイル: RingBag2.cs プロジェクト: OSRS/Oncor_OsrsLegacy
 public int CompareTo(RingBag2 <T> other)
 {
     if (other == null)
     {
         return(1);
     }
     if (object.ReferenceEquals(this, other))
     {
         return(0);
     }
     if (object.ReferenceEquals(this.Rings, other.Rings))
     {
         return(0);
     }
     return(this.Envelope.CompareTo(other.Envelope));
 }
コード例 #4
0
ファイル: RingBag2.cs プロジェクト: OSRS/Oncor_OsrsLegacy
 public override bool Equals(object obj)
 {
     if (object.ReferenceEquals(null, obj))
     {
         return(false);
     }
     if (object.ReferenceEquals(this, obj))
     {
         return(true);
     }
     if (obj is RingBag2 <T> )
     {
         RingBag2 <T> other = obj as RingBag2 <T>;
         if (other != null && this.Rings.Length == other.Rings.Length)
         {
             Ring2 <T> curUs;
             Ring2 <T> curThem;
             bool      match;
             for (int i = 0; i < this.Rings.Length; i++)
             {
                 match = false;
                 curUs = this.Rings[i];
                 for (int j = 0; j < other.Rings.Length; j++)
                 {
                     curThem = other.Rings[j];
                     if (curThem.Equals(curUs))
                     {
                         match = true;
                         break; //no point checking more
                     }
                 }
                 if (!match)
                 {
                     return(false); //didn't find a chain
                 }
             }
             return(true);
         }
     }
     return(false);
 }
コード例 #5
0
ファイル: RingBag2.cs プロジェクト: OSRS/Oncor_OsrsLegacy
 public bool Equals(RingBag2 <T> other)
 {
     if (other == null)
     {
         return(false);
     }
     if (object.ReferenceEquals(this, other))
     {
         return(true);
     }
     if (object.ReferenceEquals(this.Rings, other.Rings))
     {
         return(true);
     }
     if (this.VertexCount.Equals(other.VertexCount) && this.Envelope.Equals(other.Envelope))
     {
         Ring2 <T> us;
         Ring2 <T> them;
         for (int i = 0; i < this.Rings.Length; i++)
         {
             us   = this.Rings[i];
             them = other.Rings[i];
             if (us.Points.Length != them.Points.Length)
             {
                 return(false); //can't be the same
             }
             for (int j = 0; j < us.Points.Length; j++)
             {
                 if (!us.Points[j].Equals(them.Points[j]))
                 {
                     return(false);
                 }
             }
         }
         return(true);
     }
     return(false);
 }