Ejemplo n.º 1
0
 public PolygonBag2(PolygonBag2 <T> other)
 {
     if (other == null)
     {
         throw new ArgumentNullException();
     }
     this.Polygons = other.Polygons;
 }
Ejemplo n.º 2
0
 public int CompareTo(PolygonBag2 <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));
 }
Ejemplo n.º 3
0
        public static JObject ToGeoJson(PolygonBag2 <double> geom)
        {
            if (geom == null)
            {
                return((JObject)null);
            }
            JObject jobject = new JObject();

            jobject.Add("type", (JToken) new JValue("MultiPolygon"));
            JArray jarray1 = new JArray();

            foreach (Polygon2 <double> polygon in geom)
            {
                JArray jarray2 = new JArray();
                foreach (Point2 <double> coordinate in polygon.OuterRing)
                {
                    jarray2.Add((JToken) new JArray()
                    {
                        (JToken)coordinate.X,
                        (JToken)coordinate.Y
                    });
                }
                if (polygon.HasHoles)
                {
                    foreach (Ring2 <double> linearRing in polygon.InnerRings)
                    {
                        JArray jarray3 = new JArray();
                        foreach (Point2 <double> coordinate in linearRing)
                        {
                            jarray3.Add((JToken) new JArray()
                            {
                                (JToken)coordinate.X,
                                (JToken)coordinate.Y
                            });
                        }
                        jarray2.Add((JToken)jarray3);
                    }
                }
                jarray1.Add((JToken)jarray2);
            }
            jobject.Add("coordinates", (JToken)jarray1);
            return(jobject);
        }
Ejemplo n.º 4
0
 public bool Equals(PolygonBag2 <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);
 }
Ejemplo n.º 5
0
        public static string ToWkt(PolygonBag2 <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);
        }