示例#1
0
        private void addPostGIS_Click(object sender, EventArgs e)
        {
            // get selected map first
            MG_Map map = this.getSelectedMap();
            ArrayList tables = m_pgOper.GetTableNames();
            MG_DlgListTableNames dlg = new MG_DlgListTableNames();
            dlg.InitializeTableNames(tables);
            dlg.ShowDialog();
            string selectedTable = dlg.GetSelectedTableName();
            if (selectedTable != null)
            {
                MG_Layer layer = new MG_Layer();
                layer = m_pgOper.ExportLayer(selectedTable);
                map.AddLayer(layer);

                // update m_gMapView
                this.updateMapView();

                // add to treeview
                TreeNode layerNode = new TreeNode();
                layerNode.Text = layer.GetLayerName();
                layerNode.Checked = true;
                this.forceSelectedNodeToMap();
                this.m_gSelectedNode.Nodes.Add(layerNode);
                this.m_gSelectedNode.ExpandAll();
                // set selected node to layer node
                this.m_gSelectedNode = layerNode;
                this.treeViewContent.SelectedNode = this.m_gSelectedNode;
            }

            this.Refresh();
            // set state
            this.setState();
        }
示例#2
0
 public static void RenderLayer(MG_Layer layer, MG_MapView mapview, Graphics g)
 {
     if (layer.GetVisible())
     {
         for (int i = 0; i < layer.GetFeatureCount(); i++)
         {
             RenderFeature(layer.GetFeature(i),mapview, g);
         }
     }
 }
示例#3
0
        public MG_Layer ExportLayer(string table)
        {
            MG_Layer mgLayer = new MG_Layer();
            mgLayer.SetLayerName(table);//

            // read ext
            mgLayer.Extent = this.GetExtent(table);
            MG_FieldSet fieldSet = this.GetFieldSet(table);
            mgLayer.FieldSet = fieldSet;// collect data
            mgLayer.FeatureSet = this.GetFeatureSet(mgLayer.GetFieldSet(), table);
            mgLayer.Type = mgLayer.FeatureSet.GetAt(0).Geometry.Type;
            return mgLayer;
        }
示例#4
0
        public void AddLayer(MG_Layer layer)
        {
            this.LayerSet.Add(layer);

            // calculate extent dynamic
            if (this.MapExtent.Empty())
            {
                this.MapExtent = layer.Extent;
            }
            else
            {
                this.MapExtent = calculateExtent(this.MapExtent, layer.Extent);
            }
        }
示例#5
0
        public void AddLayer(MG_Layer layer)
        {
            this.LayerSet.Add(layer);

            // calculate extent dynamic
            if (this.MapExtent.Empty())
            {
                this.MapExtent = layer.Extent;
            }
            else
            {
                this.MapExtent = calculateExtent(this.MapExtent, layer.Extent);
            }
        }
示例#6
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;
        }
示例#7
0
        private DataTable GetDataTable(MG_Layer layer)
        {
            // Create a new DataTable.
            DataTable table = new DataTable(layer.GetLayerName());

            // add oid
            DataColumn oid_Column = new DataColumn("OID", Type.GetType("System.Int32"));
            table.Columns.Add(oid_Column);

            int i, j;
            // Add the column
            for (i = 0; i < layer.GetFieldSet().Count(); i++)
            {
                MG_Field field = layer.GetFieldSet().GetAt(i);
                DataColumn column = new DataColumn(field.Name);
                column.DataType = Type.GetType("System.String");
                // Add the Column to the DataColumnCollection.
                table.Columns.Add(column);
            }

            // Add the row
            for (i = 0; i < layer.GetFeatureCount(); i++)
            {
                MG_Feature f = layer.GetFeature(i);
                DataRow row = table.NewRow();
                // add oid
                row[0] = i+1;

                for (j = 0; j < f.GetFieldCount(); j++)
                {
                    object value = f.GetValue(j).Value;
                    if (value != null)
                    {
                        row[j + 1] = value.ToString();
                    }
                }

                // Add the row to the DataRowCollection.
                table.Rows.Add(row);
            }

            return table;
        }
示例#8
0
        public void ImportLayer(MG_Layer layer)
        {
            if (layer == null)
             return;
            // stop multi same data
            if (this.IsTableExist(layer.GetLayerName()))
                return;

            this.CreateTable(layer.FieldSet, layer.Type);
            string layerName = layer.FieldSet.GetName();
            int fc = layer.GetFeatureCount();
            // save ext
            this.CreateTableExt();
            this.InsertExtent(layerName,layer.Extent);
            for (int i=0; i< fc;i++)
            {
                MG_Feature f = layer.GetFeature(i);
                if (f.Geometry.Type == layer.Type)
                {
                    this.Insert(layerName, f.ValueSet, f.Geometry);
                }
            }
        }
示例#9
0
        private void newLayer_Click(object sender, EventArgs e)
        {
            // get selected map first
            MG_Map map = this.getSelectedMap();

            // new layer
            MG_Layer layer = new MG_Layer();
            //set layer extent
            MG_MapExtent mapExt = map.GetMapExtent();
            if (mapExt.Empty())
            {
                layer.Extent = new MG_MapExtent(this.panel1.ClientRectangle);
            }
            else
            {
                layer.Extent = mapExt;
            }

            // get layer name AND type
            MG_DlgNewLayer dlg = new MG_DlgNewLayer();
            dlg.InitializeLayerName(layer.GetLayerName());
            dlg.InitializeLayerType(MG_GeometryType.LINESTRING);
            dlg.ShowDialog();
            layer.SetLayerName(dlg.GetLayerName());
            layer.SetLayerType(dlg.GetLayerType());

            // add layer to map
            map.AddLayer(layer);

            // update m_gMapView
            this.updateMapView();

            // add to treeview
            TreeNode layerNode = new TreeNode();
            layerNode.Text = layer.GetLayerName();
            layerNode.Checked = true;
            this.forceSelectedNodeToMap();
            this.m_gSelectedNode.Nodes.Add(layerNode);
            this.m_gSelectedNode.ExpandAll();

            // set selected node to layer node
            this.m_gSelectedNode = layerNode;
            this.treeViewContent.SelectedNode = this.m_gSelectedNode;

            this.Refresh();
            // set state
            this.setState();
        }
示例#10
0
 public void Add(MG_Layer layer)
 {
     this.LayerSet.Add(layer);
 }
示例#11
0
 public MG_ToolDrawLineString(MG_Layer layer, MG_MapView mapview)
     : base(MG_ToolType.Tool_DrawLineString, layer, mapview)
 {
     this.LineString = new MG_LineString();
 }
示例#12
0
 public MG_ToolDrawPoint(MG_Layer layer, MG_MapView mapview)
     : base(MG_ToolType.Tool_DrawPoint, layer, mapview)
 {
     this.MapPoint = new MG_Point();
 }
示例#13
0
        protected bool IsStart = true; // start end

        #endregion Fields

        #region Constructors

        public MG_ToolDrawRectangle(MG_Layer layer, MG_MapView mapview)
            : base(MG_ToolType.Tool_DrawRectangle, layer, mapview)
        {
        }
示例#14
0
 public void Add(MG_Layer layer)
 {
     this.LayerSet.Add(layer);
 }
示例#15
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();
 }
示例#16
0
 public void SetLayer(MG_Layer layer)
 {
     this.layer = layer;
 }