コード例 #1
0
        private static void AppendGeometryTaggedText(EsriGeometry geometry, StringWriter writer)
        {
            if (geometry == null)
            {
                throw new NullReferenceException("Cannot write Well-Known Text: geometry was null");
            }
            if (geometry is EsriPoint)
            {
                var point = geometry as EsriPoint;
                AppendPointTaggedText(point, writer);
            }
            else if (geometry is EsriPolyline)
            {
                var pl = (EsriPolyline)geometry;
                if (pl.Paths.Count == 1)
                {
                    AppendLineStringTaggedText(geometry as EsriPolyline, writer);
                }
                else if (pl.Paths.Count > 1)
                {
                    AppendMultiLineStringTaggedText(geometry as EsriPolyline, writer);
                }
            }
            else if (geometry is EsriPolygon)
            {
                var plo = (EsriPolygon)geometry;
                if (plo.Rings.Count == 1)
                {
                    AppendPolygonTaggedText(geometry as EsriPolygon, writer);
                }
                else if (plo.Rings.Count > 1)
                {
                    AppendMultiPolygonTaggedText(geometry as EsriPolygon, writer);
                }
            }
            else if (geometry is EsriMultiPoint)
            {
                AppendMultiPointTaggedText(geometry as EsriMultiPoint, writer);
            }
            else if (geometry is EsriExtent)
            {
                var ply = new EsriPolygon();
                EsriPointCollection pc = new EsriPointCollection();
                EsriExtent          ev = geometry as EsriExtent;
                pc.Add(new EsriPoint(ev.XMin, ev.YMin));
                pc.Add(new EsriPoint(ev.XMax, ev.YMin));
                pc.Add(new EsriPoint(ev.XMax, ev.YMax));
                pc.Add(new EsriPoint(ev.XMin, ev.YMax));
                pc.Add(new EsriPoint(ev.XMin, ev.YMin));
                ply.Rings.Add(pc);
                AppendPolygonTaggedText(ply, writer);
            }

            else
            {
                throw new NotSupportedException("Unsupported Geometry implementation:" + geometry.GetType().Name);
            }
        }
コード例 #2
0
 private static void AppendPolygonText(EsriPolygon polygon, StringWriter writer)
 {
     if (polygon == null)
     {
         writer.Write("Empty");
     }
     else
     {
         writer.Write("(");
         AppendLineStringText(polygon.Rings[0], writer);
         for (int i = 1; i < polygon.Rings.Count; i++)
         {
             writer.Write(", ");
             AppendLineStringText(polygon.Rings[i], writer);
         }
         writer.Write(")");
     }
 }
コード例 #3
0
 private static void AppendMultiPolygonText(EsriPolygon multiPolygon, StringWriter writer)
 {
     if (multiPolygon == null)
     {
         writer.Write("Empty");
     }
     else
     {
         writer.Write("(");
         for (int i = 0; i < multiPolygon.Rings.Count; i++)
         {
             if (i > 0)
             {
                 writer.Write(", ");
             }
             EsriPolygon pol = new EsriPolygon();
             pol.Rings.Add(multiPolygon.Rings[i]);
             AppendPolygonText(pol, writer);
         }
         writer.Write(")");
     }
 }
コード例 #4
0
 private static void AppendPolygonTaggedText(EsriPolygon polygon, StringWriter writer)
 {
     writer.Write("Polygon");
     AppendPolygonText(polygon, writer);
 }
コード例 #5
0
 private static void AppendMultiPolygonTaggedText(EsriPolygon multiPolygon, StringWriter writer)
 {
     writer.Write("MultiPolygon");
     AppendMultiPolygonText(multiPolygon, writer);
 }