Example #1
0
 public static void RenderFeature(MG_Feature f, MG_MapView mapview, Graphics g)
 {
     //int realValue = GetRealValue(f.Symbol.LineWidth, mapview);
     Pen pen = new Pen(f.Symbol.OutlineColor, f.Symbol.LineWidth);
     SolidBrush brush = new SolidBrush(f.Symbol.FillColor);
     RenderGeometry(g, pen, brush, mapview, f.Geometry);
 }
Example #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;
        }
Example #3
0
 // feature
 public void AddFeature(MG_Feature feature)
 {
     if (this.Type == MG_GeometryType.NONE)
     {
         this.Type = feature.GetGeometry().Type;
         this.FeatureSet.Add(feature);
     }
     else if (this.Type == feature.GetGeometry().Type)
     {
         this.FeatureSet.Add(feature);
     }
 }
Example #4
0
 // feature
 public void AddFeature(MG_Feature feature)
 {
     if (this.Type == MG_GeometryType.NONE)
     {
         this.Type = feature.GetGeometry().Type;
         this.FeatureSet.Add(feature);
     }
     else if (this.Type == feature.GetGeometry().Type)
     {
         this.FeatureSet.Add(feature);
     }
 }
Example #5
0
        public MG_BaseTool(MG_ToolType type, MG_Layer layer, MG_MapView mapview)
        {
            this.ToolType = type;

               this.Layer = layer;
               this.MapView = mapview;
               if (layer!=null)
               {// pan tool: layer==null
               this.Feature = new MG_Feature(this.Layer.GetFieldSet());
               }

               // empty point
               this.FromPoint = Point.Empty;
               this.ToPoint = Point.Empty;
               this.Point3 = Point.Empty;
               this.SelectRect = Rectangle.Empty;
        }
Example #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;
        }
        public override void MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                this.IsMouseDown = false;
                Panel panel = (Panel)sender;

                if (this.Step == 0)
                {

                }
                else if (this.Step == 1)
                {
                    // add last point
                    this.ToPoint = new Point(e.X, e.Y);
                    MG_Point mapPoint = MG_BaseRender.ToPoint(this.ToPoint, this.MapView);
                    this.LineString.Add(mapPoint);

                    //1 create a feature
                    // 1.1 set geometry
                    this.Feature.SetGeometry(this.LineString);
                    // 1.2 set field value
                    for (int i = 0; i < this.Feature.GetFieldSet().Count(); i++)
                    {
                        this.Feature.SetValue(i, null);
                    }

                    //2 create a new feature
                    MG_Feature newFeature = new MG_Feature(this.Feature);
                    //3 add new feature to layer
                    this.Layer.AddFeature(newFeature);

                    //4 clear data to store the next linestring
                    this.LineString.Clear();

                    // 5 reset control params
                    this.Step = 0;
                    this.FromPoint = Point.Empty;
                    this.ToPoint = Point.Empty;
                }
            }
        }
Example #8
0
        public override void MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Panel panel = (Panel)sender;
                this.FromPoint = new Point(e.X, e.Y);

                // draw point
                MG_BaseDisplay.FillPoint(panel.CreateGraphics(), brush, this.FromPoint,MG_Constant.PointRadius);

                // screen to map
                this.MapPoint = MG_BaseRender.ToPoint(this.FromPoint, this.MapView);

                //1 create a feature
                // 1.1 set geometry
                this.Feature.SetGeometry(this.MapPoint);
                // 1.2 set field value
                for (int i = 0; i < this.Feature.GetFieldSet().Count();i++ )
                {
                    this.Feature.SetValue(i, null);
                }

                //2 create a new feature
                MG_Feature newFeature = new MG_Feature(this.Feature);
                //3 add new feature to layer
                this.Layer.AddFeature(newFeature);

                //4 clear data to store the next point
                this.MapPoint.Clear();
            }
        }
Example #9
0
 public void Add(MG_Feature field)
 {
     this.FeatureSet.Add(field);
 }
Example #10
0
 public void Add(MG_Feature field)
 {
     this.FeatureSet.Add(field);
 }
        public override void MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                this.IsMouseDown = false;

                // screen point to map point
                MG_LineString MapLineString = new MG_LineString();
                for (int i = 0; i < this.LineString.Count();i++ )
                {
                    MG_Point screenPoint = this.LineString.GetAt(i);
                    Point screen = new Point((int)screenPoint.x, (int)screenPoint.y);
                    MG_Point mapPoint = MG_BaseRender.ToPoint(screen, this.MapView);
                    MapLineString.Add(mapPoint);
                }
                MG_LineString MapLineStringOther = new MG_LineString();
                for (int i = 0; i < this.LineStringOther.Count(); i++)
                {
                    MG_Point screenPoint = this.LineStringOther.GetAt(i);
                    Point screen = new Point((int)screenPoint.x, (int)screenPoint.y);
                    MG_Point mapPoint = MG_BaseRender.ToPoint(screen, this.MapView);
                    MapLineStringOther.Add(mapPoint);
                }

                //1 create a feature
                // 1.1 set geometry
                this.Feature.SetGeometry(MapLineString);
                // 1.2 set field value
                for (int i = 0; i < this.Feature.GetFieldSet().Count(); i++)
                {
                    this.Feature.SetValue(i, null);
                }

                //2 create a new feature
                MG_Feature newFeature1 = new MG_Feature(this.Feature);
                //3 add new feature to layer
                this.Layer.AddFeature(newFeature1);

                //4 clear data to store the next linestring
                this.LineString.Clear();

                //1 create a feature
                // 1.1 set geometry
                this.Feature.SetGeometry(MapLineStringOther);
                // 1.2 set field value
                for (int i = 0; i < this.Feature.GetFieldSet().Count(); i++)
                {
                    this.Feature.SetValue(i, null);
                }

                //2 create a new feature
                MG_Feature newFeature2 = new MG_Feature(this.Feature);
                //3 add new feature to layer
                this.Layer.AddFeature(newFeature2);

                //4 clear data to store the next linestring
                this.LineStringOther.Clear();
            }
        }
Example #12
0
        protected MG_FeatureSet GetFeatureSet(MG_FieldSet fieldSet,string table)
        {
            NpgsqlDataReader reader = this.SelectAll(table);
            if (reader == null || !reader.HasRows)
            return null;

            MG_FeatureSet featureSet = new MG_FeatureSet();
            int fc = reader.FieldCount; // 4
            while (reader.Read())
            {// oid f1,f2,f3... geom
                MG_Feature f = new MG_Feature(fieldSet);
                MG_ValueSet valueSet = new MG_ValueSet();
                string oid = reader["oid"].ToString();
                string geom = reader["geomtext"].ToString();

                for (int i = 1; i < fc-1; i++)
                {
                    string str = reader[i].ToString();
                    MG_Value value = new MG_Value(i - 1, str);
                    valueSet.Add(value);
                }
                f.ValueSet = valueSet;
                f.Geometry = MG_ShapeFileOper.AsGeometry(geom);
                featureSet.Add(f);
            }
            reader.Close();
            reader.Dispose();
            return featureSet;
        }