示例#1
0
        public override string AsWKT()
        {   //  "LINESTRING (10 20, 30 40, 50 60)"
            //  "MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10), (40 40, 30 30, 40 20, 30 10))"
            //  "POLYGON ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10), (40 40, 30 30, 40 20, 30 10))"
            //  "MULTIPOLYGON (((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10), (40 40, 30 30, 40 20, 30 10)))"
            int count = this.Polygons.Count;

            if (count < 1)
            {
                return(null);
            }
            MG_Polygon p = (MG_Polygon)this.Polygons[0];

            string front = "{0} ({1}";

            front = String.Format(front, this.Type.ToString(), p.AsWKT_Reduced());

            string m   = ", {0}";
            string mid = "";

            for (int i = 1; i < count; i++)
            {
                MG_Polygon pp = (MG_Polygon)this.Polygons[i];
                mid += String.Format(m, pp.AsWKT_Reduced());
            }

            string end = ")";

            return(front + mid + end);
        }
示例#2
0
        public MG_Feature(MG_Feature f)
        {
            this.FieldSet = new MG_FieldSet();
            this.ValueSet = new MG_ValueSet();
            this.Geometry = new MG_Geometry();
            this.Symbol   = new MG_Symbol();

            for (int i = 0; i < f.GetFieldCount(); i++)
            {
                MG_Field field    = f.GetFieldSet().GetAt(i);
                MG_Field newField = new MG_Field(field);
                this.FieldSet.Add(newField);

                MG_Value value    = f.GetValue(i);
                MG_Value newValue = new MG_Value(value);
                this.ValueSet.Add(newValue);
            }
            MG_Geometry g       = f.GetGeometry();
            MG_Geometry newGeom = new MG_Geometry();

            switch (g.Type)
            {
            case MG_GeometryType.NONE:
                break;

            case MG_GeometryType.POINT:
                newGeom = new MG_Point(g as MG_Point);
                break;

            case MG_GeometryType.MULTIPOINT:
                newGeom = new MG_MultiPoint(g as MG_MultiPoint);
                break;

            case MG_GeometryType.LINESTRING:
                newGeom = new MG_LineString(g as MG_LineString);
                break;

            case MG_GeometryType.MULTILINESTRING:
                newGeom = new MG_MultiLineString(g as MG_MultiLineString);
                break;

            case MG_GeometryType.POLYGON:
                newGeom = new MG_Polygon(g as MG_Polygon);
                break;

            case MG_GeometryType.MULTIPOLYGON:
                newGeom = new MG_MultiPolygon(g as MG_MultiPolygon);
                break;
            }
            this.Geometry = newGeom;
            MG_Symbol newSymbol = new MG_Symbol(f.GetSymbol());

            this.Symbol = newSymbol;
        }
示例#3
0
 public MG_MultiPolygon(MG_MultiPolygon mp)
 {
     this.Type     = MG_GeometryType.MULTIPOLYGON;
     this.Polygons = new List <MG_Polygon>();
     if (mp != null)
     {
         for (int i = 0; i < mp.Count(); i++)
         {
             MG_Polygon p = new MG_Polygon(mp.GetAt(i));
             this.Polygons.Add(p);
         }
     }
 }
示例#4
0
 public MG_Polygon(MG_Polygon p)
 {
     this.Type        = MG_GeometryType.POLYGON;
     this.LineStrings = new List <MG_LineString>();
     if (p != null)
     {
         for (int i = 0; i < p.Count(); i++)
         {
             MG_LineString l = new MG_LineString(p.GetAt(i));
             this.LineStrings.Add(l);
         }
     }
 }
示例#5
0
 public MG_Polygon(MG_Polygon p)
 {
     this.Type = MG_GeometryType.POLYGON;
     this.LineStrings = new List<MG_LineString>();
     if (p != null)
     {
         for (int i = 0; i < p.Count(); i++)
         {
             MG_LineString l = new MG_LineString(p.GetAt(i));
             this.LineStrings.Add(l);
         }
     }
 }
示例#6
0
        public MG_Feature(MG_Feature f)
        {
            this.FieldSet = new MG_FieldSet();
            this.ValueSet = new MG_ValueSet();
            this.Geometry = new MG_Geometry();
            this.Symbol = new MG_Symbol();

            for (int i = 0; i < f.GetFieldCount();i++ )
            {
                MG_Field field = f.GetFieldSet().GetAt(i);
                MG_Field newField = new MG_Field(field);
                this.FieldSet.Add(newField);

                MG_Value value = f.GetValue(i);
                MG_Value newValue = new MG_Value(value);
                this.ValueSet.Add(newValue);
            }
            MG_Geometry g = f.GetGeometry();
            MG_Geometry newGeom = new MG_Geometry();
            switch (g.Type)
            {
                case MG_GeometryType.NONE:
                    break;
                case MG_GeometryType.POINT:
                    newGeom = new MG_Point(g as MG_Point);
                    break;
                case MG_GeometryType.MULTIPOINT:
                    newGeom = new MG_MultiPoint(g as MG_MultiPoint);
                    break;
                case MG_GeometryType.LINESTRING:
                    newGeom = new MG_LineString(g as MG_LineString);
                    break;
                case MG_GeometryType.MULTILINESTRING:
                    newGeom = new MG_MultiLineString(g as MG_MultiLineString);
                    break;
                case MG_GeometryType.POLYGON:
                    newGeom = new MG_Polygon(g as MG_Polygon);
                    break;
                case MG_GeometryType.MULTIPOLYGON:
                    newGeom = new MG_MultiPolygon(g as MG_MultiPolygon);
                    break;
            }
            this.Geometry = newGeom;
            MG_Symbol newSymbol = new MG_Symbol(f.GetSymbol());
            this.Symbol = newSymbol;
        }
示例#7
0
        private void testGeometry()
        {
            MG_Point p = new MG_Point(100, 200);
            string type = p.Type.ToString();
            string wkt = p.AsWKT();
            string wkt_reduced = p.AsWKT_Reduced();
            byte[] wkb = p.AsWKB();

            MG_MultiPoint mp = new MG_MultiPoint();
            for (int i = 0; i < 10; i++)
            {
                MG_Point pp = new MG_Point(i, i);
                mp.Add(pp);
            }
            type = mp.Type.ToString();
            wkt = mp.AsWKT();
            wkt_reduced = mp.AsWKT_Reduced();
            wkb = mp.AsWKB();

            MG_LineString l = new MG_LineString();
            for (int i = 0; i < 10; i++)
            {
                MG_Point pp = new MG_Point(i, i);
                l.Add(pp);
            }
            type = l.Type.ToString();
            wkt = l.AsWKT();
            wkt_reduced = l.AsWKT_Reduced();
            wkb = l.AsWKB();

            MG_MultiLineString ml = new MG_MultiLineString();
            for (int i = 0; i < 5; i++)
            {
                MG_LineString l2 = new MG_LineString();
                for (int j = 0; j < 3; j++)
                {
                    MG_Point pp = new MG_Point(i, j);
                    l2.Add(pp);
                }
                ml.Add(l2);
            }
            type = ml.Type.ToString();
            wkt = ml.AsWKT();
            wkt_reduced = ml.AsWKT_Reduced();
            wkb = ml.AsWKB();

            MG_Polygon pg = new MG_Polygon();
            for (int i = 0; i < 5; i++)
            {
                MG_LineString l2 = new MG_LineString();
                for (int j = 0; j < 3; j++)
                {
                    MG_Point pp = new MG_Point(i, j);
                    l2.Add(pp);
                }
                pg.Add(l2);
            }
            type = pg.Type.ToString();
            wkt = pg.AsWKT();
            wkt_reduced = pg.AsWKT_Reduced();
            wkb = pg.AsWKB();
        }
示例#8
0
 public void Remove(MG_Polygon p)
 {
     this.Polygons.Remove(p);
 }
示例#9
0
 public void Add(MG_Polygon p)
 {
     this.Polygons.Add(p);
 }
示例#10
0
 public static void RenderPolygon(Graphics g, Pen pen, MG_MapView mapview, MG_Polygon polygon)
 {
     int countLineString = polygon.Count();
     for (int i = 0; i < countLineString; i++)
     {
         MG_LineString lineString = polygon.GetAt(i);
         int countPoint = lineString.Count();
         if (countPoint < 3)
             return;
         Point[] points = new Point[countPoint];
         for (int j = 0; j < countPoint; j++)
         {
             MG_Point mp = lineString.GetAt(j);
             points[j] = AsPoint(mp, mapview);
         }
         //FillPolygon(g, brush, points);
         //Pen pen = new Pen(Color.Red, 1);
         DrawPolygon(g, pen, points);
     }
 }
示例#11
0
 public MG_ToolDrawPolygon(MG_Layer layer, MG_MapView mapview)
     : base(MG_ToolType.Tool_DrawPolygon, layer, mapview)
 {
     this.LineString = new MG_LineString();
     this.Polygon = new MG_Polygon();
 }