Example #1
0
 public PolygonSet2(PolygonSet2 <T> other)
 {
     if (other == null)
     {
         throw new ArgumentNullException();
     }
     this.Polygons = other.Polygons;
 }
Example #2
0
 public int CompareTo(PolygonSet2 <T> other)
 {
     if (other == null)
     {
         return(1);
     }
     if (object.ReferenceEquals(this, other))
     {
         return(0);
     }
     if (object.ReferenceEquals(this.Polygons, other.Polygons))
     {
         return(0);
     }
     return(this.Envelope.CompareTo(other.Envelope));
 }
Example #3
0
 public static Polygon2 <double> InvertExtent(PolygonSet2 <double> polys)
 {
     if (polys != null)
     {
         Ring2 <double>   outer  = polys.Factory.ConstructRing(polys.Envelope);
         Ring2 <double>[] inners = new Ring2 <double> [polys.Polygons.Length];
         for (int i = 0; i < inners.Length; i++)
         {
             inners[i] = polys.Polygons[i].OuterRing;
         }
         RingSet2 <double> innerSet = polys.Factory.ConstructRingSet(inners);
         if (innerSet == null)
         {
             return(null);
         }
         return(polys.Factory.ConstructPolygon(outer, innerSet));
     }
     return(null);
 }
Example #4
0
 public bool Equals(PolygonSet2 <T> other)
 {
     if (other == null)
     {
         return(false);
     }
     if (object.ReferenceEquals(this, other))
     {
         return(true);
     }
     if (object.ReferenceEquals(this.Polygons, other.Polygons))
     {
         return(true);
     }
     if (this.Polygons.Length == other.Polygons.Length && this.VertexCount.Equals(other.VertexCount) && this.Envelope.Equals(other.Envelope))
     {
         Polygon2 <T> us;
         Polygon2 <T> them;
         bool         match = false;
         for (int i = 0; i < this.Polygons.Length; i++)
         {
             us = this.Polygons[i];
             for (int j = 0; j < other.Polygons.Length; j++)
             {
                 them = other.Polygons[j];
                 if (us.Equals(them))
                 {
                     match = true;
                     break;
                 }
             }
             if (!match)
             {
                 return(false);
             }
             match = false;
         }
         return(true);
     }
     return(false);
 }
Example #5
0
        public static string ToWkt(PolygonSet2 <double> geom)
        {
            if (geom != null)
            {
                Polygon2 <double> curPoly;
                Ring2 <double>    cur;

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

                    for (uint j = 0; j < curPoly.SectionCount; j++)
                    {
                        cur = curPoly[j];
                        sb.Append('(');
                        for (uint i = 0; i < cur.VertexCount; i++)
                        {
                            sb.Append(cur[i].X);
                            sb.Append(' ');
                            sb.Append(cur[i].Y);
                            sb.Append(',');
                        }
                        sb[sb.Length - 1] = ')';
                        sb.Append(',');
                    }

                    sb[sb.Length - 1] = ')';
                    sb.Append(',');
                }
                sb[sb.Length - 1] = ')';
                return(sb.ToString());
            }
            return(string.Empty);
        }